I’m building a puzzle game app for iPhone. The user have to solve the puzzle on time.
If the user leaves the game (turning of the phone or pushing the big menu button) I would like to clock to keep counting down. Is that possible or would the timer just be paused along with the rest of the game?
iOS has some pretty tight controls on what you can do when your app is not in the foreground as they prefer user battery life over developer convenience. Perhaps a better way to handle this would be to capture the “go to sleep” event and record the timestamp. Then capture the wake event and look for captured timestamp and compare. Basically faking the countdown that you could have had that nobody could see anyhow.
As wwb said, that is your best option, as once the app leaves the foreground, there is a limited amount of time you have to process any last async code, but it gets paused