Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pausesLocationUpdatesAutomatically in iOS 6 is not working as expected

I want to achieve a functionality in which I use the GPS for the loaction updates and when the user is not moving, I want the GPS updates to be paused. AS per the "Staying on track with Location services " video, I did this:

 //Configure Location Manager
 self.theLocationManager = [[CLLocationManager alloc]init];
[self.theLocationManager setDelegate:self];
[self.theLocationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[self.theLocationManager setActivityType:CLActivityTypeFitness];

 NSLog(@"Activity Type Set: CLActivityTypeFitness");

[self.theLocationManager setPausesLocationUpdatesAutomatically:YES];
[self.theLocationManager startUpdatingLocation];

Delegates:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateLocations:(NSArray *)locations
{
    NSLog(@"Started location Updates");
}


- (void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager
{
    NSLog(@"Pausing location Updates");
}

- (void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager
{
    NSLog(@"Resuming location Updates");

    UIAlertView *pop = [[UIAlertView alloc]initWithTitle:@"Info" message:@"Location    Updates resumed" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [pop show];
    [pop release];
}

I did not get the desired behavior and the delegates "didPause.." and "didResume..." were not even called when the device was Idle.

Ideally GPS updates must stop and resume depending on the state of the device and CLActivityType but its not the case here.

Can anyone help me, what am I doing wrong?

Thanks in advance.

like image 787
Rohit Kashyap Avatar asked Nov 03 '22 10:11

Rohit Kashyap


1 Answers

The pause should occur if you let the device at a same location for about 15 minutes.

like image 200
Laurent Avatar answered Dec 09 '22 12:12

Laurent