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 NSPhotoLibraryUsageDesc