Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 824
Rajashekar Avatar asked Mar 17 '15 06:03

Rajashekar


People also ask

What is NSLocationWhenInUseUsageDescription?

NSLocationWhenInUseUsageDescription. A message that tells the user why the app is requesting access to the user's location information while the app is running in the foreground.


3 Answers

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

like image 111
JAHelia Avatar answered Sep 29 '22 21:09

JAHelia


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.

like image 32
Paulw11 Avatar answered Sep 29 '22 21:09

Paulw11


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.

like image 36
Nikos M. Avatar answered Sep 29 '22 19:09

Nikos M.