So, I'm developing an app that has a timer for about 5 minutes. During this time, the app should remain active. Accessing geolocation, counting steps, etc. The problem I'm facing is that the app falls asleep and the timer stops ticking.
I'm using react-native-background-timer for a timer. It shouldn't fall asleep, but it does. On both, android and ios. Actually it works perfectly fine when the app is in debug mode. But on release version without debug app simply falls asleep after about 3 minutes when the screen is turned off and timer stops ticking. It resumes when phone wakes up.
I can keep screen on all the time, with react-native-keep-awake, but I don't like this solution. Because my app also counts steps, and the phone should be ideally in the pocket. And with active screen, it will register accidental presses. Not good.
There should be a way. Phone calls can be really long with disabled screen and phone app doesn't sleep. I just don't know which direction to take. It's also hard to test, because with debug mode, app doesn't fall asleep at all. I need to run the release version and wait 3 minutes hoping the timer won't asleep.
Any ideas? Thanks.