iOS 10 – 更改相机,麦克风和照片库的权限,导致应用程序崩溃
iOS 10
现在需要用户权限来访问媒体库,照片,相机和其他硬件。 解决这个问题的方法是将他们的密钥添加到info.plist
并为用户描述我们如何使用他们的数据,
我只能find几个键
NSPhotoLibraryUsageDescription NSMicrophoneUsageDescription NSCameraUsageDescription
我想知道是否有更多的键也适用于iOS 10
其他硬件, 如果你没有提供info.plist
和正确的键描述你的应用程序将崩溃,如果使用XCode – 8testing版。
有一个你可以在Info.plist
文件中指定的所有Cocoa Keys
的列表:
(Xcode目标 – >信息 – >自定义iOS目标属性)
iOS已经需要权限访问麦克风,相机和媒体库(iOS6,iOS7),但是由于iOS10
应用程序将会崩溃,如果您没有提供描述为什么您要求的权限。
带示例说明的隐私密钥:
资源
你也可以打开它们作为源代码:
资源
并像这样添加它们:
<key>NSLocationAlwaysUsageDescription</key> <string>${PRODUCT_NAME} always location use</string>
所有隐私密钥列表:
NSCameraUsageDescription NSBluetoothPeripheralUsageDescription NSCalendarsUsageDescription NSContactsUsageDescription NSHealthShareUsageDescription NSHealthUpdateUsageDescription NSHomeKitUsageDescription NSLocationAlwaysUsageDescription NSLocationUsageDescription NSLocationWhenInUseUsageDescription NSAppleMusicUsageDescription NSMicrophoneUsageDescription NSMotionUsageDescription kTCCServiceMediaLibrary NSPhotoLibraryUsageDescription NSRemindersUsageDescription NSSiriUsageDescription NSSpeechRecognitionUsageDescription NSVideoSubscriberAccountUsageDescription
请为info.plist
查找以下代码获取ios 10请求许可示例。
您可以修改您的自定义消息。
<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 10的Info.plist中添加此权限以获取更多参考全部权限 。
照片:
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