【转载】ios11 相册读写权限 变更

http://www.jianshu.com/p/c03a87e4ca87

 

大家都知道访问相册需要申请用户权限。 相册权限需要在info.plist—Property List文件中添加NSPhotoLibraryUsageDescription键值对,描述文字不能为空。 iOS11之前:访问相册和存储照片到相册(读写权限),需要用户授权,需要添加NSPhotoLibraryUsageDescription。
iOS11之后:默认开启访问相册权限(读权限),无需用户授权,无需添加NSPhotoLibraryUsageDescription,适配iOS11之前的还是需要加的。 添加图片到相册(写权限),需要用户授权,需要添加NSPhotoLibraryAddUsageDescription

总结:iOS11之后如果需要写入权限需要添加
NSPhotoLibraryAddUsageDescription字段。  
   NSPhotoLibraryUsageDescription:
Property List:
   Privacy - Photo Library Usage Description
Source Code:
  NSPhotoLibraryUsageDescription
是否允许此APP使用相册?
   NSPhotoLibraryAddUsageDescription :
Property List:
   Privacy - Photo Library Additions Usage Description
Source Code:
   NSPhotoLibraryAddUsageDescription
是否允许此APP保存图片到相册?

苹果官方文档说明:

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW73

NSPhotoLibraryAddUsageDescription

NSPhotoLibraryAddUsageDescription (String - iOS) This key lets you describe the reason your app seeks write-only access to the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and that accesses the user’s photo library, must statically declare the intent to do so. Include the NSPhotoLibraryAddUsageDescription key (in apps that link on or after iOS 11) or NSPhotoLibraryUsageDescription key in your app’s Info.plist file and provide a purpose string for the key. If your app attempts to access the user’s photo library without a corresponding purpose string, your app exits.

 

This key is supported in iOS 11.0 and later.

NSPhotoLibraryUsageDescription

NSPhotoLibraryUsageDescription (String - iOS) This key lets you describe the reason your app accesses the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

Although this keys governs read and write access to the user’s photo library, it’s best to use NSPhotoLibraryAddUsageDescription if your app needs only to add assets to the library and does not need to read any assets.

Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and that accesses the user’s photo library, must statically declare the intent to do so. Include the NSPhotoLibraryUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s photo library without a corresponding purpose string, your app exits.

 

This key is supported in iOS 6.0 and later.

 



作者:小孩仔
链接:http://www.jianshu.com/p/c03a87e4ca87
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

转载于:https://www.cnblogs.com/huangzizhu/p/7698648.html

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2020 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值