javascript - Cordova plugin background mode : onactivate is not working the first time (android) -
i'm trying use background mode plugin in ionic application i'm encountering issue.
i same thing shown in readme of github project backgroundmode.onactivate
. work fine if not working second time go background.
if has idea issue, i'd glad hear :)
sample code :
$ionicplatform.ready(function() { document.addeventlistener('deviceready', function () { // android customization cordova.plugins.backgroundmode.setdefaults({ text:'doing heavy tasks.'}); // enable background mode cordova.plugins.backgroundmode.enable(); if(cordova.plugins.backgroundmode.isenabled()){ console.log('hi, enabled. signed : backgroundmode.'); } // called when background mode has been activated cordova.plugins.backgroundmode.onactivate = function () { settimeout(function () { // modify displayed notification cordova.plugins.backgroundmode.configure({ text:'running in background more 5s now.' }); console.log('running in background more 5s now.'); }, 5000); } }, false);
note : line hi, enabled. signed : backgroundmode.
when application launched.
i changed way of doing things round problem. did not manage understand bug though :(
document.addeventlistener("pause",onpause,false); function onpause() { $timeout(function() { console.log("running in background more 5s ..."); }, 5000); };
Comments
Post a Comment