I am developing an mobile application (platform: Android, iOS) with Cordova.
My application needs ping an URL to fetch data every hours. I want my application still ping the URL when it's closed.
I searched in google and I get some of this plugins:
I need a plugin like the second one but also work when the application is closed like scheduled notification like the first one.
Is there any plugin like this for cordova? Or it's impossible to do background task like this with cordova.
Thank you
I had some what the same issue, i needed to pick lat,lng every few minutes and calcuate the distance, but background plugin alone couldnt solve it, as it stops working when the phone goes to sleep .. so I had to make sure, the phone doesn't go to sleep ..
So i used power management plugin together with Background mode plugin.. and it works well..
Background mode Plugin: https://github.com/katzer/cordova-plugin-background-mode
Power Management Plugin https://github.com/boltex/cordova-plugin-powermanagement
if( ionic.Platform.isAndroid() ){
cordova.plugins.backgroundMode.enable();
window.powerManagement.dim(function() {
console.log('Wakelock acquired');
}, function() {
console.log('Failed to acquire wakelock');
});
window.powerManagement.setReleaseOnPause(false, function() {
console.log('setReleaseOnPause successfully');
}, function() {
console.log('Failed to set');
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With