Background location updates stop in iOS 16.4

Our app gets background location updates and has been working well right up to, and including iOS 16.3.1.

However, testing with iOS 16.4 we are finding that background location updates stop shortly after they start. I have spoken with other developers and they’re noticing the same thing.

Anyone else using background location updates finding this to be a problem?

Answered by Engineer in 749230022

The issue that is described here due to the changes with iOS 16.4 (and above) which affect the behavior of apps tracking location in the background.

Beginning in iOS 16.4, apps calling both startUpdatingLocation() AND startMonitoringSignificantLocationChanges() may get suspended in the background if they are specifying low accuracy and distance filtering in the location manager settings.

If your app needs only low accuracy locations of kCLLocationAccuracyKilometer and up, use startMonitoringSignificantLocationChanges() for that purpose instead.

If your app requires continuous high accuracy locations in the background, you must set the following location manager properties:

  • allowsBackgroundLocationUpdates must be set to TRUE or YES
  • distanceFilter must not be set, or set to kCLDistanceFilterNone
  • desiredAccuracy must be kCLLocationAccuracyHundredMeters or better. If you’re using numeric values, it must be set to less than 1000 meters

Alternatively you can turn on the location indicator which will avoid the issue. You can do this by setting

  • showsBackgroundLocationIndicator to TRUE or YES

If you implement the above changes in your app, its location update behavior will be similar to behavior prior to iOS 16.4. Without these changes, your app may not be able to receive continuous background location updates.

I have encountered this problem too. It seems that it cannot be used properly since iOS 16.4 beta 2. Does anyone know how to solve this problem?

I tried now on my iPad with iOS 16.4 RC and there is no problem with the app staying in the background. I switched off significant location updates as well as part of the experiment, the app still stays in the background with no problem. ~20 minutes now. If you can test this on iPad with iOS 16.4 then we can see if this is iPad vs iPhone that makes a difference or something in your vs mine configuration of a LocationManager.

I have confirmed an issue with iOS16.4 / iPadOS16.4 RC where location cannot be obtained when the app is in the background. (This also occurs on iPadOS 16.4RC.) Has anyone received a useful response from Apple on bug reports, etc.?

Are you using showsBackgroundLocationIndicator = false or showsBackgroundLocationIndicator = true? Are you calling startUpdatingLocation() when the app is foregrounded or backgrounded?

I filed a bug report: https://feedbackassistant.apple.com/feedback/12082689

Before iOS 16.4, we could reliably start CLLocationManager in the background (for example, in response to a CLCircularRegion exit or a CLVisit arrival) by calling startUpdatingLocation(), and keep it running indefinitely, assuming we had "Always" location permissions and the "Location updates" background mode. As of iOS 16.4, this no longer works reliably if the CLLocationManager is started when the app is backgrounded and showsBackgroundLocationIndicator = false. It does still seem to work if the CLLocationManager is started when the app is foregrounded and showsBackgroundLocationIndicator = true. We have seen a few similar reports on the developer forums: https://developer.apple.com/forums/thread/727015 https://developer.apple.com/forums/thread/726945 Did this behavior change in iOS 16.4? Thank you.

Same here. CLLocation stops location updates in iOS 16.4 if it starts running in the background. Any work around patch to fix this issue? Should I just set showsBackgroundLocationIndicator = true and will it solve the issue?

@nickradar. Went for a drive now with iOS 16.4 public and for me it all works 100% unless I'm severely overlooking something. I do have showsBackgroundLocationIndicator = true on the location manager that records a track. I don't have it on the location manager that listens for regions (iBeacons), but I do call startUpdatingLocation() on a region location manager before handing it over to the track location manager with showsBackgroundLocationIndicator = true, otherwise my track recording location manager would not start/stay recording in the background, I thought it was iOS specific - it might be iOS 16.4 specific then.

I have competitor apps installed for the automatic mileage tracking, and 2 of 5 (all that really track) recorded now something like:

That would correspond to points in the significant location updates, maybe. No recording in between.

That's going to be interesting.

One more thing, on significant location events I do ask for the background time extension. Not sure that plays any role, I ask due to other things, but also start a probing location manager that has showsBackgroundLocationIndicator = false and it works. Hope this will not give Apple any wrong ideas :).

I'm only seeing the issue when showsBackgroundLocationIndicator = false and startUpdatingLocation() is called while the app is backgrounded. When showsBackgroundLocationIndicator = true and startUpdatingLocation() is called while the app is foregrounded, no issues. Before iOS 16.4, both cases worked fine.

I'm not starting background tasks, although I'm also not seeing [[UIApplication sharedApplication] backgroundTimeRemaining] ticking down.

I'll do some more testing tomorrow.

I have the same problem. Background location updates stopped working. The issue is in the simulator too. I'm trying some configurations but the problem persists. I hope Apple sends a quick hotfix.

I'm testing now on simulator and for me if I set showsBackgroundLocationIndicator = true, the location updates are working in background and foreground correctly. Today I will test real device.

I can confirm that showsBackgroundLocationIndicator = true solve the problem. Is not a definitive solution but could be an hotfix. I hope that Apple fix it on CoreLocation framework.

The issue that is described here due to the changes with iOS 16.4 (and above) which affect the behavior of apps tracking location in the background.

Beginning in iOS 16.4, apps calling both startUpdatingLocation() AND startMonitoringSignificantLocationChanges() may get suspended in the background if they are specifying low accuracy and distance filtering in the location manager settings.

If your app needs only low accuracy locations of kCLLocationAccuracyKilometer and up, use startMonitoringSignificantLocationChanges() for that purpose instead.

If your app requires continuous high accuracy locations in the background, you must set the following location manager properties:

  • allowsBackgroundLocationUpdates must be set to TRUE or YES
  • distanceFilter must not be set, or set to kCLDistanceFilterNone
  • desiredAccuracy must be kCLLocationAccuracyHundredMeters or better. If you’re using numeric values, it must be set to less than 1000 meters

Alternatively you can turn on the location indicator which will avoid the issue. You can do this by setting

  • showsBackgroundLocationIndicator to TRUE or YES

If you implement the above changes in your app, its location update behavior will be similar to behavior prior to iOS 16.4. Without these changes, your app may not be able to receive continuous background location updates.

Hi. Do you have a source for this? By the way, enabling the showsBackgroundLocationIndicator flag has worked for me too.

Hi

I have the same problem in my app. I need to be able to use startUpdatingLocation with a distance filter set (200m) without setting the showsBackgroundLocationIndicator flag to true. My app needs to, in the background, be able to determine deltas in the user's location to figure out if a user is travelling or not. I'd use the CoreMotion API but that's also limited in the background, and from my testing only works when the locations are coming through in the background as well, so I am using a combination of both.

Using the significant change monitoring service is not reliable or frequent enough, by the time that my app MAYBE gets a location update through that service, I've missed out on half of the trip. Also, it seems that region monitoring has the same problem, I tried to implement it but my app stops receiving locations in the background. Please help, this is quite urgent and is clearly causing breaking changes for everyone affected. It's pretty inaccurate that my app now has to show a location pill indefinitely to users throughout the night or during the day when their location isn't even changing enough for me to use it. I can understand if the pill shows when my app starts receiving locations and goes away when my distance filter is no longer being exceeded, but this it really excessive.

Also, it's counter intuitive that my app can receive locations freely with no distanceFilter set in the background without notifying the user about this with the pill?

As a developer, I'd expect better communication from Apple to its developers of changes such as this that have the power to completely break apps. And clearly this change wasn't thought through very well.

We have made changes according to the answer [@Gualtier Malde](https://developer.apple.com/forums/profile/Gualtier Malde), but in iOS 16.5 we again notice that the application goes into suspended state while the app is in background. This does not happen on all devices and it is difficult to understand what the problem is

This change also caused significant problems for our app. Removing the distance filter seems to have fixed the issue and the app seems to be running ok in background again. I use accuracy 100m and no location indicator.

However, one drawback of not having the distance filter is that when moving, even walking or on a bike, I get 20-30 events per minute mostly with no change in coordinates.

I suspect an increase in the battery consumption assigned to our app due to this, which if true will make users unhappy.

[@Gualtier Malde](https://developer.apple.com/forums/profile/Gualtier Malde) I'm really asking for help! With all due respect, the suggested solutions have not helped. The number of users with the problem is steadily increasing every day. From our data, the increase in the number of users with the problem is not going to stop. Please pay attention to this problem, and maybe something went wrong by design?

@Scott--R did the recommendations above help? Were you able to solve the problem? In my case the recommendations did not help, the reach of users with the problem is growing

Only setting showsBackgroundLocationIndicator to TRUE or YES did not work for me (iOS 16.5.1). I had to unset distanceFilter as well to make it work.

Thank you all for your support and feedback. I've made a lot of tests with IOS versions < 16.4 and IOS versions >= 16.4

The conclusion today is that the best solution was given by Gualtier Malde in this thread, but with one exception: distanceFilter must not be set ONLY (set it to kCLDistanceFilterNone leads to a non-deterministic behavior in 16.4 and upper versions, and stops the location updates or send updates completely erratically.

So with the below code, the location updates in background with IOS > 16.4 work for roughly 5h. After that, it's a mystery why it stops. The debugger spits out nothing ....

  • allowsBackgroundLocationUpdates must be set to TRUE
  • distanceFilter must not be set
  • desiredAccuracy must be kCLLocationAccuracyHundredMeters or better. If you’re using numeric values, it must be set to less than 1000 meters (in my case it's 30 meters)
  • showsBackgroundLocationIndicator to TRUE (when I set it to false ou not set, the behavior got worse)

My app's code now tests which IOS version the device runs and I remove distanceFilter when > 16.4. In the locationManager I also send updates to my backed only every 30s because IOS 16.4 ignores Timer.scheduledTimer ...

At this point of time, I don't know how to do better. I just updated my phone to 16.5 and will run some tests with this version but no hope. It's a shame that with IOS 14.x it works so well ...

If someone has the magic solution, please share.

My problem was unrelated to the main problem discussed here, so with the piece of code below, any IOS release below or above 16.4 work.

Use case for the example: I print latitude and longitude every 30s.

This code so far worked for +24h like a charm, whatever the device moves or not, whatever the app is in the foreground or in the background, whatever the screen is on or off. Of course you must select 'Location updates' for 'Background modes' in 'Signing & Capabilities' of your project's Target. But this is obvious no :)

class TestLocation: UIViewController, CLLocationManagerDelegate{ @objc var locationManager: CLLocationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() // Configure location manager locationManager.delegate = self // requestAlwaysAuthorization() could be done before in your app, which is the case for me but for the example, I put it here (indeed requestAlwaysAuthorization() MUST be done when the app starts to avoid any crash, if you do some stuff before doing startUpdatingLocation()) locationManager.requestAlwaysAuthorization() locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.allowsBackgroundLocationUpdates = true locationManager.pausesLocationUpdatesAutomatically = false locationManager.showsBackgroundLocationIndicator = true locationManager.startUpdatingLocation() }

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    guard let currentLocation = locations.last(where: { $0.horizontalAccuracy >= 0 }) else { return }

    if let lastUpdateDate = lastLocationUpdateDate, Date().timeIntervalSince(lastUpdateDate) < 30 {
       return
    }
    else{
        print("Latitude: \(currentLocation.coordinate.latitude), Longitude: \(currentLocation.coordinate.longitude)")
        lastLocationUpdateDate = Date()
    }
}

}

Hope it helps

Background location updates stop in iOS 16.4
 
 
Q