jkang14
jkang14

Reputation: 63

How to detect screenshots with React Native (both Android and iOS)

I am trying to detect if a user takes a screenshot while using a smartphone app that I have built. I am building my project with React Native.

I have been told that I can possibly prevent screenshots for Android but not for iOS. but can I still detect whether a user attempts to take a screenshot so that I can at least send a warning via Alert?

Thanks in advance

I tried react-native-screenshot-detector but it did not work

Upvotes: 3

Views: 1840

Answers (2)

Abdulaziz Alkharashi
Abdulaziz Alkharashi

Reputation: 1316

you can use this package it supports android&ios screenshot detecting react-native-detector

import {
  addScreenshotListener,
  removeScreenshotListener,
} from 'react-native-detector';

// ...
React.useEffect(() => {
  const userDidScreenshot = () => {
    console.log('User took screenshot');
  };
  const listener = addScreenshotListener(userDidScreenshot);
  return () => {
    removeScreenshotListener(listener);
  };
}, []);

Upvotes: 1

Suresh Tamang
Suresh Tamang

Reputation: 52

There is no package for it currently.

Upvotes: 0

Related Questions