Can i use both NSLocationWhenInUseUsageDescription & NSLocationAlwaysUsageDescription? - ios

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.

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

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.

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.

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.

NSLocationAlwaysUsageDescription is deprecated.
Apple reference

Related

Google Maps asking for NSLocationWhenInUseUsageDescription

I have an iOS app that uses the Google maps library which I have added via CocoaPods. This app fetches user location even in background so it asks the user for NSLocationAlwaysUsageDescription.
But upon running the app from Xcode, I get the correct permission alert but I also get the following error message in the console.
This app has attempted to access privacy-sensitive data without a
usage description. The app's Info.plist must contain an
NSLocationWhenInUseUsageDescription key with a string value explaining
to the user how the app uses this data
Doesn't NSLocationAlwaysUsageDescription automatically allow when in usage as well? Because I don't want the When In Use option to be available in the Settings because if the user later changes to that, it will cause the app to behave not as intended.
You have to add a key value pair of NSLocationAlwaysUsageDescription as key and value is like you have to notify user , or something else that user can understand that this app is going to use gps location.
You can try this or add this in your plist
Privacy - Location Always Usage Description as key and
Application would like to use your location. By allowing background locations, we can notify you when a customer is requesting for service. Continued use of GPS running in the background can dramatically decrease battery life as value

Something wrong with my iOS app's location service declaration

A few days ago when I uploaded a new version of my app to the App Store using Xcode, I received the following e-mail from iTunes Connect:
Subject: iTunes Connect: Your app AppName has one or more issues
Dear developer,
We have discovered one or more issues with your recent delivery for
"AppName".
The following are for your information only and do not require any
action:
We have detected that this build requires the use of standard location
services when running in the background. Apps requiring location
services will now display the following text disclaimer on the App
Store. 'This app may use your location even when it isn’t open, which
can decrease device battery life'.
Regards,
The App Store team
And the build that I uploaded cannot be selected for review submission on the iTunes Connect website.
How should I deal with this problem? Thanks.
I run into this issue long time ago, this is because, if your app is still use location service in the background, it maybe consume the battery.
1) If you want to always use the location service, you should set this, can let you pass the itunes verify:
you should in your Info.plist add NSLocationAlwaysUsageDescription permission, and set the value, why you want to always use the location service.
2) If you just need when user using app this duration to use location service. You should NSLocationWhenInUseUsageDescription instead of NSLocationAlwaysUsageDescription permission, and you should also set the description why you want to use the permission.
Apple guidelines *
If your app requires location usage even in the background mode, In bottom of the app description and iTunesConnect application page you have to put this text
"This app may use your location even when it isn’t open, which can decrease device battery life"
It is important to put this disclaimer so that if user downloads your application he should be aware that location services will be active for the app even when the application is not in the use.
You don't have to put another build, just update the description with this disclaimer and submit for review again. It will get re-reviewed and, if all terms and conditions are valid, it will be approved.
Since Apple services for new application upload is not active from 23rd Dec to 27th Dec due to yearly Christmas holiday, so you should try to submit for review after it.
Let me know if you have any issues.
While going through the same issue, I found that
Capabilities -> Background Modes -> Location updates
were enabled for my app.
Please deselect this, if your app does not require location updates in background.
This is not a big problem actually. Apple reviewer already said you "do not require any action" he / she only suggest you it is more appropriate show a warning text (it is appear when you request to use location service within UIAlertView) like this message 'This app may use your location even when it isn’t open, which can decrease device battery life'.
You can add descriptive string in .plist file.
Probably you forgot to add NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in plist or you didn't add background mode in capabilities of the project.
The problem is with your string message you are displaying. i was also once stucked in this kind of issue i was using app name like "Burn you phone". So by changing the message string on location authorization will do the trick.
I had the same problem and contacted iTunes Connect about it. Below are excerpts from their responses so far:
I do understand your concerns about continuing to receive notices with
every update or build. I can confirm this is working as expected.
...
There are some emails that are system-generated by iTunes Connect and
there is not a way to disable them at this time. If you provide us
feedback we will be more than glad to provide it to the appropriate
team for future improvements.
...
You can definitely try adding the app description and see if this will
resolve the email notifications.
However, we can not assure you that this will cancel the email
notifications.
Just wanted to demonstrate their stellar customer support and exemplary knowledge of their own product...
However, I haven't yet confirmed whether putting the text in the description field will silence the email.
The other responses here mention the privacy usage descriptions in Info.plist, but this email is not directly related to this issue. Anyways, if you neglect to include those, your app will just crash when you try to access location services (unless permission had already been given in a pre-iOS 10 version of your app).

Overriding iOS Settings UI - Apple rules

As in many apps, also in my app I have a "Settings" view.
I would like to add an item composed by text + UISwitch in order to give user possibility to change the "location services" permissions: when switch is enabled "allow location services: always", when is disabled "allow location services: never".
Question is: could this a reason for an Apple App Rejection?
I read all guidelines but I can't find an answer to my question.
Links
Review rejections.
Review guidelines.
UI Tips.
Regardless of app store review, what you're thinking of doing isn't technically possible. Your app can only request location permissions, it can't then tell the system that it doesn't need them any more.
For the user to amend location permissions they have to open the iOS settings app and go to the page for your app. You can provide a link from within your app to do this, using the UIApplicationOpenSettingsURLString constant to build and open a URL.
I don't know your code so I'll try to help you writing a few lines to follow to understand Apple reject.
So the first thing you need to do is to add one or both of the following keys to your Info.plist file:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Next you need to request authorization for the corresponding location method, WhenInUse or Background. Use one of these calls:
requestWhenInUseAuthorization
requestAlwaysAuthorization
Location types that you need Always authorization to use:
Significant Location Change
Boundary Crossing (Geofences)
Background Location Updates (e.g. Fitness, Navigation apps) iBeacons
Visited Locations (iOS 8+)
Deferred Location Updates

show custom view for iOS location permission dialog

I am new to iOS. Is it possible to show a custom view or dialog in place of the default iOS location permission dialog?
No, this dialog is presented by the operating system and you cannot modify it. It is an important part of privacy management that the dialog is presented in a consistent way for all apps and that apps cannot modify the permission process.
You can display a custom view or alert prior to requesting permissions that explains what is happening and the need to click "allow" on the alert that is about to be presented
Direct Answer is it's not possible
explanation :
Only option is set description string by using Cocoa Keys(The keys associated with the Cocoa touch environments)
Add one of these key to
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Info.plist and set it's value to whatever which describe the purpose of getting location
ex:
MyApp picks you up from where you are. To book airport rides, choose “Allow” so the app can find your location.
Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s location information, must statically declare the intent to do so. Include the NSLocationAlwaysUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s location information without a corresponding purpose string, your app exits.
If you looking for localization for that message
Link

Customize default current location alert message (iOS)

Is it possible to customize the default alert message when the iPhone wants to use users current location. I want to change not only the text but also the default blue screen alert view. Is it possible ?
Thanks.
Not possible. From documentation,
Important: In addition to hardware not being available, the user has
the option of denying an application’s access to location service
data. During its initial uses by an application, the Core Location
framework prompts the user to confirm that using the location service
is acceptable. If the user denies the request, the CLLocationManager
object reports an appropriate error to its delegate during future
requests. You can also check the application’s explicit authorization
status using the authorizationStatus method.
The alert is prompted by Core location framework. We don't have any control over it.
EDIT : To add up, from this Apple developer forum thread (login required)
That alert is shown in a standard fashion for all applications for
privacy reasons. The user's current location is sensitive
information, and we want to be sure that they give their informed
consent to any use of it on the device. The way that we do that is by
providing a clear, consistent mechanism for the user to give their
consent. If applications were allowed to override or disable the
alert, then that consistency would be lost.
and the answerer is an Apple employee..
Years later, Apple did implement some customization options!
Have a look at the documentation
documentation
If you put one of the following key in your info.plist (depending on your usage of the location services), you can specify a custom string, that is displayed in the default alert additionally.
NSLocationUsageDescription (available since iOS6)
NSLocationWhenInUseUsageDescription (since iOS8)
NSLocationAlwaysUsageDescription (since iOS8)

Resources