43

In iOS 6, the purpose property of CLLocationManager, to describe the reason for using location services (@property(copy, nonatomic) NSString *purpose) has been deprecated.

What replacement, if any, is proposed by Apple?

Guillaume
  • 21,685
  • 6
  • 63
  • 95

2 Answers2

62

The replacement for the purpose property in iOS 6 is a new Info.plist key named NSLocationUsageDescription (aka "Privacy - Location Usage Description").

The key is documented in the Information Property List Key Reference but unfortunately it's not mentioned with the deprecation note of the purpose property.

However, the CLLocationManager.h does have this comment:

* Deprecated. Set the purpose string in Info.plist using key NSLocationUsageDescription.

In your code, you could set both the key and the purpose property (but you may want to check if the location manager responds to that selector first if/when that method is actually removed in the future).

If running under iOS 6, the location manager will use the key.
When running under less than iOS 6, the key will be ignored and the purpose property will be used.

  • 6
    How exactly can you localize this string then? Or do you then need a localized infoplist.strings just for this purpose? (no pun intended) – Bob de Graaf Sep 23 '13 at 15:18
  • @BobdeGraaf localized infoplist.strings sounds like the way to go from here: http://stackoverflow.com/a/14144989/159758 – DonnaLea May 30 '14 at 21:16
3

I just had the same issue in my App.

I found that you can now set the Activity of the CLLocationManager! You can choose different CLActivityTypes, so you don't need to write your own purpose anymore.

Here's for example for a Navigation based App

[self.gps setActivityType:CLActivityTypeAutomotiveNavigation];

Other possible CLActivityTypes are:

 - CLActivityTypeFitness
 - CLActivityTypeOther
 - CLActivityTypeOtherNavigation
Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70
Ralph Marschall
  • 139
  • 2
  • 7
  • Does it change what is displayed to the user? And I'd like to be more specific (like it was possible before with "purpose"), instead of just using TypeOther. Waiting for a replacement, I'll continue using the deprecated method. – Guillaume Sep 25 '12 at 11:21
  • Well the message displayed to the user is kind of a default message: " 'AppName' wants to use your current location. " I don't understand why apple changed this, I'm sure that users would like to know the details... – Ralph Marschall Sep 25 '12 at 11:41
  • Don't forget that deprecated officially means soon to be abandoned, but the definition of soon can vary. – Guillaume Sep 25 '12 at 12:19
  • It is used to detect periods of non-motion and power down the radio to save power. It is not displayed to the user. – tooluser Feb 11 '14 at 17:49