Support for the new auth status PHAuthorizationStatusLimited
from iOS 14
#326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! Here is a PR for a change we are currently using in our App (http://fleetback.com).
Summary
In version 4.0.4 of the lib, when you call
CameraRoll.getPhotos(...)
on iOS there is no distinction if you have access to all photos (PHAuthorizationStatusAuthorized
) or just the one the user has given permission for (PHAuthorizationStatusLimited
) because it uses the deprecated method[PHPhotoLibrary authorizationStatus];
.This change updates the lib to use
[PHPhotoLibrary authorizationStatusForAccessLevel:];
and[PHPhotoLibrary requestAuthorizationForAccessLevel: handler:]
if available. I put the level atPHAccessLevelReadWrite
to be backwards compatible.This PR adds a new field
limited
in the result ofCameraRoll.getPhotos(...)
that will be true if the status isPHAuthorizationStatusLimited
. This lets you show in your UI that there are more photos available.Motivation
With iOS 14, if the user chose the "Select photos..." option the first time the gallery is accessed, every subsequent time an alert is presented to the user to let them change the selection.
This second alert interrupts the user, make them do their photo selection twice, cannot be translated, and does not call the completion handler when the user is done changing their selection (you have to wait for iOS 15 for this oversight to be fixed). Fortunately you can disable it with
PHPhotoLibraryPreventAutomaticLimitedAccessAlert
in your Info.plist.If you don't use
UIImagePickerController
it's generally better to have some non-intrusive UI in your app to change the permissions. With this PR you can now do that.Test Plan
What's required for testing (prerequisites)?
CameraRoll.getPhotos(...)
and displays the resultsCameraRoll.getPhotos(...)
and displays the results, with<key>PHAuthorizationStatusLimited</key><true/>
in Info.plistWhat are the steps to reproduce (after prerequisites)?
Test 1
CameraRoll.getPhotos
"limited": true
is returnedCameraRoll.getPhotos
The promise is fulfilled immediately with the old selection (this is an iOS issue)
"limited": true
is returnedTest 2
CameraRoll.getPhotos
"limited": true
is returnedCameraRoll.getPhotos
"limited": true
is returnedTest 3
CameraRoll.getPhotos
"limited": false
is returnedCameraRoll.getPhotos
"limited": false
is returnedCompatibility
The change is backwards compatible with v4.0.4.
Checklist
README.md
example/App.js
)