I have an App with Region Monitoring but for better presition I call to "startUpdatingLocation" for use the GPS when the user enter into the Region specified:
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[manager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
locationManager =manager;
CLLocation *location1 = locationManager.location;
CLLocation *location2 = [[CLLocation alloc] initWithLatitude:obj.latitude longitude:obj.longitude];
float betweenDistance=[location1 distanceFromLocation:location2];
if((betweenDistance/1000)<=0.350000){
// Fires an UIAlert
}
}
That works fine in the most of cases, for example if the user is outside the region and then press the "Home Button" and after enter into the region fires the function "didEnterRegion" and the GPS starts to work for a few minutes and show the Alert, thats the right way.
But if the App is open and then the user enter in the region fires the function "didEnterRegion" and the GPS starts, but if the user press the "Home Button" in that moment the GPS stops and the Alert never appear.
I don't want to activate the option of "Required Background modes" in the info.plist because I only want to use GPS for a few minutes after the user press de Home Button, and not for to use in a excesive mode.
Any ideas?