iOS Question Background Timer

Graeme Mitchell

Member
Licensed User
I have to push an app to the background every once in a while and I need the timer that is running to continue. This app isnt published to the App Store, just "downloaded" through the Bridge onto my iPhone
 

hatzisn

Well-Known Member
Licensed User
Longtime User
You are aware that no code is executed in the background, aren't you? The only way to run code in the background, at least as my knowledge goes, is silent push notifications and this is only for 30 seconds or so.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I have to push an app to the background every once in a while and I need the timer that is running to continue. This app isnt published to the App Store, just "downloaded" through the Bridge onto my iPhone

no need to run a timer in the background. when the app goes to the background (check for the relevant event) you can store the current time and when it returns you calculate the time from the current time to the time you stored when leaving the app.

i wrote some time ago an example. the problem is that an app that went to the background may be killed by the OS and you cannot ensure that it will stay alive so the best solution is store the time in a file and calculate it when you return.
 
Upvote 0
Top