How should Cordova plugin for single platform be packaged? -


background

i developing cordova app must run service, i.e. continue in background , restart when device does. far can tell, on ios case of setting uibackgroundmodes correctly on android requires little more effort , service needs explicitly started.

i have developed plugin android based on mark taylor's example here.

at present have js called on deviceready start android code don't need ios.

question

how should package plugin work on platforms 0 config. seems clunky write if (device.type == 'android') statements in main js don't want write native null implementations.

is there suggested approach this?

figured out using <js-module> tag described here.

added plugin.xml:

<platform name='android'>     ...     <js-module src="androidspecificstuff.js" name="somemodule">         <clobbers target="somemodule" />     </js-module>     ... </platform> 

then in androidspecificstuff.js had code like:

document.addeventlistener('deviceready', function () {     // android-specific initialisation here   }) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -