- ✅ Screenshot detection
- ✅ Screen recording detection
- ✅ Screenshot prevention (Android)
- ✅ Screen recording prevention (Android)
- ✅ Secure view (
FLAG_SECURE) on Android - ✅ Screen capture status detection on iOS
Installation
npm install react-native-capture-protectionor
yarn add react-native-capture-protectioniOS
cd ios
pod installEnable Protection
import CaptureProtection from 'react-native-capture-protection';
await CaptureProtection.prevent();Disable
await CaptureProtection.allow();Detect Screenshots
import { useEffect } from 'react';
import CaptureProtection from 'react-native-capture-protection';
useEffect(() => {
const subscription = CaptureProtection.addScreenshotListener(() => {
console.log('Screenshot taken');
});
return () => subscription.remove();
}, []);Detect Screen Recording
useEffect(() => {
const subscription =
CaptureProtection.addScreenRecordingListener((isRecording) => {
console.log(isRecording);
});
return () => subscription.remove();
}, []);
Check Current Recording Status
const recording = await CaptureProtection.isScreenRecording();Enable Only on Sensitive Screens
import { useFocusEffect } from '@react-navigation/native';
import { useCallback } from 'react';
import CaptureProtection from 'react-native-capture-protection';
useFocusEffect(
useCallback(() => {
CaptureProtection.prevent();
return () => {
CaptureProtection.allow();
};
}, [])
);This protects only the current screen.
Platform Support
| Feature | Android | iOS |
|---|---|---|
| Prevent screenshots | ✅ | ❌ |
| Detect screenshots | ✅ | ✅ |
| Detect screen recording | ✅ | ✅ |
| Prevent screen recording | ✅ (FLAG_SECURE) | ❌ |
| Recent apps preview protection | ✅ | Limited (requires app-specific UI handling) |
Notes
- Android:
prevent()usesFLAG_SECURE, which blocks screenshots, screen recording, and protects the app preview in the recent apps screen. - iOS: Apple does not allow apps to prevent screenshots. The library can only detect screenshots after they occur and notify you when screen recording is active.