Why is my iPhone app still showing the location services arrow?

I’m working on an app that tracks your location. Thanks to Apple and the new APIs in the iOS 4 SDK its actually pretty easy. You fiddle with some accuracy settings, set a delegate and BLAM, you start getting update callbacks with your current location. To get it to work in the background, all you need to do is put a key in your app’s plist.

The class that does the monitoring is CLLocationManager. CLLocationManager has 2 main ways to monitor your location. You can tell it to startUpdatingLocation and the more battery friendly startMonitoringSignificantLocationChanges. Me being the curious guy I am, I decide to give both a try. After not seeing results, and reading the documentation (significant changes means it happens when you change cell towers), I decided to go with the first option.

Things went great after that, my app development went along smoothly except for one thing. The arrow that tells you location services are enabled would NOT go away. The only way I could get it to go away was to disable location services for the app. How did I get rid of the arrow you ask? Here’s how.

Obviously, the first thing I did was head to Google. Unfortunately, all I could find were sites telling me how to turn off location services. My next idea was to head to StackOverflow. I spent some time searching and found this post, which led me to this.

Basically, the issue is that the location services calls to startMonitoringSignificantLocationChanges are registered across app installs, deletions, quits, and just about everything. The post says the solution is to delete the app and it’ll work. Hooray! I have my solution. Not so fast. This didn’t solve my problem.

Luckily, these posts gave me the information I needed to fix the problem myself. I figured I had a rogue monitorSignificantLocationChanges call hanging out somewhere. How do I get rid of it? Tell it to stop. So in one of my viewDidLoad methods, I took my location manager and told it to stopMonitoringSignificantLocationChanges. Goodbye arrow. I took the line out and now everything behaves just like it should.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

One Response to Why is my iPhone app still showing the location services arrow?

  1. Joe says:

    Thanks for the tip… I was running across the same problem. Your solution worked perfectly… no more “significant” location changes for me! :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>