NSLocationWhenInUseUsageDescription inside library Info.plist - ios

I've built a Swift library that uses CoreLocation for fetching user location when the app is in use. If I want to integrate my library inside an app, I only need to import the library, instantiate my class and start the method that gets user location...
...And I also need to add NSLocationWhenInUseUsageDescription inside the app Info.plist!
I was wondering if it is possible to add the NSLocationWhenInUseUsageDescription inside the library Info.plist to let the programmer choose if implement a custom description or leave the default library description.
P.S. I've already added the NSLocationWhenInUseUsageDescription inside the library Info.plist, but Xcode is not happy if I decide not to add it also in the app Info.plist:
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
Thanks a lot in advance!

No, this is not possible.
You will need to instruct the library user that they need to add the location usage key to their app's info.plist.
They will need to add a description that is appropriate for their app's usage of location

Related

Xamarin iOS project Info.plist issues during submission on App Store

I am developing project which use the following permissions in Info.plist: NSCameraUsageDescription,
NSPhotoLibraryUsageDescription, NSMicrophoneUsageDescription, NSPhotoLibraryAddUsageDescription, NSCalendarsUsageDescription. App can browse photos library or take a picture. After the deployment process for submission on App Store I get the info:
The app's Info.plist file should contain a NSLocationAlwaysUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data.
The app's Info.plist file should contain a NSLocationWhenInUseUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data.
In my app I don't use or ask user for location permission. Moreover I use the NuGet packages: Xamarin.Essentials, Forms, Plugin.Permissions. How can I workaround this issue with location permissions to avoid placing this ?
There is nothing that you can do to workaround the problem aside from removing plugins.
And there are no reasons to do something like that as the end-user won't see any difference unless you ask for the location in the app's code. Info.plist is not visible to the end user in any way including through the app listing.

Error Appstore connect : Missing Purpose String in Info.plist File

I've submitted my app for review to the App Store Connect. Although the app is still under review, I've received an email to inform me that I have to fix an error. Here is the content of the message:
Dear Developer,
We identified one or more issues with a recent delivery for your app
XXXXX. Your delivery was successful, but you may wish to correct the
following issues in your next delivery:
"Missing Purpose String in Info.plist File. Your app's code
references one or more APIs that access sensitive user data. The
app's Info.plist file should contain a
NSLocationAlwaysUsageDescription key with a user-facing purpose
string explaining clearly and completely why your app needs the data.
Starting spring 2019, all apps submitted to the App Store that access
user data will be required to include a purpose string.If you're
using external libraries or SDKs, they may reference APIs that
require a purpose string. While your app might not use these APIs, a
purpose string is still required. You can contact the developer of
the library or SDK and request they release a version of their code
that doesn't contain the APIs.
After you’ve corrected the issues, you can use Xcode or Application
Loader to upload a new binary to iTunes Connect.
Best regards,
The App Store Team
My app is fully built with Expo and I don't know how to access and modify the Info.plist.
Any idea?
EDIT April 2019 : You now have to add these two keys, as spring 2019 has begun. Note that NSLocationAlwaysUsageDescription is now deprecated (since iOS 11) and has been replaced with NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription. If you want to support lower than iOS 11, you'll have to use the three values.
To sum up you have to:
Add NSLocationAlwaysAndWhenInUseUsageDescription AND NSLocationWhenInUseUsageDescription for iOS 11 and more
And add NSLocationAlwaysUsageDescription if you want to support iOS 10 and less
And finally, you can add NSLocationUsageDescription if you wan to support iOS 8 and less.
You can submit your app even if you got this message !
I’ve just faced the same issue yesterday, even if the app isn’t using the location functionality. It may be related to some framework included in the project that have this optional feature.
I can confirm that my app has been approved even without the NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription key in info.plist
Indeed, as Apple stated in the mail :
Starting spring 2019, all apps submitted to the App Store
that access user data will be required to include a purpose
string.
So the only thing to do is to add this key (right now is better, so that you won’t forget) in you project so that it will be included in your next update.
Just add two new entries in your info.plist, with NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription as keys and a short description of why you use them as the value (even if you don’t really use them...).
If you're using Expo, you can add solve by adding infoPlist to app.json like so:
"expo": {
"ios": {
"bundleIdentifier": "com.app.myapp",
"infoPlist": {
"NSLocationAlwaysUsageDescription": "Some message to appease Apple.",
},
},
}
Expo Docs
I have some apps in the store and I tried to distribute a version for QA and the same thing happened in two different Apps.
I think this is a new criteria to accept the builds uploads to Appstore connect.
The solution is simple, add the following lines in the .plist file.
<key>NSLocationAlwaysUsageDescription</key>
<string>custom message</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>custom message</string>
PS: In my case have not using any feature of location, but I added these lines in order to comply with Appstore connect guidelines. Btw after receive that email, I could test the app even when they said that build it had some issues.
I hope this work for you guys.
It's a new requirement from apple, even if you do not use location. If you want to add the permissions in Xcode, look for "Privacy - Location Usage Description" and "Privacy - Location When In Use Usage Description" and type a custom string for each of them.
For more simplifying you can add these lines in your info.plist. These error are coming because Starting spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.
Open info.plist as source code.
Add these following lines in your plist
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) needs Location access for "some reason"!</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) needs Location access for "some reason"!</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) needs Location access for "some reason"!</string>
##Use this key in info.plist file
NSLocationAlwaysUsageDescription
Your location is required for xyz benefits for you NSLocationWhenInUseUsageDescription
Your location is required for xyz benefits for you
"Missing Purpose String in Info.plist File. Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSLocationAlwaysUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs.
Open Info.plist as source code.
Add these following lines in your plist
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) needs Location access for "some reason"!</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) needs Location access for "some reason"!</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) needs Location access for "some reason"!</string>
We did receive the same email and we aren't using the CoreLocation at all. After a quick search, we found that Parse SDK could use CoreLocation. In Apple's email, they clearly say:
If you're using external libraries or SDKs, they may reference APIs that require a purpose string.
That mean the minute your code or any other Library or SDKs can use CoreLocation, even if you don't use it, you need to provide privacy description for "When In Use" and "Always Use".
It is also something new from Apple and for now it's only a warning but it will be required starting in Spring 2019 for new submissions.
There are the following cases:
NSLocationAlwaysAndWhenInUseUsageDescription (iOS>11)
NSLocationWhenInUseUsageDescription (iOS>11)
NSLocationAlwaysUsageDescription (iOS<=10)
NSLocationUsageDescription (seems very old, iOS8?)
Apple states at:
Add the NSLocationWhenInUseUsageDescription key and the NSLocationAlwaysAndWhenInUseUsageDescription key to your Info.plist file.
and:
If your app supports iOS 10 and earlier, add the NSLocationAlwaysUsage
NSLocationUsageDescription seems dead, the only ref in ADC site is:
https://developer.apple.com/ibeacon/Getting-Started-with-iBeacon.pdf
So to be sure, use first 3.
This issue is occurring because you haven't included
<NSLocationAlwaysUsageDescription>
for your app. I faced the same issue when I tried to submit my app on the AppStore. After the app was processed, I got the same mail. I just added the description and now its resolved.
Hope this helps.
These answers all tell you how to comply with the App Store rules to avoid the warning but the true fix would be for Expo to allow you to disable their SDKs requirement for Location Services unless you actually use them - I'm not sure if this is possible.
Please review the email you received from **App Store Connect **
Identify The Missing Key
Instructions
Open info.plist file.
Add and search for the missing key from the options provided (e.g. Contacts = Privacy - Contacts Usage Description)
Add Usage Description:
$(PRODUCT_NAME) needs Contacts access to "Provide The Reason Here".
Example:
same issue in Feb 19, got an email with a bunch of permissions I am not using, I assume they are from plugins. Apple says in March 19 it is a requirement so I am adding these in info.plst and uploading again.
It is very silly indeed.
I had
<key>NSLocationWhenInUseUsageDescription </key>
instead of
<key>NSLocationWhenInUseUsageDescription</key>
be sure to remove trailing whitespace
I also face the same issue but after 27 hours, I received the email about approved even I did nothing. So wait for approximately 24 hours instead of doing all this process again.
With Xcode 11 copy the key NSLocationAlwaysUsageDescription and add this to Info -> Custom iOS Target Properties -> Click + in the bottom left of this tab and as a value insert some kind of description like This app requires location access to function properly..
My app also got that, and I do nothing about it but it can run well ,next time I think should add such key in plist,just do some description
A short answer to the above problem -
NSLocationAlwaysUsageDescription must be updated with the following description in Info.plist file
{Your App Name} requires access to the location to suggest dengue
outbreak zones.
In our case, we were using NSLocationWhenInUseUsageDescription in our app, but not NSLocationAlwaysUsageDescription.
Reading from the comments here (thanks matt-oakes), it looks like NSLocationAlwaysUsageDescription is being used by one of the dependency frameworks we use.
Running our app it doesn't show the actual NSLocationAlwaysUsageDescription permission modal, so it looks to just handle this in the background.
So in summary, adding NSLocationAlwaysUsageDescription to the Info.plist fixed the warning email, and did not change any behaviour in the app 👍🏻

Is it mandatory to add NSPhotoLibraryUsageDescription in info.plist?

I am not using UIImagePicker in my app and not accessing the Photo Library. I got a mail regarding add NSPhotoLibraryUsageDescription in info.plist file.
I have following questions
How to confirm my project accessing the photo library?
I already searched UIImagePicker in my project and did't get any result.
Is it mandatory to add NSPhotoLibraryUsageDescription in info.plist while i am not accessing the photo library?
Can any one help to find it out .
Thanks
UIImagePicker
An image picker controller manages user interactions and delivers the results of those interactions to a delegate object. The role and appearance of an image picker controller depend on the source type you assign to it before you present it.
whenever you used UIImagePicker, you have to give permission for that particular application
There is a list of all Cocoa Keys that you can specify in your Info.plist file:
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html
(Xcode target -> Info -> Custom iOS Target Properties)
iOS already required permissions to access microphone, camera, and media library earlier (iOS6, iOS7), but since iOS10 the apps will crash if you don't provide the description why you are asking for the permission.
UPDATE:
Summary of all privacy keys (with example description):
Useful Link
You only have to add this key-value pair to your info.plist if you are actually accessing the photos any way. If it's not added the app is going to crash.
Check if any of your added dependencies using UIImagePicker.
No it's not mandatory to add NSPhotoLibraryUsageDescription key in info.plist. If your App is not using accessing photo from library/gallery then you should remove it. But as "#Bence Pattogato" said if Your app accessing photo from library/gallery and there is no key added in info.plist then it will be crash.
For your information below are different keys that required to add info.plist if you accessing relevant features according to camera/photo library.
1) NSPhotoLibraryUsageDescription : This key lets you describe the reason your app accesses the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.
2) NSCameraUsageDescription : describes the reason that the app (including an iMessage app) accesses the device’s camera. When the system prompts the user to allow access, this string is displayed as part of the alert.
3) NSPhotoLibraryAddUsageDescription : (New in iOS 11) This key lets you describe the reason your app seeks write-only access to the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.
Above information get from this Appel official link.

App crashes with __CRASHING_DUE_TO_PRIVACY_VIOLATION__ when trying to access contacts

Upon updating to iOS 10, when trying to access the contacts through plugin cordova-plugin-contacts v2.2.0, the app exits with
__CRASHING_DUE_TO_PRIVACY_VIOLATION__
I don't know what other extra info i can provide right now, just let me know if i can be more specific. Thanx.
Maybe this is of some use: https://stackoverflow.com/a/39416858/592641, but i couldn't find a guide of how to specify those usage descriptions in cordova.
After creating an Xcode project and finding the Info.Plist file, you may try adding NSContactsUsageDescription key, which should accept a string value.
A complete list of Cocoa Keys
Hope that helps!
EDIT
A part from the doc: (which can help you understand why it is crashing)
Important: To protect user privacy, an iOS app linked on or after iOS
10.0, and which accesses the user’s contacts, must statically declare the intent to do so. Include the NSContactsUsageDescription 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 contacts without a
corresponding purpose string, your app exits.
My app was missing NSFaceIDUsageDescription key
In short, the usage descriptions need to be specified inside *info.plist
That's no good for Cordova codebase since .plist files are not part of the repository. The simplest way I found to put them inside config.xml is this:
Install cordova-custom-config
Add the following inside config.xml:
.
<platform name="ios">
<config-file parent="NSContactsUsageDescription" target="*info.plist">
<string>Easily invite your friends</string>
</config-file>
</platform>
My Info.plist was missing NSPhotoLibraryAddUsageDescription. There are now TWO permissions associated with the photo library (starting iOS 11):
NSPhotoLibraryUsageDescription - to access the photo library
NSPhotoLibraryAddUsageDescription - write only permission to photo library
I had the first permission prior to iOS 11 when it was the only key needed to use the photo library. Apparently in iOS 11 they added the second and made it required to add photos to the library. So if you support iOS 10 but don't include the second key, you will crash on iOS 11.
All Keys are Here
For me, I was trying to request access to the microphone, but I hadn't defined the Privacy - Microphone Usage Description string.
Go into your Info.plist file, and scroll down to the values that start with Privacy. Make sure you add keys and string values for everything relevant to your app.
I got here with the same error using Kudan AR via Unity, and #NeverHelpless's answer was on target, except the fix was NSCameraUsageDescription (Add to Info.plist with a description string)
If you are clear the issue is when accessing Contacts, then follow instructions posted on above answers.
But if those didn't help you, you may want to read my related answer here on other possible solutions (if you are using Bluetooth on your app):
https://stackoverflow.com/a/60073667/457202

Is it possible to define NSLocationWhenInUseUsageDescription within a Framework?

I have developed a Framework which at some point will try to request the device's location. As I understand it, every App which includes this Framework will have to add a NSLocationWhenInUseUsageDescription to its own Info.plist in order to make location usage possible from within the Framework.
Is there a way to provide a NSLocationWhenInUseUsageDescription already inside the Framework so I don't have to rely on the App to define it?
Adding is to the Framework's Info.plist doesn't work. Modifying the App's Info.plist at runtime is also not possible.
Not possible.
The info.plist is present in your Apps Bundle, which is READ-ONLY. This makes it impossible to modify it at runtime.
This makes a lot of sense too because Apple doesn't want Apps to request X permissions when the app is in review and switch to Y once the app is live.
Not letting Frameworks directly request permissions also makes sense. Because you want the app to be aware what permissions related to users sensitive data, a third party piece of code needs before you include it in your code.
All iOS frameworks include required permissions in a readMe file or in such a relevant document along with the framework.
It's not possible as i know... You will have to explain that in order to use your framework, the developer must include the NSLocationWhenInUseUsageDescription tag.

Resources