Reputation: 33
I want to do the following:
Create a Phonegap service that runs in the background even if the android app is not open.
Upvotes: 2
Views: 1362
Reputation: 1307
You may use the plugin: https://github.com/katzer/cordova-plugin-background-mode
To prevent the app from being paused while in background, the backroundMode.enable interface has to be calle, like this:
cordova.plugins.backgroundMode.enable();
So, the backgroundMode.isActive interface can be used to get the information if the background mode is active:
Then, the backgroundMode.onactivate interface can be used to get notified when the background mode has been activated.
cordova.plugins.backgroundMode.isEnabled();
cordova.plugins.backgroundMode.onactivate = function() {};
See the link to more detailed information, I have helped.
Upvotes: 3