Issue
I'm currently using the Expo imagepicker and it works well on Android phones. However, when choosing the "Select Photos" option on iOS, the photo gallery pops up again after permission is granted and a photo is selected. It is only on the second photo select that a photo is actually uploaded.
I tried to follow the solution here: presentationStyle Object prop addition
The prop does not accept 0 as a valid argument anymore and the enums doesn't result in any meaningful change to the photo selector UI. The bug also still remains regardless of the options I list. It seems like this may be an issues with the UIImagePickerController on iOS. I also don't know of an alternative to expo-image-picker for my expo application.
The selection works flawlessly when the user selects "Allow Access to All Photos".Is it possible for me to circumvent the double pop-up when "Select photos" is used instead of "Allow Access to All Photos"? I'm considering using a different package, but I don't really know how to make the double pop-up go away.
Solution
It turns out the bug is a feature. Since IOS 14 there has been an additional option when asking for photo permissions, that being "Select Photos...".
This issue talks about the PHPickerViewController and it is correct that the expo-image-picker uses the PHPickerViewController as its built off of the IOS SDK. The behaviour in which the image library modal is shown twice is, however, intended behaviour with the new PHPicker on apple. This is the user first selecting the photos the app should have access to. The second modal is them selecting the photos to be uploaded. This is counter-intuitive because the app continues showing the entire photos library even after the user has "restricted access". This is also intended behaviour, which is even more counter intuitive. This is because after IOS 14, Apple says we no longer need to ask for photo library permission if we are simply accessing photos. This is because the photo picker is run outside of the main process and only passes the selected images to the app, meaning the app technically never accessed the photos library.
The "Select Photos" feature from apple, restricts asset access to PhotoKit (PHAssets) in the IOS SDK. The PhotoKit is used in apps that implement non-destructive image editing for example that need write access to the photos library.
I found a number of good reasources supporting this claim:
https://developer.apple.com/forums/thread/652819 (1:10 and 12:00 are timestamps where they talk about this if you don't wanna watch the whole video)
https://developer.apple.com/videos/play/wwdc2020/10641/ talks about when we would need to ask for permissions
https://developer.apple.com/forums/thread/652819 discussion thread about this confusing behaviour
https://developer.apple.com/forums/thread/653414 There is a quote here that really stuck out. "Forcing users to give your app full Photos Library access before presenting UIImagePickerController could be considered an anti-pattern."
https://github.com/expo/expo/issues/11625 some folks on github also confused by this.
https://github.com/react-native-image-picker/react-native-image-picker/issues/1952 discussion on react-native-image-picker repo So I think the solution to this issue here is, thankfully, not to build a new photo picker, rather to turn off the permissions prompt from the expo-image-picker on IOS 14 and up.
Tldr; I was able to get away with not explicitly asking for permissions that should be pre-defined before interacting with the interface.
Answered By - ApluUAlberta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.