Anyone seeing iOS11 issue with location services in background?

I have been testing on iOS11 beta versions between 4 and now 8 and I am sometimes seeing an issue where location services stop delivering GPS points when in the background. The logging that I have in the application isn't showing that any application delegate methods are firing, but the application seems to just go to sleep completely. No GPS is reported, nor core motion, etc. I have added the necessary entitlements for "Always On" that iOS11 requires as well, but the issue persists.

Replies

Yes! Everyone seeing this issue should file a bug report.

I have the same issue, however its kind of very inconsistent. I upgraded to latest public version – iOS 11.0.3

After setting all required parameters, I have the app running on two different iPhone 6s.

1. One of the phone just goes to sleep in less then 3 mins and hence no updates from location services (The Location arrow, at the top right corner, disappears)

2. The other phone works for a much longer time, updating location in background, however when in stationary (i.e not in motion), location service stops. (The Location arrow, at the top right corner, disappears)

Even after restarting iphone device (iOS 11 device), it doesn't seem to work properly.

manager.requestAlwaysAuthorization()

manager.desiredAccuracy = kCLLocationAccuracyBestForNavigation

manager.distanceFilter = kCLDistanceFilterNone

manager.pausesLocationUpdatesAutomatically = false

manager.allowsBackgroundLocationUpdates = true

Any other fixes/suggestions/thoughts? Also is it required to keep moving to have the location service active?

>Any other fixes/suggestions/thoughts?


Be sure to add your bug report #(s) to your thread for reference.

We have also seen this issue. However, an iOS update does not seem to cause issues when starting the location updates manually and then sending the app to the background aferwards (our app can do both, which did not simplify bug hunting...). So, regardless of your device model we found that:

- Fresh app install:

* Background start of location updates: works

* Manually start of location updates, and sending app to background: works


- iOS update with app installed:

* Background start of location updates: broken

* Manually start of location updates, and sending app to background: works


- After reboot/toggle "Location Services":

* Background start of location updates: works

* Manually start of location updates, and sending app to background: works


I will file a bug report as well.

Seeing the exact same behavior and result.. we've filed a Radar as well...

In the project navigator, find the Info.plist file, right click on it, and select “Open As”, “Source Code”. Then, inside the top-level

<dict>
section, add:

<key>NSLocationWhenInUseUsageDescription</key>

<string>We'll show you cool things near you in the app.

</string> <!-- iOS 10 or earlier -->

<key>NSLocationAlwaysUsageDescription</key>

<string>We'll show you cool things near you in the app, and alert you via notifications if you don't have the app open.</string>

<!-- iOS 11 -->

<key>NSLocationAlwaysAndWhenInUsageDescription</key>

<string>We'll show you cool things near you in the app. With the "always" option, we can also alert you via notifications if you don't have the app open.</string>


Why the three keys and what do they mean?

  • NSLocationWhenInUseUsageDescription
    should describe how your app uses Location Services when it’s in use (or “in the foreground”).
  • NSLocationAlwaysUsageDescription
    should describe how your app uses Location Services both when in use, and in the background. This description is only for users of your app with iOS 10 or earlier.
  • NSLocationAlwaysAndWhenInUsageDescription
    should also describe how your app uses Location Services both when in use, and in the background. This description is only for users of your app with iOS 11. The users will be given an option to choose between “when in use” and “always” authorization.

I had a chat with an Apple engineer and it seems this behaviour is by design now. If you start location updates in the foreground it should all work as expected. However starting location updates in the background no longer extends the suspension timer. A reboot or reinstall can make it revert back to the old behaviour which apparently is a bug 😟


Significant Location Change is not affected by this - and this seems to fire every 5 min for me - but only gives me ~10sec of airtime before suspension kicks in again.


Love to see this behaviour changed - this pretty much breaks every background telematics app out there. Atleast some official documentation on this would be nice.

Apple must be kidding. There was a similar issue with the introduction of iOS 7.0 (though at that time well documented), which had the result that many many Apps became useless. After protest of the developers they changed this behavior back in iOS 7.1, so Apps could again get location updates from the background. Seems that Apple has forgotten this desaster from a few years back...


There are many Apps which require that the location update is started in the background in order to preverve battery life and because they do need these updates only at certain times. If this is no longer possible the only option would be to start the location update in the foreground and never stop receiving such updates even if the App does not need them (which wastes a lot of energy), so the App can get location updates in the background when these are needed somtime later.


It does not really make much sense that this should be the new intended behavior. Hopefully it was just this one Apple engineer who did not understand this correctly.

If this is new design, I really hope they would make an official note on this soon - and update their docs!

It would not much sense if this would be the new design. Apple has introduced new permission strings for background and foreground usage in iOS 11. So why introducing this when the Apps can no longer get location updates in the background. I really hope that this is not new design. This would kill lots of Apps.

Any update on the bug report? iOS 11.2 still shows the same trouble.

What's the link to the Radar?

We're witnessing the same bug after the upgrade to iOS 11.2.


Without repeating everyone's comments here, the most important observations:


  • We're seeing this with every iOS upgrade since 11.x (also minor upgrades)
  • The issue appears only when updating locations is started in the background.

(If location updates are started in the foreground, it continues flawlessly in the background.)

  • Even if the device is receiving accurate locations from a different app (e.g. Strava started in the foreground), our app seems suspended.
  • The app keeps receiving what appears to be significant locations changes (from interval and distance), followed by ~10 seconds of accurate location updates, after which is goes into suspension again.
  • As a solution / workaround: After the device reboots, the bug disappears, and location updates in the background are restored as before.

I've filed a Apple Bug Report rdar://35990983 (and reposted at Open Radar)

I got this working with a weird fix.


If your app was installed before the update, significant location change will launch the app but then it gets suspended after approximately 10 seconds (repeats every 5 mins).

However, If you install your application right after iOS 11.x.x update, it seems to work just fine. So I thought about unregistering from any previous location services (like significant locations or Region monitoring) at launch and re-registering them (last three lines in code below).


I tested this on 11.2.2 update and works fine while another app without highlighted lines still had the issue on same device. No restart was required for app or iPhone after iOS 11 update. Here is the code.


override init() {

self.cllocationManager = CLLocationManager()

self.cllocationManager.distanceFilter = kCLDistanceFilterNone

self.cllocationManager.allowsBackgroundLocationUpdates = true

self.cllocationManager.activityType = .automotiveNavigation

if (CLLocationManager.authorizationStatus() == .notDetermined) {

self.cllocationManager.requestAlwaysAuthorization()

}

super.init()

self.cllocationManager.delegate = self

self.stopRegionMonitoring() // incase you registered for regions

self.cllocationManager.stopMonitoringSignificantLocationChanges()

self.cllocationManager.startMonitoringSignificantLocationChanges() // re-register for significant location change

}

Just to be sure :-)

Do you state that a call to stopMonitoringSignigicantLocationChanges() followed by a startMonitoringSignificantLocationChanges() would prevent the app from entering idle mode when startUpdatingLocation() is called? So it continues to deliver location updates in the background, even after an OS update?


        locationManager.startUpdatingLocation()
        locationManager.allowsBackgroundLocationUpdates = true
        locationManager.pausesLocationUpdatesAutomatically = false