Search code examples
react-nativescreenshot

How to detect a screenshot in a RN application?


I'm having some problem about a screenshot-detector in an application.

I'm using EXPO, but I've no idea about how can I detect a screenshot. Suppose that I've a profile screen. Each user has a profile page, I want to detect when another user does a screenshot on the screen.

My problem is: how can I detect this? I readed about the gesture here, but it didn't help me. With the gestures I can detect, instead, the scroll in a page, the location x and location y.

I readed also this answer, but about the event touchesCancelled:withEvent:touchesCancelled:withEvent: I have not found anything in React Native docs (and also EXPO docs).

So: which is the idea behind a screenshot detector? Thanks for your help!


Solution

  • You can't do it without detaching EXPO. There is already a feature request for that.

    If you decide to detach EXPO, react-native-screenshot-detector might be helpful. The solution is very similar to the one from the linked question.