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];
}