DEV Community

Cover image for react-native detect when user takes a screenshot
David Narbutovich
David Narbutovich

Posted on • Updated 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: 50%; Popularity: 8%; Maintenance: 55%
expo-screen-capture Quality: 95%; Popularity: 26%; Maintenance: 99%
react-native-screenshot-notifier Quality: 51%; Popularity: 3%; Maintenance: 16%
react-native-screenshot-detect Quality: 20%; Popularity: 2%; Maintenance: 4%

⚠️ 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 ❤️

Discussion (0)