iOS10的版本在获取手机权限的时候会要求开发者手动的去设置权限,否则就会报类似这样的错误:
This app has crashed because it attempted to access privacy-sensitive data without a usage description.
The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.
大体意思就是这个App缺少一个获取私有(敏感)数据的权限描述,需要我们在info.plist文件中必须含有一个名字叫做NSPhotoLibraryUsageDescription的值来解释为什么应用需要使用这个数据。所以获取相册资源的键值就是NSPhotoLibraryUsageDescription!!!
于是就去info.plist文件中添加了下面的键值:
文字版
NSPhotoLibraryUsageDescription //相册权限
Microphone Usage Description //麦克风权限
Contacts Usage Description //通讯录权限
Camera Usage Description //摄像头权限
NSSiriUsageDescription //Siri的权限
Bluetooth Peripheral Usage Description //蓝牙
Reminders Usage Description //提醒事项
Motion Usage Description //运动与健康
Media Libaray Usage Description //媒体资源库
Calendars Usage Description //日历
这个时候再获取手机权限的时候就会弹出一个提示框
image.png
点击“好”,就可以获取了。
网友评论