DEV Community

Cover image for react-native detect when user takes a screenshot
Davyd NRB
Davyd NRB

Posted on • Edited on

react-native detect when user takes a screenshot

This is really important when you communicate with family, colleagues, or close friends on the internet, you have to be sure that sensitive information won't be copied and re-shared with someone else. Popular applications like Instagram, Snapchat long ago implemented this simple feature: screenshot detection.

demo taking a screenshot on Android


How things are in the react-native ecosystem? For current moment I found three modules that compatible with latest version of react-native@0.65.x (see below)

Module name iOS Android Stats
react-native-detector Quality: 75%; Popularity: 14%; Maintenance: 98%
expo-screen-capture Quality: 95%; Popularity: 38%; Maintenance: 98%
react-native-screenshot-notifier Quality: 51%; Popularity: 6%; Maintenance: 48%
react-native-screenshot-detect Quality: 20%; Popularity: 3%; Maintenance: 33%

⚠️ Note: Both modules has one limitation on Android, that required a READ_EXTERNAL_STORAGE permission

For Android to understand that screenshot was taken modules use ContentObserver, to listen that a picture file was created and filename includes "screenshot"


if you have any question I am glad to discuss them in the comments!

(c) MurAmur ❤️

Top comments (0)