Why does didUpdateLocations: only have one location after locationManagerDidResumeLocationUpdates:

321 views Asked by At

I have location services working in iOS8.

It is set for kCLLocationAccuracyBest using startMonitoringSignificantLocationChanges to restart when in the background and startUpdatingLocation for accuracy.

When I set pausesLocationUpdatesAutomatically = YES, the location services get paused and resumed as expected. However, the following call to didUpdateLocations: only has one location in it.

I was expecting to receive a bunch of locations that were received by the OS while the delivery was paused. Am I missing something here? Does it have anything to do with deferredLocationUpdatesAvailable?

This answer talks about a post on Apple Dev Forum, but I get nothing when searching for pausesLocationUpdatesAutomatically.

Please note: this issue has nothing to do with calling requestAlwaysAuthorization or setting prompts in info.plist.

2

There are 2 answers

0
Quentin Hayot On BEST ANSWER

When you pause the location updates, the system considers that you don't need the location for now. Resuming it will only give you the current location.
This is a normal behavior.

0
Matt On

Further to the answer by Quentin Hayot...

The documentation for pausesLocationUpdatesAutomatically states:

Allowing the location manager to pause updates can improve battery life on the target device without sacrificing location data.

This is highly misleading.

What it really means is when location manager pauses it will sacrifice location data: the app does not get and never will get location updates until the location manager resumes.

It should explain that paused location updates are completely different from deferred location updates.

To improve battery life, the app should call allowDeferredLocationUpdatesUntilTraveled:timeout: which does deliver all location updates gathered while deferring to locationManager:didUpdateLocations:.

The documentation for locationManager:didUpdateLocations: states:

If updates were deferred or if multiple locations arrived before they could be delivered, the array may contain additional entries.

which is reasonably clear, but it could state that it has nothing to do with, and should not be confused with, pausesLocationUpdatesAutomatically.