I'm working on an app that monitors the user's location.
After I call startUpdatingLocation()
I can put the app in the background. It continues to update the location. That works well.
My question is: can I restart the continuous location updates from a didExitRegion
call in the background? Now if I simply call startUpdatingLocation()
again, the app gets killed after 10 seconds.
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
locationManager.startUpdatingLocation()
}
So the steps would be:
- I ask the location manager to
startUpdatingLocation()
. - The user puts the app in the background while the location updates are continuously being received.
- The user stops for a while (for a coffee for example) so I ask the location manager to put down a geofence and
stopUpdatingLocation()
. - The user continues his drive so when he leaves the geofence I'd like to ask the location manager to
startUpdatingLocation()
again.