Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Shashank2406/react-native-screen-record-prevent
https://github.com/Shashank2406/react-native-screen-record-prevent
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Shashank2406/react-native-screen-record-prevent
- Owner: Shashank2406
- License: mit
- Created: 2021-12-22T11:46:15.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-29T11:52:39.000Z (over 1 year ago)
- Last Synced: 2024-10-01T10:48:47.204Z (3 months ago)
- Language: Java
- Size: 24.4 KB
- Stars: 12
- Watchers: 1
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-screen-record-prevent
## Getting started
`$ npm install react-native-screen-record-prevent --save`
### Mostly automatic installation
`$ react-native link react-native-screen-record-prevent`
### Manual installation
#### iOS
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-screen-record-prevent` and add `RNScreenRecordPrevent.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNScreenRecordPrevent.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<#### Android
1. 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 the `getPackages()` method
2. 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')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-screen-record-prevent')
```## Usage
#### For Android - Just enable the RNScreenRecordPrevent.
```javascript
import RNScreenRecordPrevent from 'react-native-screen-record-prevent';RNScreenRecordPrevent.enabled(true/false);
```
#### For iOS - You can get a screen recording event from here and then make your own view controller.
```javascript
const iosNativeEvent = new NativeEventEmitter(RNScreenRecordPrevent);
iosNativeEvent.addListener('ScreenRecordingEvent', data => console.log(data));
```#### For iOS - You can get a check screen recording is active or not
```javascript
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.