moshikafya
moshikafya

Reputation: 3320

background operation

Is it possible to put your app in the background, and have a counter that once expires, wakes up the app and have the app does some action? I know it's basic, but I just cant seem to have it work. Where do I put this counter + action? Under app did enter background?

Thanks for the help.

Upvotes: 0

Views: 78

Answers (1)

AlexWien
AlexWien

Reputation: 28767

I don't think that this works in general:

You are allowed only to run in the background for specific tasks:

Apple doc tells which tasks that are:

One of that tasks is receiving GPS messages.

As long as you have GPS enabled and your app configured that it uses GPS for background, your app stays alive in the background. If you disable GPS some time later it will suspend, and not wake up till the user activates it.

So to realize your problem you have to stay active in the background (e.g by reading GPS). You can start the timer in AppDelegate:applicationDidEnterBackground or similar

If you need more time to shutdown, you explicitly can request for more time, there is one method for that. I dont know what happens if you request more at regulary intervals

Upvotes: 3

Related Questions