提到iOS10.0权限设置,先说一下在iOS9.0的权限设置
iOS9.0引入了新特性App Transport Security (ATS),导致网络请求访问失败,新特性要求App内访问的网络必须使用HTTPS协议,也就是超文本传输协议。
但是现在很多公司使用的还是http协议,也不可能一下子就改为HTTPS;
为了让http请求也能正常范文网络数据,解决的办法如下:
在info.plist文件中添加App Transport Security Settings类型Dictionary;
在App Transport Security Settings下添加Allow Arbitrary Loads类型Boolean,值设为YES;
这样就可以正常访问到网络数据了;
iOS10.0对用户的隐私权限越来越重视,要想正常访问相册,相机,位置,麦克风,蓝牙,健康等都需要事先在info.plist文件中进行相应设置,现将开发中常用的用户权限设置总结如下:
蓝牙
NSBluetoothPeripheralUsageDescription
日历
NSCalendarsUsageDescription
相机
NSCameraUsageDescription
健康分享
NSHealthShareUsageDescription
健康更新
NSHealthUpdateUsageDescription
始终允许访问位置
NSLocationAlwaysUsageDescription
位置
NSLocationUsageDescription
在使用期间访问位置
NSLocationWhenInUseUsageDescription
麦克风
NSMicrophoneUsageDescription
运动与健康
NSMotionUsageDescription
相册
NSPhotoLibraryUsageDescription
提醒事项
NSRemindersUsageDescription
在info.plist添加如上访问权限,就可以避免运行中使用到的权限突然crash。
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App需要您的同意,才能访问蓝牙</string>
<key>NSCalendarsUsageDescription</key>
<string>App需要您的同意,才能访问日历</string>
<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能访问相机</string>
<key>NSHealthShareUsageDescription</key>
<string>App需要您的同意,才能访问健康分享</string>
<key>NSHealthUpdateUsageDescription</key>
<string>App需要您的同意,才能访问健康更新</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>App需要您的同意,才能始终访问位置</string>
<key>NSLocationUsageDescription</key>
<string>App需要您的同意,才能访问位置</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App需要您的同意,才能在使用期间访问位置</string>
<key>NSMicrophoneUsageDescription</key>
<string>App需要您的同意,才能访问麦克风</string>
<key>NSMotionUsageDescription</key>
<string>App需要您的同意,才能访问运动与健身</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能访问相册</string>
<key>NSRemindersUsageDescription</key>
<string>App需要您的同意,才能访问提醒事项</string>