3 Reasons to Upgrade to iOS 14 Photo Picker
Just in case you were not convinced with the first reason.
1. You no longer have to request permission to use it
Yes, privacy, of course. Apple is all about privacy, and they made some very interesting changes on how the photo picker behaves to achieve built-in privacy: the new photo picker runs in a separate process, even though it looks like it's running inside its host app. The app can't access the picker directly, and not even take screenshots of its content. Only the selected images are sent to the app.
This goes beyond protecting the user's privacy, though. Now your app doesn't have to request the user's permission to access their Photo Library because, well, your app doesn't need to access it directly anymore. This smashes a trust barrier between your app and its users.
2. User Experience
The new photo picker offers top notch user experience, with an UI that is intuitive and familiar to the user already, since it's the same one used throughout the system. It has built-in support to:
Reviewing selected items
Zooming in and out of the grid of images
Filterable media types (images, videos, live photos)
State of Art Search
The advantage of using the same search algorithm as the system is that it comes with built-in support to search by:
Date (month or year)
Place (city or state)
Business names (museums, for example)
Category (beach or sunset, for example)
Events (sports games or concerts, for example)
Person (Lia or Gordon, for example)
Now app developers don’t need to worry about optimizing the result queries of Photo Library items to avoid OOM crashes, so it's safer and less error prone.
3. It's Easy
Adopting the new photo picker couldn't be simpler. For developers, this change can be summarized in:
⠀Configuring the photo picker and presenting it (3–6 lines of code):
var configuration = PHPickerConfiguration()
configuration.filter = .images
configuration.selectionLimit = 0
let picker = PHPickerViewController(configuration: configuration)
picker.delegate = self
present(picker, animated: true)
2. ⠀ Implementing a single delegate method that handles the receiving of the results. The results that need to be handled are: images, live photos, and videos. Luckily, Apple provides a sample app that provides this implementation for you (except video handling).
3. ⠀ Deleting A LOT of code related to: asking for permission to access Photo Library, reading and parsing the Photo Library items in an optimized way, creating custom UI components to allow selection and visualization of multiple items, and probably more. For reference, at Tellus I estimate that we’ll able to delete ~1030 lines of code, including 3 xib files.
Are there limitations?
As of now, the new photo picker does have some limitations over UIImagePickerController, and that’s why they didn’t deprecate it completely.
The new picker doesn’t support camera usage, unlike UIImagePickerController that features a wide range of camera-related configurations. But this is not related to the Photo Library :)
UIImagePickerController has a property to allow editing of the image after selecting it. This is not supported by the new picker.
UIImagePickerController just deprecated videoExportPreset as Apple wants you to handle video compression on your own.
When will you still need to request access to the user’s Photo Library?
Basically, only when your app provides:
Non-destructive image editing;
Photo Library organization, such as managing albums or deleting photos.
Apple's efforts towards improving user privacy are no joke. Adhere to them as soon as you can to increase user's trust in your app. This can also make development faster as we saw here today.
Given that Facebook’s iOS app can open the camera in the background without your knowledge and other bizarre privacy violations, I expect to see the same strategy used in the Photo Picker being applied in other areas of the "permission" spectrum, such as camera usage. Most apps using the camera to simply take a picture or record a video don't actually need full access to your camera itself, just its output after it's done being used.
Does your app use UIImagePickerController? Are you going to replace it with the new PHPicker? Do you have a custom-built solution for photo multi-selection? Let me know on the comments below or via twitter @rogerluan_ :)
Follow me for new iOS and Swift content!
Thanks for reading roger.ml! Subscribe for free to receive new posts and support my work.