I have an app which continually tracks the device location in background. This worked pretty well in ios 11.4 where I could let run the app in background for days while still doing other stuff in foreground.
Now with ios 12 the app does stop running after some time when the device is let alone.
LocationManager is intialized as follows:
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
locationManager.startUpdatingHeading()
locationManager.allowsBackgroundLocationUpdates = false
locationManager.pausesLocationUpdatesAutomatically = false
if #available(iOS 11.0, *)
{
locationManager.showsBackgroundLocationIndicator = true
}
locationManager.distanceFilter = prefs.getDoubleFromString(Prefs.PREF_DISTANCE_FILTER, defaultVal: 2.5)
When the user decides to start tracking
locationManager.allowsBackgroundLocationUpdates = true
is set.
The app has the "Always" privilege set for location service.
Any idea what changed in ios 12 ?
This seems to be a bug since iOS 12 that apps will get terminated in background for no decent reason. I've filled in a bug report.
See for more information and a demo project to demonstrate the problem here: iOS 12 terminates apps in the background for no reason
Bug is fixed in iOS 12.2 beta 2 (16E5191d)
I have this question too, and I try to turn off the "Do Not Disturb" last night, background location service works fine.
So, the "Do Not Disturb" mode can stop location service?
Any other way to avoid location service stopping except turn off "Do Not Disturb"?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With