I have a timer in my Ionic3 application. The timer runs perfectly with a setInterval, but when I close the App into the sleep mode, the timer stops to run. After bringing my App again to the fourground, the timer continue - but he starts at the place where it paused before.
how can I prevent the timer from pausing If I background the App?
My component
time: any;
displayTime() {
this.time = moment().hour(0).minute(0).second(this.counter++).format('HH : mm : ss');
}
startTime() {
if(this.runClock == null) {
this.runClock = setInterval(() => {
this.displayTime();
},1000)
}
}
In my HTML I call {{ time }}.
Plugins like https://ionicframework.com/docs/native/background-mode/ will not work, because the App Store will reject Apps using this plugin.
Any other ideas?