I am using an iPhone5s with IOS 7.1 for testing. I use the locationManagerDidPauseLocationUpdates delegate to call a method to set up the geofence.
- (void) monitorForDepartureFromLastKnownStoppedLocation:(Locations *)lastKnownLocation
{
CLLocationCoordinate2D lastLocation = CLLocationCoordinate2DMake(lastKnownLocation.latitude, lastKnownLocation.longitude);
CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:lastLocation
radius:300
identifier:@"departure from last stopped location"];
region.notifyOnEntry = NO;
region.notifyOnExit = YES;
[monitorSignificantChangeObject.locationManager startMonitoringForRegion:region];
}
This then calls the - (void) locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
delegate method when the user exits the region.
Everything works in the following scenarios.
- app in foreground.
- app in background.
- screen locked with app in background or foreground.
It does't work correctly in the following scenario:
The geofence has been exited (ie didExitregion should fire) and the screen is locked AND the screen is turned off (ie screen is black, this happens a couple of seconds after screen locks) in this scenario the didExitRegion does not fire at all. However as soon as I press the home button the screen comes on (still locked) the didexitRegion immediately triggers.
Is this normal behaviour or am I missing something ?