In order to run a phonegap app we need plugins , i've installed this plugin https://github.com/katzer/cordova-plugin-background-mode followed the steps given added the following code, but no success. a little help would be appreciated. or are there any plugins about any tutorials are available ?? thanks
window.onunload=function(){
alert("sdcvbh");
window.plugin.backgroundMode.enable();
};
onDeviceReady: function() {
app.receivedEvent('deviceready');
alert("v");
window.plugin.backgroundMode.disable();
},
try something like this:
<script src="cordova.js></script>
<script>
function onDeviceReady(){
document.addEventListener('pause', onPause, false);
document.addEventListener('resume', onResume, false);
window.plugin.backgroundMode.disable();
}
function onResume(){
window.plugin.backgroundMode.disable();
}
function onPause(){
window.plugin.backgroundMode.enable();
}
document.addEventListener('deviceready', onDeviceReady, false);
</script>
This will use the cordova deviceready, pause and resume events and should accomplish what you need.
For more info on available events checkout this (current version of cordova is 3.5.0 at the time of writing this.)