Reputation: 407
I am trying to get precise region monitoring working with iOS5/iPhone 4G and I don't seem to be having much luck. To be clear, I AM able to get region enter events; it's just that I am getting them prematurely. Let me explain. This is my code for setting up a region:
#define GEO_FENCING_RADIUS 10 // in meters
CLLocationDistance radius = GEO_FENCING_RADIUS;
// Create the region and start monitoring it.
CLRegion* region = [[CLRegion alloc] initCircularRegionWithCenter:coordinate
radius:radius
identifier:identifier];
[self.locationManager startMonitoringForRegion:region
desiredAccuracy:kCLLocationAccuracyBest];
radius, in this code, is set to 10 meters. My assumption, then, is that I will only receive a region notification if I am within 10 meters of this location. Instead, I can get the notification at much higher distance values (I've seen a 2 mile proximity triggering the region). What would cause this? Also, I am using significantLocationChangeMonitoringAvailable with the defaults values set for CLLocationManager. Maybe using significantLocationChangeMonitoringAvailable is somehow precluding more accurate trigger events?
Any ideas what's happening here?
Upvotes: 4
Views: 1458
Reputation: 126167
The significant location change service is for significant location changes only. From the docs:
This method indicates whether the device is able to report updates based on significant location changes only. (Significant location change monitoring primarily involves detecting changes in the cell tower currently associated with the device.) This capability provides tremendous power savings for applications that want to track a user’s approximate location and do not need highly accurate position information.
Region monitoring works the same way, so it can only tell you when you're within about 1 km of a point of interest. (And note that since this is based on cell tower positioning, you'll get more or less accuracy depending on the density of cell towers in the area, and can only use this approach on devices with a cellular connection -- no iPod touch or WiFi iPad.)
If you want both the power benefits of region monitoring / significant change monitoring, and the ability to precisely track location within a region of interest, you'll need to set up for the former only, at first... then, once you're in/near a region of interest, switch to higher accuracy monitoring. (This might be best done with a separate instance of CLLocationManager
.)
Upvotes: 2