iOS Background Mode: After running location updates in the background, the app never terminates.

I'm running location updates in the background. All works well:

- On significant location the app is launched in the background

- appDidFinishLaunching(options:) is called as expected.

- I start LocationManager startUpdatingLocation() and startMonitoringSignificantLocationChanges()

- Locations are collected correctly.

- After some time, I call stopUpdatingLocation()

- My program at this stage doesn't need to do anything and no further code is executed


At this point the program stays idle. applicationWillTerminate is never called again. Is this expected? I'd hoped the app will shut down again as no location updates are required.


What's the expected behaviour? Should the app shut down or should it stay idle forever?


Once this happens, then if a user user opens the app or a significant location is received again, then appDidFinishLaunching(options:) is NOT called, but instead applicationDidBecomeActive.


Is there any documentation I can follow that supports the expected behaviour?

Replies

Hi there! We have a similar app which launched in the background when significant location update is detected. However, after iOS 13, we have some issues to have the app run long enough in the background. The app stops running in the background after 30 seconds. iOS 12 worked really well. Do you have this issue? Appreciate if you could share more on this! Thanks so much!