Background location updates and state restoration

Hello,

I am having troubles with my tracking app. The goal is for the user to start location manager updates (tracking) in the foreground and then allowing him to minimise the app and use the phone with other apps. Just letting my app in the background fetching location, analysing IMU sensors and processing the data so an overview can be presented after the tracking finishes.

What I found out from beta testers is that they correctly launched the tracking in foreground, then they switched to a different app and some of them just locked their devices. The tracking stopped after around 20 minutes and the users report that the app was suspended by the system and that they are back at the login screen.

How is this possible? I thought that once user starts location updates in the foreground and then goes into the background and uses other apps/locks the device, the system should never suspend the app and this shouldn't happen - ergo I should not bother implementing state restoration. Am I wrong about that?

I have Background Modes - Location Updates enabled as well as these three lines:
Code Block
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.showsBackgroundLocationIndicator = true


Does anyone have any ideas?
Thank you for your time.
Background location updates and state restoration
 
 
Q