iOS 10 - 更改相机、麦克风和照片库的请求权限导致应用程序崩溃
iOS 10 - Changes in asking permissions of Camera, microphone and Photo Library causing application to crash
iOS 10、现在需要用户许可才能访问媒体库、照片、相机和其他类似硬件。解决方案是将他们的密钥添加到 info.plist
中,并向用户说明我们如何使用他们的数据,
我只能找到几把钥匙
NSPhotoLibraryUsageDescription
NSMicrophoneUsageDescription
NSCameraUsageDescription
我想知道是否还有其他硬件的更多密钥,如 iOS 10
如果您没有提供 info.plist
正确的密钥描述,您的应用程序将会崩溃 如果构建使用 XCode - 8 beta.
[已将隐私密钥列表更新为 iOS 13 - 见下文]
您可以在 Info.plist
文件中指定所有 Cocoa Keys
的列表:
(Xcode: 目标 -> 信息 -> 自定义 iOS 目标属性)
iOS 之前已经需要访问麦克风、摄像头和媒体库的权限(iOS 6,iOS 7),但是 因为 iOS 10 如果您不提供请求权限的说明(不能为空),应用程序将崩溃。
带有示例说明的私钥:
并像这样添加私钥:
<key>NSLocationAlwaysUsageDescription</key>
<string>${PRODUCT_NAME} always location use</string>
所有私钥列表:[更新为 iOS 13]
NFCReaderUsageDescription
NSAppleMusicUsageDescription
NSBluetoothAlwaysUsageDescription
NSBluetoothPeripheralUsageDescription
NSCalendarsUsageDescription
NSCameraUsageDescription
NSContactsUsageDescription
NSFaceIDUsageDescription
NSHealthShareUsageDescription
NSHealthUpdateUsageDescription
NSHomeKitUsageDescription
NSLocationAlwaysUsageDescription
NSLocationUsageDescription
NSLocationWhenInUseUsageDescription
NSMicrophoneUsageDescription
NSMotionUsageDescription
NSPhotoLibraryAddUsageDescription
NSPhotoLibraryUsageDescription
NSRemindersUsageDescription
NSSiriUsageDescription
NSSpeechRecognitionUsageDescription
NSVideoSubscriberAccountUsageDescription
2019 年更新:
在过去的几个月里,我的两个应用程序在审查期间被拒绝,因为相机使用说明没有具体说明我如何处理拍摄的照片。
我不得不将描述从 ${PRODUCT_NAME} need access to the camera to take a photo
更改为 ${PRODUCT_NAME} need access to the camera to update your avatar
,即使应用上下文很明显(用户点击头像)。
看来Apple现在更加重视隐私使用说明了,我们应该详细说明为什么要征求权限。
You have to add this permission in Info.plist for iOS 10.
照片:
Key : Privacy - Photo Library Usage Description
Value : $(PRODUCT_NAME) photo use
麦克风:
Key : Privacy - Microphone Usage Description
Value : $(PRODUCT_NAME) microphone use
相机:
Key : Privacy - Camera Usage Description
Value : $(PRODUCT_NAME) camera use
请在下面找到 ios 的代码 10 info.plist
的请求权限示例。
您可以修改您的自定义消息。
<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 以及,如果您想将 photo/image 添加到您的库中,则必须添加此键
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${PRODUCT_NAME} library Usage</string>
iOS 10、现在需要用户许可才能访问媒体库、照片、相机和其他类似硬件。解决方案是将他们的密钥添加到 info.plist
中,并向用户说明我们如何使用他们的数据,
我只能找到几把钥匙
NSPhotoLibraryUsageDescription
NSMicrophoneUsageDescription
NSCameraUsageDescription
我想知道是否还有其他硬件的更多密钥,如 iOS 10
如果您没有提供 info.plist
正确的密钥描述,您的应用程序将会崩溃 如果构建使用 XCode - 8 beta.
[已将隐私密钥列表更新为 iOS 13 - 见下文]
您可以在 Info.plist
文件中指定所有 Cocoa Keys
的列表:
(Xcode: 目标 -> 信息 -> 自定义 iOS 目标属性)
iOS 之前已经需要访问麦克风、摄像头和媒体库的权限(iOS 6,iOS 7),但是 因为 iOS 10 如果您不提供请求权限的说明(不能为空),应用程序将崩溃。
带有示例说明的私钥:
并像这样添加私钥:
<key>NSLocationAlwaysUsageDescription</key>
<string>${PRODUCT_NAME} always location use</string>
所有私钥列表:[更新为 iOS 13]
NFCReaderUsageDescription
NSAppleMusicUsageDescription
NSBluetoothAlwaysUsageDescription
NSBluetoothPeripheralUsageDescription
NSCalendarsUsageDescription
NSCameraUsageDescription
NSContactsUsageDescription
NSFaceIDUsageDescription
NSHealthShareUsageDescription
NSHealthUpdateUsageDescription
NSHomeKitUsageDescription
NSLocationAlwaysUsageDescription
NSLocationUsageDescription
NSLocationWhenInUseUsageDescription
NSMicrophoneUsageDescription
NSMotionUsageDescription
NSPhotoLibraryAddUsageDescription
NSPhotoLibraryUsageDescription
NSRemindersUsageDescription
NSSiriUsageDescription
NSSpeechRecognitionUsageDescription
NSVideoSubscriberAccountUsageDescription
2019 年更新:
在过去的几个月里,我的两个应用程序在审查期间被拒绝,因为相机使用说明没有具体说明我如何处理拍摄的照片。
我不得不将描述从 ${PRODUCT_NAME} need access to the camera to take a photo
更改为 ${PRODUCT_NAME} need access to the camera to update your avatar
,即使应用上下文很明显(用户点击头像)。
看来Apple现在更加重视隐私使用说明了,我们应该详细说明为什么要征求权限。
You have to add this permission in Info.plist for iOS 10.
照片:
Key : Privacy - Photo Library Usage Description
Value : $(PRODUCT_NAME) photo use
麦克风:
Key : Privacy - Microphone Usage Description
Value : $(PRODUCT_NAME) microphone use
相机:
Key : Privacy - Camera Usage Description
Value : $(PRODUCT_NAME) camera use
请在下面找到 ios 的代码 10 info.plist
的请求权限示例。
您可以修改您的自定义消息。
<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 以及,如果您想将 photo/image 添加到您的库中,则必须添加此键
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${PRODUCT_NAME} library Usage</string>