一直以来苹果都特别注重用户的隐私问题,比如访问联系人和打开相册都会弹出一个提示,来征求用户的意见,iOS10更加完善了这方面的权限。
A significant change in iOS 10 is that you must declare ahead of time any access to private data or your App will crash.
在访问下列信息的时候,需要在info.plist
文件里,加上访问说明。
Contacts, Calendar, Reminders, Photos, Bluetooth Sharing, Microphone, Camera, Location, Health, HomeKit, Media Library, Motion, CallKit, Speech Recognition, SiriKit, TV Provider.
否则就会造成崩溃,这是我没有加说明的情况下,试图访问图库的一个崩溃
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.
可以直接在info.plist
里添加键值对,输入Privacy
就会有提示了。
也可以以Source Code
的方式打开info.plist
,然后粘贴下面的字段。
下面列出所有的字段,方便以后粘贴使用。
<key>NSVideoSubscriberAccountUsageDescription</key>
<string>视频认证</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>语音识别</string>
<key>NSSiriUsageDescription</key>
<string>Siri使用</string>
<key>NSRemindersUsageDescription</key>
<string>访问提醒事项</string>
<key>kTCCServiceMediaLibrary</key>
<string>TV控制</string>
<key>NSMotionUsageDescription</key>
<string>运动权限</string>
<key>NSMicrophoneUsageDescription</key>
<string>麦克风权限</string>
<key>NSAppleMusicUsageDescription</key>
<string>苹果音乐</string>
<key>NSLocationUsageDescription</key>
<string>位置权限</string>
<key>NSHomeKitUsageDescription</key>
<string>HomeKit权限</string>
<key>NSHealthUpdateUsageDescription</key>
<string>健康应用</string>
<key>NSHealthShareUsageDescription</key>
<string>健康应用</string>
<key>NSContactsUsageDescription</key>
<string>通讯录</string>
<key>NSCalendarsUsageDescription</key>
<string>日历</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>蓝牙</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>相册</string>
<key>NSCameraUsageDescription</key>
<string>相机</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>永久使用定位</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>应用使用的时候使用定位</string>
网友评论