ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.14k stars 1.56k forks source link

Compliance with Google Play's Photo and Video Permissions policy #2087

Open bhavesh-lw opened 2 months ago

bhavesh-lw commented 2 months ago

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

Upcoming android deadline.

There is upcoming android deadline regarding READ_MEDIA_IMAGES permission. As per new google You can only use READ_MEDIA_PERMISSION permission if your app is a gallery app, or if its core functionality is editing, managing, and maintaining photos. Otherwise, you must migrate to the Android photo picker, or a photo picker of your choice.

Now apps that are using this for picking up profile pictures or other non-core features won't be able to use READ_MEDIA_IMAGES permission after the deadline.

Here is timeline google provided

Screenshot 2024-09-20 at 12 44 30 PM

Detail policy info here

So necessary update to package required in order to access images without READ_MEDIA_IMAGES permission.

Pauligrinder commented 2 months ago

I found a library that already does this: react-native-photo-picker, and it doesn't look like it'd be very hard to implement. I'll do it myself in the coming weeks unless someone else beats me to it, as I really need this for all the apps I'm maintaining.

I'd be very thankful if someone else did beat me to it though, as I'm not used to developing libraries so I'm having a hard time getting the environment to work properly.

Pauligrinder commented 2 months ago

I actually got it done already with an as minimal change as possible. I'll post a PR asap.

julianD77 commented 2 months ago

We are using this library in an App using react-native 0.73.6, and both targetSDK and compileSDK at 34, and also now see the new warning in the Play console regarding the READ_MEDIA_IMAGES permission.

We have now tested a version of our App after removing READ_MEDIA_IMAGES permission from the AndroidManifest.xml and so far have not seen any problems opening and selecting images. We have tried against various devices and Android versions going back to Android 8.0 and so far the image picker has worked OK.

Interested to hear from others if they have found devices where this permission is still required. I know the readme of the project states it should be added, but might it only be required for apps with a targetSDK of 33?

NOTE: there is a related/duplicate issue here #2043

Pauligrinder commented 2 months ago

@julianD77 I think it's just Android 13+ where that permission is required. I don't remember exactly what happened and on what device/version, but it definitely doesn't work 100% without it.

Either way I also think it's better to use the way Google has suggested to pick images, and it's not a very big deal to upgrade.

webchun commented 2 months ago

Got the same problem today when pushing a new update for my app.

Pauligrinder commented 1 month ago

Pull request created: https://github.com/ivpusic/react-native-image-crop-picker/pull/2093

leonardorib commented 1 month ago

We are using this library in an App using react-native 0.73.6, and both targetSDK and compileSDK at 34, and also now see the new warning in the Play console regarding the READ_MEDIA_IMAGES permission.

We have now tested a version of our App after removing READ_MEDIA_IMAGES permission from the AndroidManifest.xml and so far have not seen any problems opening and selecting images. We have tried against various devices and Android versions going back to Android 8.0 and so far the image picker has worked OK.

Interested to hear from others if they have found devices where this permission is still required. I know the readme of the project states it should be added, but might it only be required for apps with a targetSDK of 33?

NOTE: there is a related/duplicate issue here #2043

I was reading through @Pauligrinder PR and the history on this permission, and testing our app and i had the same result here! Simply removing READ_MEDIA_IMAGES and the picker still worked fine (Android 14).

Either way I also think it's better to use the way Google has suggested to pick images, and it's not a very big deal to upgrade.

But I agree, long term is always best to comply with whatever Google is suggesting

leonardorib commented 1 month ago

I was reading through @Pauligrinder PR and the history on this permission, and testing our app and i had the same result here! Simply removing READ_MEDIA_IMAGES and the picker still worked fine (Android 14).

Looks like this is what happened:

https://android-developers.googleblog.com/2023/04/photo-picker-everywhere.html#:~:text=GET_CONTENT%20takeover

Since our last blog post, we started rolling out support for the GET_CONTENT intent in the Android photo picker whenever the specified MIME type filter matches image/ and/or video/

https://medium.com/androiddevelopers/permissionless-is-the-future-of-storage-on-android-3fbceeb3d70a#:~:text=ACTION_GET_CONTENT%20behaviour%20change

As we just saw, adopting the Android photo picker requires just a few lines of code. While we want all apps to use it, migration might take some time in your app. That’s why we are bringing the benefits of Android photo picker to existing apps using ACTION_GET_CONTENT by switching the system file picker for the photo picker under the hood without any code change required in the upcoming months. If you launch the ACTION_GET_CONTENT intent with an image and/or video mime type filter, the photo picker will be shown instead of the document picker. For applications, the expected intent results will be the same: a list of Uri.

This explains why we are being able to remove READ_MEDIA_IMAGES and still have the new photo picker working normally even though it is not explicitly implemented.

scblason commented 1 month ago

@leonardorib Could you explain why we get this library working even with the removed permissions? I tested myself on an Android SDK 34 and I got the same results (library working ok). Is it because this library is using ACTION_GET_CONTENT?

leonardorib commented 1 month ago

@scblason

@leonardorib Could you explain why we get this library working even with the removed permissions? I tested myself on an Android SDK 34 and I got the same results (library working ok). Is it because this library is using ACTION_GET_CONTENT?

Sure! In my previous comment I'm linking the official blog posts from Google where they mention this transition to the new Photo Picker that provides more privacy for users. So if you stick to the new photo picker, don't even need to ask permissions.

And as part of the transition, they state on the post on Medium:

...that’s why we are bringing the benefits of Android photo picker to existing apps using ACTION_GET_CONTENT by switching the system file picker for the photo picker under the hood without any code change required in the upcoming months. If you launch the ACTION_GET_CONTENT intent with an image and/or video mime type filter

And on android-developers.googleblog.com:

Since our last blog post, we started rolling out support for the GET_CONTENT intent in the Android photo picker whenever the specified MIME type filter matches image/ and/or video/

So they made the Photo Picker show up even if you are using the legacy GET_CONTENT intent with a mime type filter for image or video instead of using the actual photo picker API.

And this is precisely the case for this library as you can see in this function:

https://github.com/ivpusic/react-native-image-crop-picker/blob/6ff41ff98874c3213907e27e781084ce2f862d2a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java#L365-L392

So even though no changes were made in the library code to invoke the new Photo Picker, it is still able to do it since Google implemented the switch on their side. This is why the package is working even if you remove READ_MEDIA_IMAGES.

scblason commented 1 month ago

@leonardorib thank you very much for the thorough response. I saw the same in the code and I wanted to validate if this was the correct conclusion. I did more test in different devices and I haven't had any issues after removing the permissions.

aleksamrakovic commented 1 week ago

any news regarding this issue?