I have an app with a location manager that runs with startUpdatingLocation. However, if it hasn't moved then i stopUpdatingLocation, mark the current location as a region and startMonitoringForRegion like so:
[locationManager stopUpdatingLocation];
CLRegion* region = [[CLRegion alloc] initCircularRegionWithCenter:self.currentLocation.coordinate radius:25 identifier:@"last_loc"];
[self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[region release];
When the app is completely shut down and I exit the region, locationManager:didExitRegion is called and I continue on my merry way like so:
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
[self.locationManager stopMonitoringForRegion:region];
[locationManager startUpdatingLocation];
}
However, if the app is running, either in the background or foreground, the app won't respond to locationManager:didExitRegion. What am I missing?
Be sure to initialize the coordinate property. If you want the coordinate to be the user's current location, use [your location manager].location.coordinate.latitude
and [your location manager].location.coordinate.longitude
as the initialization properties. If you require altitude, include [your location manager].location.altitude
, [your location manager].location.horizontalAccuracy
, [your location manager].location.verticalAccuracy
, and [your location manager].location.timeStamp
. Without this information, you create a region that has no coordinate, but still exists. Essentially, it has a name, but no real information.