react-native-screenshot-prevent
This fork contains fully working blank screenshot on IOS13+ including screen recording
This fork contains fully working image screenshot cover on IOS13+ including screen recording
App layout is white / or black in dark theme
For now you might disable RNPreventScreenshot.enableSecureView() in development mode (check DEV variable)
because disableSecureView() is not working yet correctly
Getting started
$ npm install react-native-screenshot-prevent --save
Mostly automatic installation
React-Native version 0.59.X and higher: on IOS you might use only pod install
in your ios folder
$ react-native link react-native-screenshot-prevent
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜ Add Files to [your project's name]
- Go to
node_modules
➜ react-native-screenshot-prevent
and add RNScreenshotPrevent.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNScreenshotPrevent.a
to your project's Build Phases
➜ Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.killserver.screenshotprev.RNScreenshotPreventPackage;
to the imports at the top of the file - Add
new RNScreenshotPreventPackage()
to the list returned by the getPackages()
method
- Append the following lines to
android/settings.gradle
:
include ':react-native-screenshot-prevent'
project(':react-native-screenshot-prevent').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screenshot-prevent/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
implementation project(':react-native-screenshot-prevent')
Usage
import RNScreenshotPrevent, { addListener } from 'react-native-screenshot-prevent';
RNScreenshotPrevent.enabled(true/false);
if(!__DEV__) RNScreenshotPrevent.enableSecureView();
if(!__DEV__) RNPreventScreenshot.enableSecureView(imgUri);
if(!__DEV__) RNScreenshotPrevent.disableSecureView();
addListener(fn);
useEffect(() => {
const subscription = RNScreenshotPrevent.addListener(() => {
console.log('Screenshot taken');
showAlert({
title: 'Warning',
message: 'You have taken a screenshot of the app. This is prohibited due to security reasons.',
confirmText: 'I understand'
});
})
return () => {
subscription.remove();
}
}, []);