AzizAK / react-native-detector

a screenshot detector for react native
MIT License
210 stars 40 forks source link

Not able to detect Screenshot on Android 13. #66

Closed psbdgr8 closed 1 year ago

psbdgr8 commented 1 year ago

It is working with android 12 and below and iOS 16.5 as well. but not able to detect on Android 13+, any help will be appreciated

Sun-Woo-Kim commented 1 year ago

same issue

psbdgr8 commented 1 year ago

@Sun-Woo-Kim if you find any workaround or another Module, please share Thanks.

elmotan95 commented 1 year ago

I think this is may relate to permission https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

This library rely on Manifest.permission.READ_EXTERNAL_STORAGE which is not relevant anymore on Android 13

elmotan95 commented 1 year ago

I already solve the problem.

Make sure to ask permissions with react-native-permissions and for Android 13 or later, check permission for READ_MEDIA_IMAGES, other than that you can use READ_EXTERNAL_STORAGE.

You can test screenshot with emulator by using this command adb shell /system/bin/screencap -p /sdcard/screenshot.png

I made some adjustment too on native module, you can check the PR here https://github.com/AzizAK/react-native-detector/pull/67

For quick fix you can do patch-package

psbdgr8 commented 1 year ago

@elmotan95 Thank you so much it resolved my issue. To resolve the problem of the screenshot detection occurring twice and encountering the "lateinit contentObserver has not been initialized" error, I had to perform slight adjustments to the code. You can refer to the changes made in fork #68 for further details.

elmotan95 commented 1 year ago

Thanks! Yeah I got that error too randomly (don't know how to reproduce) after checking your comment.

psbdgr8 commented 1 year ago

Thanks! Yeah I got that error too randomly (don't know how to reproduce) after checking your comment.

you can reproduce it by updating React Native script

NoahSimajji commented 5 months ago

@psbdgr8 is the fork version work on Android 14?

psbdgr8 commented 5 months ago

@NoahSimajji yes it is working with Android 14 as well.