iOS: Show Users the Reason You Require Their Location

A great, but under­used loc­a­tion fea­ture on iOS is the pur­pose prop­erty of the CLLocationManager.

So many apps ask for your loc­a­tion — give your users con­fid­ence in shar­ing their loc­a­tion 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 loc­a­tion mon­it­or­ing, 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 pleas­ant reason when you request their per­mis­sion:
iOS iPhone Screen Location Prompt

I’ve no idea why this is so rarely used, it’s been avail­able since iOS 3.2.

Tip from the Apple docs:

You must set the value of this prop­erty prior to start­ing any loc­a­tion ser­vices. Because the string is ulti­mately dis­played to the user, you should always load it from a loc­al­ized strings file.

One Comment

  1. Posted 27/11/2011 at 1:19 pm | Permalink

    The reason? Far too many copy-pasters out there call­ing them­selves “pro­gram­mers”, that don’t touch the doc­u­ment­a­tion unless they really have to.

    I’m just start­ing a pro­ject using the Core Location for the first time and saw this ‘pur­pose’ prop­erty. Having never seen such a pur­pose given on any app’s con­sent dia­log, I star­ted a google search out of curi­os­ity, how many ref­er­ences to it will be on the inter­tubes. Your blog entry happened be one of very few men­tion­ing it.

    Good job!

Post a Comment

Your email is never shared.