Light's Blog

The best or nothing.

iOS System Authorization

| Comments

iOS 10开始,获取隐私敏感数据需要在plist.info文件中配置,否则app会crash。
配置方法:添加对应权限的key和value,value不许为空。
常用权限:

  • Network:无需添加key
  • Location:Privacy - Location Always Usage Description
  • Photo:Privacy - Photo Library Usage Description
  • Camera:Privacy - Camera Usage Description
  • Microphone:Privacy - Microphone Usage Description
  • Contact:Privacy - Contacts Usage Description
  • Media:Privacy - Media Library Usage Description

手动请求权限:当用户拒绝授权某权限时,需要手动再次请求。
跳转至权限设置界面:

1
2
3
4
[[UIApplication sharedApplication]
                openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]
                options:@{}
      completionHandler:nil];

Demo地址

Comments