Rajashekar
Rajashekar

Reputation: 629

Can i use both NSLocationWhenInUseUsageDescription & NSLocationAlwaysUsageDescription?

One of the frameworks I used (Indoo.rs SDK,for bluetooth location detection) was developed to work with NSLocationWhenInUseUsageDescription in the plist file. I am also using Core Location manager which is configured to work with NSLocationAlwaysUsageDescription.

Can I use both in my .plist? I am not sure how to proceed with this when there are two types of hardware (bluetooth & GPS/WIFI/Celltowers) used for location services.

Upvotes: 7

Views: 6022

Answers (5)

AechoLiu
AechoLiu

Reputation: 18398

NSLocationAlwaysUsageDescription is deprecated.

Apple reference

enter image description here

Upvotes: 0

mvandillen
mvandillen

Reputation: 944

Having the two options both listed gives the user more control over its privacy. The user can decide to only allow locations when the app is open but deny background locations.

Upvotes: 0

JAHelia
JAHelia

Reputation: 7932

if you provide two options in your plist file, you will see 3 entries for location in app settings: Always, When In Use and Never, if you provide NSLocationAlwaysUsageDescription only in plist, you will see two entries in the settings: Always & Never and if you provide NSLocationWhenInUseUsageDescription only in plist, you will see two entries in the settings: When In Use & Never

Upvotes: 6

Nikos M.
Nikos M.

Reputation: 13783

Basically you can use only the NSLocationAlwaysUsageDescription in your .plist because if you ask for permission to use the user's location always, you can of course use it also while the app is in use.

These are just settings. Think of how your app is going to work and choose the appropriate permission. "Always permission" means that your app can update its location even if not running (which also drains battery much faster and leaves the location icon on the status bar on all the time and is far more common to get turned off by the user manually later). So choose what your app really needs.

Upvotes: 1

Paulw11
Paulw11

Reputation: 114875

It isn't to do with the hardware that you are using - it is to do with whether you want to use location servers only when your app is running in the foreground (when in use authorisation) or also when your app is in the background (always authorisation).

You should then request the appropriate level of access. "Always" authorisation includes "when in use" authorisation, so if you prompt the user for "always" authorisation then they won't be prompted if the framework requests "when in use" authorisation.

If, however, the framework requests "when in use" before your code requests "always" then the user will see two requests and you will need to set both keys - From a user experience point of view you should avoid this.

Upvotes: 3

Related Questions