I would to create a timer in my App. I created a timer as:
var timer = document.getElementById('timer');
var rest = 90;
timer.innerHTML = rest + 's';
var interval = setInterval(function(){
if(rest <= 0){
clearInterval(interval);
}else{
rest -= 1;
timer.innerHTML = rest + 's';
}
}, 1000);
<div id='timer'></div>
But, when the user leaves my app (NOT KILL, JUST LEAVE) and go to any other app, the timer stops working.
And when he comes back to my app, the timer starts working.
This question is a copy to the following:
How can I run background tasks in React Native?
The following answer is written: Currently, there is, unfortunately, no support for background tasks of any kind. The feature you are referring to would be a background timer. Such a timer is this product plain (a feature request) for react native, you may upvote it to show an increased demand for this feature.
(There is no update yet. As far as i know)
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