MCPcopy Index your code
hub / github.com/a7medev/react-native-prevent-screenshots

github.com/a7medev/react-native-prevent-screenshots @2.0.0-nightly.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.0.0-nightly.1 ↗ · + Follow
85 symbols 140 edges 31 files 10 documented · 12% updated 3y ago2.0.0-nightly.1 · 2022-07-26★ 751 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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();

Extension points exported contracts — how you extend this code

Spec (Interface)
(no doc) [4 implementers]
src/NativePreventScreenshots.ts

Core symbols most depended-on inside this repo

start
called by 6
src/NativePreventScreenshots.ts
stop
called by 4
src/NativePreventScreenshots.ts
isPrevented
called by 4
src/NativePreventScreenshots.ts
register
called by 2
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/newarchitecture/components/MainComponentsRegistry.java
getMainComponentName
called by 1
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/MainActivity.java
getReactNativeHost
called by 1
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/MainApplication.java
initializeFlipper
called by 1
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/MainApplication.java
initHybrid
called by 1
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/newarchitecture/components/MainComponentsRegistry.java

Shape

Method 61
Class 16
Function 7
Interface 1

Languages

Java69%
TypeScript16%
C++14%

Modules by API surface

example/android/app/src/main/java/com/example/reactnativepreventscreenshots/newarchitecture/MainApplicationReactNativeHost.java10 symbols
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java7 symbols
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/MainApplication.java7 symbols
example/android/app/src/main/java/com/example/reactnativepreventscreenshots/MainActivity.java6 symbols
android/src/turbo/PreventScreenshotsModule.java6 symbols
android/src/legacy/PreventScreenshotsModule.java6 symbols
src/prevent-screenshots/index.ts5 symbols
example/android/app/src/debug/java/com/example/reactnativepreventscreenshots/ReactNativeFlipper.java5 symbols
android/src/main/java/com/reactnativepreventscreenshots/PreventScreenshotsModuleImpl.java5 symbols
src/NativePreventScreenshots.ts4 symbols
example/android/app/src/main/jni/MainComponentsRegistry.cpp4 symbols
example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp4 symbols

For agents

$ claude mcp add react-native-prevent-screenshots \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page