iOS 10 - Changes in asking permissions of Camera, microphone and Photo Library causing application to crash
Asked Answered
G

3

107

iOS 10, Now Requires User Permission to Access Media Library, Photos, Camera and other Hardware like these. The solution for this is to add their keys into info.plist with a description for user that how we are using their data,

I could only find a few keys

NSPhotoLibraryUsageDescription
NSMicrophoneUsageDescription
NSCameraUsageDescription

I want to know if there are more keys also for other hardware as in iOS 10 if you haven't provided info.plist with proper keys description your application will crash if build using XCode - 8 beta.

Greta answered 21/7, 2016 at 7:55 Comment(2)
is't iOS 10 in under NDA ?Io
I am not sure about this.Greta
E
145

[UPDATED privacy keys list to iOS 13 - see below]

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 (iOS 6, iOS 7), but since iOS 10 app will crash if you don't provide the description why you are asking for the permission (it can't be empty).

Privacy keys with example description: cheatsheet

Source

Alternatively, you can open Info.plist as source code: source code

Source

And add privacy keys like this:

<key>NSLocationAlwaysUsageDescription</key>
<string>${PRODUCT_NAME} always location use</string>

List of all privacy keys: [UPDATED to iOS 13]

NFCReaderUsageDescription
NSAppleMusicUsageDescription
NSBluetoothAlwaysUsageDescription
NSBluetoothPeripheralUsageDescription
NSCalendarsUsageDescription
NSCameraUsageDescription
NSContactsUsageDescription
NSFaceIDUsageDescription
NSHealthShareUsageDescription
NSHealthUpdateUsageDescription
NSHomeKitUsageDescription
NSLocationAlwaysUsageDescription
NSLocationUsageDescription
NSLocationWhenInUseUsageDescription
NSMicrophoneUsageDescription
NSMotionUsageDescription
NSPhotoLibraryAddUsageDescription
NSPhotoLibraryUsageDescription
NSRemindersUsageDescription
NSSiriUsageDescription
NSSpeechRecognitionUsageDescription
NSVideoSubscriberAccountUsageDescription

Update 2019:

In the last months, two of my apps were rejected during the review because the camera usage description wasn't specifying what I do with taken photos.

I had to change the description from ${PRODUCT_NAME} need access to the camera to take a photo to ${PRODUCT_NAME} need access to the camera to update your avatar even though the app context was obvious (user tapped on the avatar).

It seems that Apple is now paying even more attention to the privacy usage descriptions, and we should explain in details why we are asking for permission.

Eloisaeloise answered 21/7, 2016 at 8:0 Comment(10)
yes, but however the change is that application will now crash if you haven't provided description about why we are asking for permission. please correct me if I am wrong.Greta
@Syed Ali Salman You are right - it will crash since iOS10, now really get your question. Will update the answer. :)Eloisaeloise
I hope apple will decide whether it is mandatory or not. According to apple documentation it is not: Explain why your app needs the information if it’s not obvious. You can add custom text to the system-provided permission request alert. Make the text specific and polite, so people don’t feel pressured. Keep the text short, and use sentence case. There’s no need to include your app name. The system already identifies your app as the one making the request.Blancmange
I previously commented about being able to leave these values blank to just display the system-generated message, and while it works fine functionally, it appears that Apple will auto-reject your binary if you include these keys but do not set a value for them.Eldwon
It seems to me that it is a total nonsense from Apple, to let an app just crash when it lacks a permission description... What a poor user experience! (Anonymous) complains flow fast in the AppStore review... And of course the Simultor behaves differently...Ibanez
Apple! If you are reading this ... this should be FLAGGED out in the validation phase of the app upload, not when the app has uploaded and you reject it saying invalid binary. How difficult is it to do this??G
My app doesn't use ANY of these features. Why do I need to enable them???Thynne
@Thynne You need to add permissions of features that you use, of course.Eloisaeloise
@Eloisaeloise My app does not use these features, but apparently a couple frameworks of mine do. That explains why I need to specify. I'm still trying to figure out why iTunes Connect says my app accesses the photo library though. Haven't been able to find anything in the frameworks I'm using.Thynne
I couldn't agree more with these comments. It's shocking that Apple gets away with stuff like this. Last week, my iPhone app worked, this week (following an iOS upgrade), it crashes completely when a user tries to take a photo. No error... no suggestion of what happened, just an angry user. Apple are seriously the most developer-unfriendly company I've dealt with since Palm....Lali
C
70

Please find below codes for ios 10 request permission sample for info.plist.
You can modify for your custom message.

    <key>NSCameraUsageDescription</key>
    <string>${PRODUCT_NAME} Camera Usage</string>

    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>${PRODUCT_NAME} BluetoothPeripheral</string>

    <key>NSCalendarsUsageDescription</key>
    <string>${PRODUCT_NAME} Calendar Usage</string>

    <key>NSContactsUsageDescription</key>
    <string>${PRODUCT_NAME} Contact fetch</string>

    <key>NSHealthShareUsageDescription</key>
    <string>${PRODUCT_NAME} Health Description</string>

    <key>NSHealthUpdateUsageDescription</key>
    <string>${PRODUCT_NAME} Health Updates</string>

    <key>NSHomeKitUsageDescription</key>
    <string>${PRODUCT_NAME} HomeKit Usage</string>

    <key>NSLocationAlwaysUsageDescription</key>
    <string>${PRODUCT_NAME} Use location always</string>

    <key>NSLocationUsageDescription</key>
    <string>${PRODUCT_NAME} Location Updates</string>

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>${PRODUCT_NAME} WhenInUse Location</string>

    <key>NSAppleMusicUsageDescription</key>
    <string>${PRODUCT_NAME} Music Usage</string>

    <key>NSMicrophoneUsageDescription</key>
    <string>${PRODUCT_NAME} Microphone Usage</string>

    <key>NSMotionUsageDescription</key>
    <string>${PRODUCT_NAME} Motion Usage</string>

    <key>kTCCServiceMediaLibrary</key>
    <string>${PRODUCT_NAME} MediaLibrary Usage</string>

    <key>NSPhotoLibraryUsageDescription</key>
    <string>${PRODUCT_NAME} PhotoLibrary Usage</string>

    <key>NSRemindersUsageDescription</key>
    <string>${PRODUCT_NAME} Reminder Usage</string>

    <key>NSSiriUsageDescription</key>
    <string>${PRODUCT_NAME} Siri Usage</string>

    <key>NSSpeechRecognitionUsageDescription</key>
    <string>${PRODUCT_NAME} Speech Recognition Usage</string>

    <key>NSVideoSubscriberAccountUsageDescription</key>
    <string>${PRODUCT_NAME} Video Subscribe Usage</string>

iOS 11 and plus, If you want to add photo/image to your library then you must add this key

    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>${PRODUCT_NAME} library Usage</string>
Coplin answered 22/11, 2016 at 5:25 Comment(2)
Thanks, its true answer, just Apple says "There’s no need to include your app name. The system already identifies your app as the one making the request."Radiant
That's the answer i was looking forAnton
Z
18

You have to add this permission in Info.plist for iOS 10.

Photo :

Key       :  Privacy - Photo Library Usage Description    
Value   :  $(PRODUCT_NAME) photo use

Microphone :

Key        :  Privacy - Microphone Usage Description    
Value    :  $(PRODUCT_NAME) microphone use

Camera :

Key       :  Privacy - Camera Usage Description   
Value   :  $(PRODUCT_NAME) camera use
Zachery answered 21/9, 2016 at 5:40 Comment(1)
Right keys are like NSPhotoLibraryUsageDescription.Calvities

© 2022 - 2024 — McMap. All rights reserved.