如何开启权限?
在访问相机、相册时,我们通常需要开启使用权限,方法是在info.plist中添加Cocoa Key,并输入该权限的使用说明:(如下图)
什么是Cocoa Keys?
'Cocoa and Cocoa Touch are the environments used to define apps that run in macOS, iOS, tvOS, and watchOS. The keys associated with the Cocoa environments provide support for Interface Builder nib files and provide support for other user-facing features vended by your bundle'
Cocoa和CocoaTouch是用来定义在MacOS、IOS、tvOS和Watch操作系统中运行的应用程序的环境。与cocoa环境相关联的keys,提供了对接口生成器nib文件的支持,并提供了对包支持的其他面向用户特性的支持。
Cocoa Keys 列表
权限说明 | Cocoa Key | Xcode Name | String |
---|---|---|---|
蓝牙 | NSBluetoothPeripheralUsageDescription | Privacy - Bluetooth Peripheral Usage Description | App需要您的同意,才能访问蓝牙 |
日历 | NSCalendarsUsageDescription | Privacy - Calendars Usage Description | App需要您的同意,才能访问日历 |
相机 | NSCameraUsageDescription | Privacy - Camera Usage Description | App需要您的同意,才能访问相机 |
通讯录 | NSContactsUsageDescription | Privacy - Contacts Usage Description | App需要您的同意,才能访问通讯录 |
FaceID | NSFaceIDUsageDescription | Privacy - Face ID Usage Description | |
健康共享 | NSHealthShareUsageDescription | Privacy - Health Share Usage Description | |
健康更新 | NSHealthUpdateUsageDescription | Privacy - Health Update Usage Description | |
HomeKit | NSHomeKitUsageDescription | Privacy - HomeKit Usage Description | |
始终访问位置 | NSLocationAlwaysUsageDescription | Privacy - Location Always Usage Description | |
位置 | NSLocationUsageDescription | Privacy - Location Usage Description | |
在使用期间访问位置 | NSLocationWhenInUseUsageDescription | Privacy - Location When In Use Usage Description | |
麦克风 | NSMicrophoneUsageDescription | Privacy - Microphone Usage Description | |
运动 | NSMotionUsageDescription | Privacy - Motion Usage Description | |
保存图片 | NSPhotoLibraryAddUsageDescription | Privacy - Photo Library Additions Usage Description | |
相册 | NSPhotoLibraryUsageDescription | Privacy - Photo Library Usage Description | |
提醒事项 | NSRemindersUsageDescription | Privacy - Reminders Usage Description | |
媒体资料库 | NSAppleMusicUsageDescription | Privacy - Media Library Usage Description | |
NFC 近距离无线通信 | NFCReaderUsageDescription | Privacy - NFC Reader Usage Description |
参考文档
Cocoa Keys
网友评论