Hey folks I’m having trouble wrapping my head around the correct way to handle camera and photo permissions in iOS 14 and what the appropriate flow is. It feels like I’ve overlooked something simple though not sure what exactly.
For context, the user is not prompted with a request for camera or photos permission until they’ve tapped the respective button for the first time. The app includes a custom photo picker that displays available photos to select based on previous photo associations (i.e. a photo can only belong to one product at a time and wouldn’t show as “available” in the custom picker unless it wasn’t associated with a product).
If the user taps the camera button, accepts the permission request, takes a photo and taps “Use Photo”, the UIImagePickerController
is dismissed and an alert is presented that asks the user to Select Photos...
, Allow Access
to All Photos
, or Don't Allow
. If the user chooses to allow access to all photos there is no problem, the photo is saved using PhotoKit APIs and the UI updated to showcase the thumbnail of the photo just taken. Everything works as expected.
If the user chooses to select certain photos, a PHPickerViewController
is presented and does not include the photo just taken with the camera since it has yet to be saved. This makes sense though leaves me to wonder how do I save the image and allow the user who chooses limited photo access to select that newly taken photo? Perhaps this isn’t possible.
There are additional hiccups I’m seeing with the flow such that if the user then taps “Done” to dismiss the PHPickerViewController
without making any selections after electing limited access, the app is able to save the image taken from the camera using PhotoKit APIs and the UI updated to showcase the thumbnail (this seems incorrect though I may be misunderstanding something simple).
In the same run of the app, if the user taps the photos button, they are presented with the custom picker and logging shows a fetch count of 0 photos available to the user. This makes sense since there were no selections made. However, on the next app run, if the user taps the photo button, they are presented with the alert to Select More Photos...
or Keep Current Selection
. If they elect to add to the photo selection, they are presented with a PHPickerViewController
that shows the photo previously taken with the camera as a user selection and a fetch count of 1 for available photos. Additionally, with limited access mode, attempts to generate thumbnails have produced errors in the Xcode console indicating that an operation is not permitted or a failure to decode an asset. I've seen the following in the console: [Thumbnails] Could not open PLPositionalImageTable...
It feels like I’m missing something basic in this process of taking, saving, and using photos (even a limited selection of them) for iOS 14. Does anyone have experience with this or a resource beyond recent WWDC videos that may shed light on what I’m missing? Appreciate the help in advance.
Also fwiw I would love to rely on PHPickerViewController
rather than the custom picker however unless I’m missing something, PHPickerViewController
doesn’t allow us to provide a subset of photos to display and only that subset even if the subset is limited by the user selection in limited access mode. If I’m misguided I’d appreciate direction there as well. Thanks all!