Search code examples
iosobjective-ccllocationmanagercllocation

CLLocationManager desiredAccuracy of kCLLocationAccuracyHundredMeters causes location updates to be very infrequent


I am attempting to use location accuracy of kCLLocationAccuracyHundredMeters for my standard location updates in my application, which seem to work relatively well for a bit, but every once in a while I will receive a 10 minute gap between updates (while driving around multiple miles in different directions) which seems out of character for the setting. Here are the settings on my location manager. Also I am only using foreground location updates so for these tests I had the screen on the entire time and app always in foreground.

self.locManager = [[CLLocationManager alloc] init];
self.locManager.delegate = self;
self.locManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
self.locManager.distanceFilter = 15;

I tried out kCLLocationAccuracyBest with the same other settings and I get perfect measurements throughout my drive, but I don't need that accurate of a location. I assumed the hundred meter accuracy would still give relatively consistent updates with less accuracy, which is what we are looking for.

Is this just a side effect of working with the kCLLocationAccuracyHundredMeters setting vs kCLLocationAccuracyBest?

Tested on an iPhone 6s : 11.0.2 and iPhone 7Plus : 11.0.3

Any help is appreciated, thanks!

EDIT:

I should clarify I did setup logging in the CLLocationManager delegate methods listed below, but never received any callbacks / logs.

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
- (void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(nullable NSError *)error;
- (void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager;
- (void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager;

Solution

  • When you ask for kCLLocationAccuracyHundredMeters iPhone does not use GPS at all and relies on cell towers and wifi access points for triangulation. That means iPhone updates location with the frequency of wifi scans, which is far from continuous. If you are getting away from areas with wifi coverage, cell towers become your only source and you might start getting location updates only when switching between cell towers.

    To cut it short:

    • setting accuracy tells iOS which hardware to use,

    • distance filter tells iOS how far to move before waking up CPU with new data