cordova-plugin-background-mode
cordova-plugin-background-mode copied to clipboard
javascript code(an $interval function) doesn't run in background mode on android8
On android 6, it works like a charm. But on android 8, the $interval function doesn't run. Does anyone get the same issue?
@ITKing80 Hi I have the same issue. the background mode only runs for about 5 mins, then the app is not running anymore, anyone has a solution?
Same issue in Samsung Galaxy S8 Android Oreo 8.0
It works perfectly for me, but when the application is in the foreground. However, when the application goes to the second plane, after 10 minutes it stops.
I have solved it using setTimeout recursively to create something similar to setInterval
I have solved it using setTimeout recursively to create something similar to setInterval
It works. You saved my life!
@magancete how are you, can you please share me , you function with seTimeout. since in the device after 10m to freeze the interval :(
@magancete how are you, can you please share me , you function with seTimeout. since in the device after 10m to freeze the interval :(
vat time = //time you want in miliseconds;
var timer = setTimeout(function request() {
if(condition){
//do something
} else {
time = newTime;
timer = setTimeout(request, time);
}
}, time);
If you want to clear timer use clearTimeout(timer);
@magancete Thanks so much.
@santiagovasquez @magancete Does this fix still work? I am facing a similar challenge with using setInterval and I used the solution mentioned using timeout but still it stops working after 5 mins at the background.
i have the same problem of @meghajayakumar. After 5 min these functions stop working:
- recursive
setTimeout()
-
setInterval()
- rxjs
interval()
Solved using this:
this.backgroundMode.on('activate').subscribe(() => {
this.backgroundMode.disableWebViewOptimizations();
this.backgroundMode.disableBatteryOptimizations();
});
@FrancescoPaiola Where did you put these lines?