Reputation: 392
I am migrating an existing app to work with iOS 9, there was not much to change but adding ATS to the info.plist
and use MKAnnotationView
instead of MKPinAnnotationView
for custom pins on the map. The problem was when starting to test the changes, I noticed the location updates were too frequent, even when I'm standing still. Nothing has been changed in the way the location manager is initialized.
Here is a small sample of the log.
2015-09-25 12:16:25.462 MyApp[2009:911066] location: <+39.09040164,-77.52540765> +/- 65.00m (speed -1.00 mps / course -1.00) @ 9/25/15, 12:16:25 PM Eastern Daylight Time
2015-09-25 12:16:25.464 MyApp[2009:911066] location: <+39.09040164,-77.52540765> +/- 65.00m (speed -1.00 mps / course -1.00) @ 9/25/15, 12:16:25 PM Eastern Daylight Time
2015-09-25 12:16:25.468 MyApp[2009:911066] location: <+39.09040164,-77.52540765> +/- 65.00m (speed -1.00 mps / course -1.00) @ 9/25/15, 12:16:25 PM Eastern Daylight Time
2015-09-25 12:16:25.475 MyApp[2009:911066] location: <+39.09040164,-77.52540765> +/- 65.00m (speed -1.00 mps / course -1.00) @ 9/25/15, 12:16:25 PM Eastern Daylight Time
The location manager is set like this
locationManager = [CLLocationManager new];
locationManager.delegate = self;
locationManager.distanceFilter = 25.0f;
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[locationManager requestAlwaysAuthorization];
}
[locationManager startUpdatingLocation];
I guess the question is: is there something wrong with my implementation or was there a change in the Core Location API that is ignoring the distance filter?
Upvotes: 3
Views: 1426
Reputation: 392
In the locationManager:didUpdateLocations:
method the distanceFilter
property of CLLocationManager
was was being reset depending on the speed, in iOS 9
this seems to trigger a new location update (returning the last known location), thus resulting on hundreds of new location updates in a few seconds.
Upvotes: 2