9

I am trying to use some CoreLocation features, and I am running into problems with deferred location updates.

For some reason when the app was updated for iOS 10 deferredLocationUpdatesAvailable returns NO always. I am testing on an iPhone 6s, so I know that the device is capable of using GPS features.

I tried using this to debug:

[CLLocationManager deferredLocationUpdatesAvailable]

I can't figure out if this is an issue with iOS 10 or if I have something set incorrectly.

In this method:

- (void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(NSError *)error {
    self.deferringUpdates = NO;
    NSLog(@"DEFERRING Error: [%@]", error);
    if (error) {
        [[LocationManagerClient alertWithMessage:error.localizedDescription andTitle:error.domain] show];
    }
}

I end up logging this error:

DEFERRING Error: [Error Domain=kCLErrorDomain Code=11 "(null)"]

Has anyone else run into this problem with iOS 10 or have any idea what is going on?

Edit: This is how I am setting the distance filter

- (void)configureForApplicationWillResignActive {
    [_locationManager setAllowsBackgroundLocationUpdates:YES];
    [_locationManager setPausesLocationUpdatesAutomatically:NO];
    [_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
    [_locationManager setDistanceFilter:kCLDistanceFilterNone];   // use distance filter
    [_locationManager requestAlwaysAuthorization];
}

- (void)configureForApplicationDidBecomeActive {
    [_locationManager setAllowsBackgroundLocationUpdates:YES];
    [_locationManager setPausesLocationUpdatesAutomatically:NO];
    [_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
    [_locationManager setDistanceFilter:kCLDistanceFilterNone];   // use distance filter
    [_locationManager requestAlwaysAuthorization];
}
Erik
  • 295
  • 2
  • 10
  • Have you set a distance filter other than 0? This will cause error 11. Can you show how you have initialised your CLLocationManager? – Paulw11 Sep 14 '16 at 20:19
  • Edited for more detail. – Erik Sep 14 '16 at 20:29
  • We have exactly the same problem, calling [CLLocationManager deferredLocationUpdatesAvailable] always returns NO on iOS 10 on our iPhone 6s and 6 devices. Activating deferred location updates causes kCLErrorDomain Code=11 – Thomas Einwaller Sep 23 '16 at 15:09
  • Same problem for me, iPhone 6S with 10.0.2. Very frustrating, because I had spent many days on getting deferred updates right. Did you report it as a bug? – LPG Sep 24 '16 at 13:15
  • We are seeing the same issue in our apps, deferredLocationUpdatesAvailable() always returns false under iOS 10.0.2 and activating deferred locations causes didFinishDeferredUpdatesWithError to be called with kCLErrorDeferredFailed - I filed a radar: https://openradar.appspot.com/radar?id=4927958787555328 – Thomas Einwaller Sep 25 '16 at 06:20
  • Has anyone tried on iOS 11? – alpennec Jun 18 '17 at 17:07
  • Tried, not working in iOS 11. – Yogesh Maheshwari Jul 06 '17 at 19:54
  • is it working at iOS11.2? I'm still struggling with it..... – AlexWoe89 Dec 12 '17 at 11:32

4 Answers4

3

I have already filed a Radar (28303779) with proof of concept sample code - also contains the wording from the radar. I have also opened a dev forum post and it appears a lot of engineers are facing the same problem. deferredLocationUpdatesAvailable() is also returning false in iOS 10. Seems like apple has intentionally turned off the functionality.

Update

My Bug Report got closed saying 'it works as intended'. I suppose Apple does not intend to fix it and it was mistakenly taken out without deprecation first.

zakishaheen
  • 5,551
  • 1
  • 22
  • 29
2

Deferred updates are now officially deprecated (in iOS 13). This is effectively an admission that they have not been supported for several years.

matt
  • 515,959
  • 87
  • 875
  • 1,141
1

I looks like this is a bug in iOS 10

We should all file radars to get it fixed, please dupe mine: openradar.appspot.com/radar?id=4927958787555328

Thomas Einwaller
  • 8,873
  • 4
  • 40
  • 55
  • My Bug Report got closed saying 'it works as intended'. I suppose Apple does not intend to fix it and it was mistakenly taken out without deprecation first. – zakishaheen Sep 29 '16 at 22:49
  • mine was marked as duplicate of 28561857 and will be closed - too bad that there is no information about 28561857 available :/ – Thomas Einwaller Oct 05 '16 at 08:51
  • Now it's the same for me: my own report is closed, but marked as duplicate of 28561857, which itself however is still open. I wonder whether any reasoning will also be forwarded to us when they close 28561857. I can hardly believe that they deliberately removed the feature altogether without deprecating it first or at least mentioning it in any kind of release notes. – LPG Oct 07 '16 at 12:20
  • yeah, especially since it looks like Apple cares a lot about energy efficiency and deferred location updates was a great feature – Thomas Einwaller Oct 07 '16 at 12:51
  • It is neither fixed in iOS 10.1.1 nor did they close the original bug report - it still says "Duplicate of 28561857 (Open)" in my own (closed) bug report. – LPG Nov 05 '16 at 18:15
  • Still not fixed in 10.2. – LPG Dec 15 '16 at 07:19
  • 10.3, still not fixed – David Apr 18 '17 at 02:01
  • Not fixed in iOS 11 – Yogesh Maheshwari Jul 06 '17 at 19:52
  • I am beginning to wonder whether they simply decided to use the motion coprocessor for other tasks. So maybe it will only return on a future device which has a more powerful one? Did anyone try on the latest iPhones 8/X? – LPG Jan 14 '18 at 23:05
0

It seems like it is a "bug". (reproduced on iOS11 and iOS12, iPhone 7, iPad mini 4 cellular)

CLLocationManager.deferredLocationUpdatesAvailable() always returns false, so code for deferred updates never run. However, when app is in the background and Location manager delivers positions via locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]), those positions are delayed as if deferred mode was enabled.

I am thinking that deferred API is there just for compatibility reasons with old apps, and new apps don't need to worry about it at all.

Juraj Antas
  • 3,059
  • 27
  • 37
  • on which iOS version you have tested? I am using `iPhone SE` with `iOS 12.3.1` and it seems that `deferredLocationUpdatesAvailable()` is returning false. – Sauvik Dolui Jun 11 '19 at 05:44
  • tested on iOS11 and iOS12. I am not using deferred updates now, and quite frankly I don't miss them. – Juraj Antas Jun 11 '19 at 15:02