I want to implement long-running background timer which sends user's location to server periodically.
To do this, I set location
mode for UIBackgroundModes
, and call beginBackgroundTaskWithExpirationHandler
when the application goes to background.
And for CLLocationManager
, I use startUpdatingLocation
method (don't want to use significant change, because I need high precision location).
But around 26minutes after the app goes to background, it stops to send location to the server. But the app isn't crashed, so after I bring the app to foreground, it can resume its timer.
26minutes is from experiments, with iOS 6.1, iPhone 5.
Here are some questions,
I can't understand why it suspends after 26mins not 10mins, which is known as time limit for background task.
Before 16mins,
backgroundTimeRemaining
methods returns double max value. But after 16mins, it decreases from600
, so it suspends the background task after 10mins.
I already tried to call beginBackgroundTaskWithExpirationHandler
inside of expiration handler, but no use.
If there's anyone who has a clue for this problem, will be greatly appreciated.