I found a solution to implement this with the help of the Apple Developer Forums:
- Specify
location background mode - Create an
NSTimerin the background withUIApplication:beginBackgroundTaskWithExpirationHandler: - When
nis smaller thanUIApplication:backgroundTimeRemainingit will work just fine. Whennis larger, thelocation managershould be enabled (and disabled) again before there is no time remaining to avoid the background task being killed.
This works because location is one of the three allowed types of background execution.
Note: I lost some time by testing this in the simulator where it doesn’t work. However, it works fine on my phone.