Location Services Settings Not Deleted With App

I was working away on my iOS app today and I noticed a bug that only appeared to happen on my phone (the simulator was fine). What was happening was that when a MKMapView stopped tracking the user’s location the GPS was staying on. In fact I had to uninstall the app for it to switch off.

Now I was pretty sure that this had been working in the past but I’d just upgraded to iOS 5.1 so perhaps this was a bug? I quickly slapped together a test app with a map view that toggled tracking a user and the GPS switched off and on when expected.

My next idea was to start commented out big chunks of my apps code to see if this fixed things. It didn’t and I had got to the point where there was little different code left. Still the GPS stayed on…

As this problem only occurred on the phone I started to think that the phone was keeping some location services state around so I tried deleting and reinstalling the app, restarting the phone and various combinations of this and it still didn’t work. To further test my theory that the phone was keeping some location services state I renamed my app (bundle name to be precise) and voilà! it started working.

Now I wasn’t keen to have to rename my app to fix this problem so I did a little searching and found that you can reset all location services data from your phone via:

General -> Reset -> Reset Location Warnings

This fixed the problem, my app’s location services state must’ve got corrupted somehow (I still haven’t worked out how) and deleting/reinstalling the app wasn’t clearing it.

Of course this wipes the location settings for ALL apps so you’ll get a prompt to use location services the next time you open other apps, but it beats re-naming the app.