Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios12 background location service stopping

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 ?

like image 534
Michael Konz Avatar asked Sep 27 '18 09:09

Michael Konz


2 Answers

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)

like image 142
Sjoerd Perfors Avatar answered Sep 27 '22 22:09

Sjoerd Perfors


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"?

like image 21
AntScript Avatar answered Sep 27 '22 21:09

AntScript