This region monitor has really bad accuracy. Anyone can solve this problem? My Source Code's repository is here: https://github.com/robert-yi-jones/RegionTrigger
I have created a CLLocationCoordinate2D variable which is centre of map. Then, I set up a region by 100 meters radius based on the coordinate.
CLLocationCoordinate2D *targetPoint =
[[CLLocation alloc] initWithLatitude:MapView.centerCoordinate.latitude
longitude:MapView.centerCoordinate.longitude];
targetRegion = [[CLCircularRegion alloc] initWithCenter:targetPoint.coordinate
radius:300
identifier:@"My Circle Region"];
[locationManager startMonitoringForRegion:targetRegion];
However, it looks like the region I start monitor is not working well.
/*
* locationManager:didEnterRegion:
*
* Discussion:
* Invoked when the user enters a monitored region. This callback will be invoked for every allocated
* CLLocationManager instance with a non-nil delegate that implements this method.
*/
- (void)locationManager:(CLLocationManager *)manager
didEnterRegion:(CLRegion *)region{
if ([region.identifier isEqualToString:@"My Circle Region"]) {
[self showAlertWithTitle:@"Entering a Region"
Message:region.identifier];
}
}
/*
* locationManager:didExitRegion:
*
* Discussion:
* Invoked when the user exits a monitored region. This callback will be invoked for every allocated
* CLLocationManager instance with a non-nil delegate that implements this method.
*/
- (void)locationManager:(CLLocationManager *)manager
didExitRegion:(CLRegion *)region{
if ([region.identifier isEqualToString:@"My Circle Region"]) {
[self showAlertWithTitle:@"Exiting a Region"
Message:region.identifier];
}
}
It notices me only when coordinate switching to some place around 6 KM away from my setup region.
Does anyone has region monitor sample code? I really can't find my bug!
My experience is that this is normal behavior. I've been using region monitoring for about 2.5 years now and since iOS 6, the
-didExitRegion
delegate takes much longer to trigger than the-didEnterRegion
. I also had this behavior confirmed by an Apple Engineer during WWDC 2013. It doesn't sound as if they plan to improve the accuracy, rather delay, in the exit events. According to the engineer, the OS takes a lot longer to decipher that you've left because it has to completely get out of range of known Wifi networks and to new cell towers. It is much easier to determine you've arrived than it is to determine you've left.If it is only taking 300M or so to trigger your geofence (outside the 300M radius), I'd say you are probably within the operating limits of the geofence. If you need precision better than that for exiting, then you will likely have to invoke the GPS chip and all the work that goes along with that. Hope this information helps.