$ npm install react-native-screen-record-prevent --save
$ react-native link react-native-screen-record-prevent
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-screen-record-preventand addRNScreenRecordPrevent.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNScreenRecordPrevent.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.videoready.screenrecordprev;to the imports at the top of the file - Add
new RNPreventRecordPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':react-native-screen-record-prevent' project(':react-native-screen-record-prevent').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screen-record-prevent/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-screen-record-prevent')
import RNScreenRecordPrevent from 'react-native-screen-record-prevent';
RNScreenRecordPrevent.enabled(true/false); const iosNativeEvent = new NativeEventEmitter(RNScreenRecordPrevent);
iosNativeEvent.addListener('ScreenRecordingEvent', data => console.log(data)); RNScreenRecordPrevent.checkRecordingStatus().then(value => {
console.log(value);
});Note - On iOS, we can't stop screen recording as we can on Android. For this, you'll need to add your own view controller. You can prevent screen recording by adding a view with a black backdrop over your video player when 'ScreenRecodingEvent' returns true.