When Apple introduced limited photo access in iOS 14, some iOS developers were not so happy about it, it seems like Apple was trying to make developers’ life harder. Any apps (old or new) that want to support iOS 14 or higher will have to handle this extra permission status.
Meanwhile, from the user’s perspective, it is a very welcome change. Users can now have more control over the privacy of their photos, limiting the number of photos an app can access.
With this new permission status, the way to handle photo library permission in iOS 14 is very different from the previous iOS versions. In this article, I would like to show you how to properly handle each and every permission status in your iOS apps. Once you get the full picture of how it works, you will find that it is not as complicated as you think.
Note:
This article is mainly for situations where you need to build your own image picker. If you don’t need a custom image picker, use the new PHPickerViewController (a better UIImagePickerController) that manages photo library permission for you.
The Sample App
In terms of photo library permission handling, I really like how Facebook App did it. Therefore, let’s try to create a simple prototype app that mimics the Facebook App’s photo library permission workflow.
Since the aim of this article is to show you how to handle each permission status, we won’t be building a fully functioning image picker. Instead, we will create a POC image picker that displays the permission status, number of accessible photos, and the required UI elements.

UIs for each authorization status
When tap on the “See All Photos” button, the app will redirect the user to the app’s privacy settings so that he/she can grant full photo library access to the app.

Tapping on “See All Photos” button
Whereas, when tapping on the “Manage” button, the user can either select more photos or grant full photo library access to the app.

Tapping on “Manage” button
Requesting Photo Library Access Permission
Before we can start accessing the user’s photo library, we must first get permission to do so. Head over to info.plist and add the

本文详细介绍了如何在iOS应用中处理照片库权限,包括新引入的有限访问权限。开发者需要请求读写权限,并适当地处理授权状态,如授权、限制、拒绝等。用户可以选择授予全库访问或仅限选定照片。文章还提供了代码示例,展示了如何创建类似Facebook应用的权限管理流程,并解释了如何监听照片库的变化以便更新UI。
最低0.47元/天 解锁文章
6119

被折叠的 条评论
为什么被折叠?



