wn-na / react-native-capture-protection

It’s a library for React Native to control simple capture events(i.e. Screenshot or Screen record)
https://www.npmjs.com/package/react-native-capture-protection
MIT License
102 stars 10 forks source link

binding with expo-screen-capture on iOS not always working #36

Closed wdoyle2 closed 6 months ago

wdoyle2 commented 8 months ago

We use useCaptureProtection and preventScreenshot to prevent screenshoting on iOS and Android. On Android this works perfectly fine as well as the events when a screenshot is triggered.

However on iOS we have noticed that the screenshot prevent does not engage correctly and block the image. The notification to say the screenshot was taken is correctly flagged however the screenshot is still intact.

Is this something we are getting wrong? Can you make any suggestions on how we can ensure that screenshots never get taken on iOS?

wn-na commented 8 months ago

@wdoyle2 hi, What version are you using, and can I see your code? And if you want a completely prevent screenshot like Android, it's going to be hard, I know the best for iOS is make a black screen as user do screenshot

mstfmedeni commented 8 months ago

@0xlethe hi, We use verison 1.9.1, we use it this way in app.tsx. We also use the same useeffect in ApplicationNavigator. black screen will be enough for us but some users take screenshots normally

Screenshot 2024-03-21 at 02 16 22

mstfmedeni commented 8 months ago

We also trigger expo-screen-capture with usePreventScreenCapture as an additional measure

wn-na commented 8 months ago

@mstfmedeni hi, It looks like a conflict with expo-screen-capture to me. in expo-screen-capture, add subview for sharedApplication.keyWindow.subviews.firstObject, also react-native-capture-protection use add sublayer in sharedApplication.keyWindow.sublayers.firstObject

For now, it seems like a good idea to use one.

However, i'll be modifying the library to include this in the near future.

mstfmedeni commented 8 months ago

thank you I will test in detail