According to apple docs, significant location change should update location at least every 15min. I am indeed receiving updates when I move significantly, but not when the device is stationary. What is your experience with updates? Do they come at least every 15min?
If GPS-level accuracy isn’t critical for your app and you don’t need
continuous tracking, you can use the significant-change location
service. It’s crucial that you use the significant-change location
service correctly, because it wakes the system and your app at least
every 15 minutes, even if no location changes have occurred, and it
runs continuously until you stop it.
Well, I have a naive solution. You can use a NSTimer to force the CLLocationManger instance to update the current location every 15 minutes or whatever the time you want it to be periodically updated.
Here's the code I would use:
First, call this method to start update your location whenever you need in your viewDidLoad or else where.
- (void)startStandardUpdates
{
if (nil == locationManager){
locationManager = [[CLLocationManager alloc] init];
}
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// 900 seconds is equal to 15 minutes
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:900 target:self selector:@selector(updateUserLocation) userInfo:nil repeats:YES];
[timer fire];
}
Second, implement the updateUserLocation method:
-(void)updateUserLocation{
[self.locationManager startUpdatingLocation];
}
Last, confirm to the protocol, then implement the location did update method. We read the latest updated result and let the location manager to stop updating current location until next 15 minutes.:
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
CLLocation *userLocation = [locations objectAtIndex:0];
CLLocationCoordinate2D userLocationCoordinate = userLocation.coordinate;
/*
Do whatever you want to update by using the updated userLocationCoordinate.
*/
[manager stopUpdatingLocation];
}