react-native-screen-blocker
v1.0.8
Published
React Native module to block screenshots and screen recording on Android and iOS
Maintainers
Readme
react-native-screen-blocker
React Native module to block screenshots and screen recordings on Android and iOS devices by leveraging native platform capabilities.
Table of Contents
Features
- Prevent screenshots and screen recordings at the OS level.
- Simple API to enable and disable protection dynamically.
- Supports React Native 0.60+ with automatic linking.
- Uses
FLAG_SECUREon Android. - Uses iOS 13+
setSecure:API with fallback options.
Supported Platforms
| Platform | Minimum Version | Notes |
| -------- | --------------- | -------------------------------- |
| Android | API 16+ | Uses WindowManager.LayoutParams.FLAG_SECURE |
| iOS | 11.0+ | iOS 13+ uses setSecure:; earlier iOS uses overlays and observers |
Installation
- Install via npm or yarn:
npm install react-native-screen-blocker
# or
yarn add react-native-screen-blocker- For iOS, install CocoaPods dependencies:
cd ios && pod install && cd ..- For React Native < 0.60, link manually:
react-native link react-native-screen-blockerUsage
Import the module
import { enableScreenBlock, disableScreenBlock } from 'react-native-screen-blocker';Enable Screen Block
Call early in the app lifecycle.
enableScreenBlock();Disable Screen Block
disableScreenBlock();API
| Method | Description | Returns |
|-----------|-----------------------------------------------------|---------------|
| enableScreenBlock() | Enables screenshot and screen recording protection | Promise<void> |
| disableScreenBlock() | Disables protection and allows screenshots/recordings | Promise<void> |
Example
import React, { useEffect } from 'react';
import { enableScreenBlock, disableScreenBlock } from 'react-native-screen-blocker';
export default function App() {
useEffect(() => {
enableScreenBlock();
}, []);
return (
// App JSX
);
}Contact
For questions or support, reach me at: [email protected]
