🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

react-native-prevent-screenshots

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-prevent-screenshots

Prevent Screenshots in your React Native app when needed. 🦄

latest
Source
npmnpm
Version
2.0.0-nightly.1
Version published
Weekly downloads
75
22.95%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Prevent Screenshots

Prevent Screenshots in your React Native app when needed. 🦄

Installation

First, you need to install the package using the command above:

npm install react-native-prevent-screenshots --save

Or if you're using Yarn:

yarn add react-native-prevent-screenshots

React Native <= 0.59

For React Native <= 0.59, there's no autolinking so you have to link the package using the command below:

react-native link react-native-prevent-screenshots

Expo Managed Workflow Support

In order to use react-native-prevent-screenshots with Expo you have to have native android folder in your app, fortunately you can do that easily without ejecting just by using this command:

expo run:android

which will generate the android folder for you and allow you to use custom native code for android while still using Expo managed workflow.

NOTE: you don't have to do the same for iOS because we use the React Native AppState JavaScript API on iOS.

Usage

For iOS support you have to wrap the App component with the withPreventScreenshots call like this:

import { withPreventScreenshots } from 'react-native-prevent-screenshots';

function App() {
  // ...
}

export default withPreventScreenshots(App);

Now, you can now call PreventScreenshots.start() and PreventScreenshots.stop() functions anywhere in your app to start/stop preventing screenshots.

import { PreventScreenshots } from 'react-native-prevent-screenshots';

// Prevent Screenshots (returns `Promise<boolean>` of the prevention state)
PreventScreenshots.start();

// Allow Screenshots (returns `Promise<boolean>` of the prevention state)
PreventScreenshots.stop();

Keywords

react-native

FAQs

Package last updated on 26 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts