I’m working on a simple app that has the following requirement: a task will be started at a given location and, after the user wanders a certain distance away, the task should be automatically ended.
I’m currently using CLLocationManager’s startUpdatingLocation to get the initial GPS location to within 100 meters accuracy. This works fine.
Then I use CLLocationManager’s startMonitoringSignificantLocationChanges to determine if the user has wandered far enough away. I use this method as it’s better on battery life, can run in the background, etc.
Now, the issue I am having is with the accuracy of the location returned when using startMonitoringSignificantLocationChanges. If I just let my phone sit on my desk, and wait 10-20 minutes, it will automatically end the task because of the accuracy (or lack thereof) of the position returned from startMonitoringSignificantLocationChanges. For instance:
2011-11-27 20:21:44.653 MyApp[2692:707] Location manager wants 100.000000 meter accuracy
2011-11-27 20:21:44.655 MyApp[2692:707] Location manager got 99.260482 meter accuracy
2011-11-27 20:27:52.975 MyApp[2692:707] visit location: lat 43.619912 long -70.237781
2011-11-27 20:27:52.977 MyApp[2692:707] current location: lat 43.619808 long -70.237561
2011-11-27 20:27:52.981 MyApp[2692:707] moved 21.155182 meters from visit origin
2011-11-27 20:37:53.205 MyApp[2692:707] visit location: lat 43.619912 long -70.237781
2011-11-27 20:37:53.207 MyApp[2692:707] current location: lat 43.628081 long -70.231727
2011-11-27 20:37:53.211 MyApp[2692:707] moved 1030.822457 meters from visit origin
The above all occurred without me moving the device an inch. My hunch is that startMonitoringSignificantLocationChanges is not accurate enough to accomplish this requirement. Is that the case? Or am I maybe overlooking something?
Any feedback would be appreciated. I didn’t post any code but it’s all pretty basic CLLocationManager stuff. Let me know if there’s more information or code snippets needed.
Thanks in advance!
From the
CLLocationManagerdocs:As such, it’s unlikely that
startMonitoringSignificantLocationChangescan be used to check for locations at the level of accuracy you’re looking for — it’s rare that a cell tower can localize you that well. You may want to try usingstartMonitoringForRegion:desiredAccuracy:instead; it also works in the background, and will do a lot of the dirty work of hit-testing the region for you.