I am developing a iPhone app running on iOS5, and am unable to set up geofences when I call the startMonitoringForRegion:desiredAccuracy:
method on click of a button.
It works fine in the simulator when I print out the regions in monitoredRegions
, but when running on an actual iPhone 4, the monitoredRegions
is always empty. Expectedly, the didEnterRegion:
and didExitRegion:
methods are not called as well.
Another puzzling fact is that on BOTH the simulator and the iPhone 4 device, the CLLocationManagerDelegate method didStartMonitoringForRegion:
is never called as well.
Would appreciate some help here, thank you!
EDIT: this is method that I call on click of a button:
-(void) queueGeofence: (CLLocationCoordinate2D)selectedBranch userCoordinate:(CLLocationCoordinate2D)userCoordinate radius: (CLLocationDegrees)radius {
geofence = [[CLRegion alloc] initCircularRegionWithCenter:selectedBranch radius:radius identifier:@"geofence"];
CLLocationAccuracy acc = kCLLocationAccuracyNearestTenMeters;
[locationManager startMonitoringForRegion:geofence desiredAccuracy:acc];
[CLLocationManager regionMonitoringEnabled];
NSLog([CLLocationManager regionMonitoringEnabled] ? @"regionMonitoringEnabled:Yes" : @"regionMonitoringEnabled:No");
NSLog([CLLocationManager regionMonitoringAvailable] ? @"regionMonitoringAvailable:Yes" : @"regionMonitoringAvailable:No");
NSLog(@"LOCATIONMANAGER monitored regions: %@", [locationManager monitoredRegions]});
}
Region monitoring is both enabled and available, but monitoredRegions
is still giving me back nothing.