4

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?

salil
  • 407
  • 3
  • 14

1 Answers1

2

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.)

rickster
  • 124,678
  • 26
  • 272
  • 326
  • Is there any advantage of using region monitoring over significant location change in terms if accuracy? – user836026 May 11 '12 at 17:20
  • 1
    They're about the same in terms of accuracy, but they serve different purposes. Say your app wants to know when the user leaves home and arrives at work after a 20 km commute... Using region monitoring, you'll get notified once when the user gets about 1 km away from home, and once again when the user gets within about 1 km of work. Using significant location changes, you'll get 10-20 notifications along the way, every time the user moves by about 1 km (and since you don't need those notifications in this example, all you're doing is wasting battery). – rickster May 11 '12 at 18:00
  • 1
    (Also worth noting: both services are based on the cell tower currently associated with the device, so you may see better than 1 km accuracy in densely populated areas and worse in sparsely populated areas: 1 km is just the general guideline Apple says you can expect on average.) – rickster May 11 '12 at 18:01
  • As a data point, I seem to be changing cell towers every mile here in SOMA, SF. – salil May 17 '12 at 23:45
  • I would like to add that with the recent improvements, Region Monitoring can now inform you with 5-10 meters accuracy. – fatih Sep 08 '12 at 02:39
  • say, @fatih, do you get that accuracy when your app is in the background/has the screen off? and can I ask which of the standard/significant change services you use? thanks for the update! – ari gold Sep 16 '12 at 02:30