Question

I want didEnterRegion to be called with much precision, but I wasn't able to do so. Here is what I have done: I used the best values of distanceFilter and desiredAccuracy (most precise GPS settings according to Apple) and have a destination CLCircularRegion (Subclass of CLRegion).

self.locationManager.distanceFilter = kCLLocationAccuracyBestForNavigation;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;

@property (nonatomic, strong) CLCircularRegion *Destination;
self.Destination = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(43.907691, -69.963158) radius:5 identifier:@"Destination"];

[self.locationManager startMonitoringForRegion:self.Destination];

The problem is when I am like 150m away from this destination, didEnterRegion gets called. Also around similar distance away didExitRegion gets called. I want didEnter and didExit region to be called when I am 5 m away, not 150m away, as I have specified with initiation of CLCircularRegion. Does anyone have a solution? Precision is what I need, and 150m instead of 5m is too inaccurate for me. Thanks ton -

(I used iPhone 4S to Test)

Was it helpful?

Solution

While in theory accuracies of 5m are possible with the current GPS+ technical gear, it may be that Apple prevents such accuracy for region monitoring for various reasons.

One is that they always want a good user experience and the 5m accuracy you want is within the accuracy range you will often get from the GPS readings. Thus leaving such a small region could also be on account of lower accuracy readings while the user is still within the region. Apple does cover up for such errors by setting thresholds for posting regionEnter or regionExit notifications. From Apple documentation:

When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.

The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters

Nevertheless since you can ask for high accuracy readings Apple should also take that into account. The alternative might be - as you commented - to use didUpdateLocation: and determine if inside or outside the region. That way you could include a test for location accuracy and only accept an exit/entry when horizontal accuracy is good enough.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top