Update: iOS 6 deprecated the purpose property and it now has to be set in your Info.plist with the key NSLocationUsageDescription which is displayed in Xcode as Privacy – Location Usage Description. If you’re still supporting iOS 5 and earlier make sure you include both.
A great, but underused location feature on iOS is the purpose property of the CLLocationManager.
So many apps ask for your location – give your users confidence in sharing their location by telling them why you need it!
Example:
locationManager.purpose = @"We'll only use your location to show you local events nearby.";
You need to do this before you start the location monitoring, so:
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.purpose = @"We'll only use your location to show you local events nearby.";
locationManager.delegate = self;
[locationManager startUpdatingLocation];
Your users will now get a pleasant reason when you request their permission:
I’ve no idea why this is so rarely used, it’s been available since iOS 3.2.
Tip from the Apple docs:
You must set the value of this property prior to starting any location services. Because the string is ultimately displayed to the user, you should always load it from a localized strings file.
The reason? Far too many copy-pasters out there calling themselves “programmers”, that don’t touch the documentation unless they really have to.
I’m just starting a project using the Core Location for the first time and saw this ‘purpose’ property. Having never seen such a purpose given on any app’s consent dialog, I started a google search out of curiosity, how many references to it will be on the intertubes. Your blog entry happened be one of very few mentioning it.
Good job!