@ivan.ng/react-native-screenshot-detector
v0.1.0
Published
Detect device screenshots (iOS & Android) and screen recording (iOS) in React Native.
Maintainers
Readme
react-native-screenshot-detector
Detect when the user takes a screenshot (iOS & Android) and when the screen is being recorded / captured (iOS only) in React Native — via a simple listener API.
Privacy-friendly: the library only tells you that a screenshot or capture happened. It never accesses or exposes the screenshot image.
Features
- 📸 Screenshot detection on iOS and Android
- 🔴 Screen recording / capture detection on iOS (start & stop)
- 🧩 Built as a React Native Turbo Native Module (New Architecture)
- 🔔 Simple subscription API with automatic cleanup
- 🟦 Written in TypeScript with full type definitions
Platform support
| Capability | iOS | Android | | ----------------------------------- | ---------- | ----------------------- | | Screenshot detection | ✅ iOS 15+ | ✅ Android 14+ (API 34) | | Screen recording/capture detection | ✅ iOS 15+ | ❌ Not supported |
Android has no public API to detect that a third-party app is recording the
screen, so recording detection is iOS only. On Android the recording APIs are
safe no-ops (isScreenCaptureSupported is false).
Requirements
- React Native 0.81+ with the New Architecture enabled (the default in 0.81)
- iOS 15.0+
- Android 14+ (API level 34) at runtime for screenshot detection
Installation
npm install @ivan.ng/react-native-screenshot-detectoror
yarn add @ivan.ng/react-native-screenshot-detectoriOS
cd ios && pod installAndroid
No manual steps. The library declares the required
android.permission.DETECT_SCREEN_CAPTURE permission and merges it into your app
automatically. It is a normal (non-runtime) permission — the user is not prompted.
Screenshot detection uses the official Activity.registerScreenCaptureCallback
API, which only fires while your app is in the foreground.
Usage
import { useEffect } from 'react';
import { Alert } from 'react-native';
import {
addScreenshotListener,
addScreenCaptureListener,
isScreenBeingCaptured,
isScreenCaptureSupported,
} from '@ivan.ng/react-native-screenshot-detector';
function useScreenshotGuard() {
useEffect(() => {
const screenshotSub = addScreenshotListener(() => {
Alert.alert('Screenshot detected', 'Please respect content privacy.');
});
// iOS only — never fires on Android.
const captureSub = addScreenCaptureListener(({ isCapturing }) => {
console.log('Screen capture is now', isCapturing ? 'ON' : 'OFF');
});
return () => {
screenshotSub.remove();
captureSub.remove();
};
}, []);
}
// One-off query (iOS reflects UIScreen.isCaptured; Android resolves false)
const capturing = await isScreenBeingCaptured();
// Feature-detect at runtime
if (isScreenCaptureSupported) {
// safe to rely on capture events
}API
addScreenshotListener(listener: () => void): Subscription
Calls listener whenever the user takes a screenshot (iOS & Android). Returns a
subscription — call .remove() to stop listening.
addScreenCaptureListener(listener: (event: { isCapturing: boolean }) => void): Subscription
Calls listener when screen recording/capture starts or stops. iOS only
(never fires on Android). Returns a subscription with .remove().
isScreenBeingCaptured(): Promise<boolean>
Resolves whether the screen is currently being captured. Reflects
UIScreen.isCaptured on iOS; resolves false on Android.
isScreenCaptureSupported: boolean
true on iOS, false on Android.
How it works
- iOS: observes
UIApplication.userDidTakeScreenshotNotificationfor screenshots andUIScreen.capturedDidChangeNotification/UIScreen.isCapturedfor recording, mirroring, and AirPlay. - Android: registers an
Activity.ScreenCaptureCallbackviaregisterScreenCaptureCallback(API 34+), tied to your activity's lifecycle.
Disclaimer
This library is provided "as is" under the MIT License, without warranty of any kind — you use it at your own risk. You are solely responsible for ensuring your use of screenshot and screen-capture detection complies with all applicable laws, regulations, app-store policies, and privacy requirements. The author accepts no liability for any loss, damage, data leak, hack, or legal consequence arising from its use. By installing or using this library, you agree to accept that risk yourself.
Acceptable use. You agree not to use this library for any unlawful purpose, or in any manner that infringes the privacy, intellectual-property, or other rights of any person. You are solely responsible for how you integrate and use it.
Indemnification. To the fullest extent permitted by law, you agree to indemnify and hold harmless the author from any claims, damages, liabilities, losses, or expenses (including legal fees) arising out of or related to your use of this library or your violation of any law or third-party right.
License
MIT © 2026 ivan-ng-ivan
Made with create-react-native-library
