Expo 仅支持 Dev Client,Expo Go 无法使用;React Native 低于 0.70 需改用 v1.9.17;Android 需在 build.gradle 配置 missingDimensionStrategy,低于 14 的截图检测需改用 callbackTiramisu 并声明 READ_MEDIA_IMAGES
react-native-capture-protection
wn-naMIT活跃维护React Native 防截屏与录屏检测库,可拦截并识别截图、屏幕录制和应用切换,兼容 Expo 与 CLI,用于提升移动端隐私安全。
🛡️ A React Native library to prevent and detect for screen capture, screenshots and app switcher for enhanced security. Fully compatible with both Expo and CLI.
npm install react-native-capture-protection
cd ios && pod installREADME 未说明
React Native 防截屏库,阻止并检测截图、录屏和后台预览,兼顾 Expo 与 CLI
React Native 防截屏与录屏检测库,可拦截并识别截图、屏幕录制和应用切换,兼容 Expo 与 CLI,用于提升移动端隐私安全。
核心能力
- 阻止 iOS 与 Android 的截图和录屏
- iOS 额外支持 App Switcher 预览遮挡
- 提供事件监听与 useCaptureProtection Hook
- 可按截图、录屏、后台预览分别开关
- 内置 Jest mock 便于单元测试
容易踩的坑
- v2.4.3最新正式版2026-10-25 · 2026-10-25 12:53 UTC
What's Changed
- fix(ios): add the app switcher cover synchronously by @Manoj201 in https://github.com/wn-na/react-native-capture-protection/pull/140
New Contributors
- @Manoj201 made their first contribution in https://github.com/wn-na/react-native-capture-protection/pull/140
Full Changelog: https://github.com/wn-na/react-native-capture-protection/compare/v2.4.2...v2.4.3
- v2.4.22026-10-06 · 2026-10-06 13:19 UTC
查看更新说明
What's Changed
- Clarify different dimensions in README.md for Android below 14 by @tobiasvandriessel-infi in https://github.com/wn-na/react-native-capture-protection/pull/129
- fix(android): skip explicit Kotlin plugin when AGP registers the kotlin extension by @gabrieldonadel in https://github.com/wn-na/react-native-capture-protection/pull/134
- Add Swift Package Manager manifest (React Native 0.87 SwiftPM) by @serpixel in https://github.com/wn-na/react-native-capture-protection/pull/137
- fix: ios 27 scene delegate by @wn-na in https://github.com/wn-na/react-native-capture-protection/pull/138
New Contributors
- @tobiasvandriessel-infi made their first contribution in https://github.com/wn-na/react-native-capture-protection/pull/129
- @gabrieldonadel made their first contribution in https://github.com/wn-na/react-native-capture-protection/pull/134
- @serpixel made their first contribution in https://github.com/wn-na/react-native-capture-protection/pull/137
Full Changelog: https://github.com/wn-na/react-native-capture-protection/compare/v2.4.1...v2.4.2
- v2.4.12026-01-24 · 2026-01-24 09:41 UTC
查看更新说明
What's Changed
- fix: fix build web by @wn-na in https://github.com/wn-na/react-native-capture-protection/pull/126
Full Changelog: https://github.com/wn-na/react-native-capture-protection/compare/v2.4.0...v2.4.1
- v2.4.02025-12-26 · 2025-12-26 04:59 UTC
查看更新说明
What's Changed
- fix: Modify productFlavors description by @wn-na in https://github.com/wn-na/react-native-capture-protection/pull/123
Full Changelog: https://github.com/wn-na/react-native-capture-protection/compare/v2.3.5...v2.4.0
- v2.3.42025-11-24 · 2025-11-24 13:18 UTC
查看更新说明
What's Changed
- fix: export mock file by @wn-na in https://github.com/wn-na/react-native-capture-protection/pull/119
Full Changelog: https://github.com/wn-na/react-native-capture-protection/compare/v2.3.3...v2.3.4
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
🛡️ react-native-capture-protection
A React Native library to prevent screen capture, screenshots, and app switcher previews—providing enhanced security for your app.
Fully compatible with React Native CLI and Expo (Dev Client only).
📸 Screenshots
| Screenshot Protection | App Switcher Protection |
|---|---|
![]() |
✨ Features
- 🔒 iOS: Screenshot, Screen Recording & App Switcher protection
- 🔒 Android: Screenshot & Screen Recording protection
- 📡 Event listeners for capture events
- 🧩 Hooks & Provider support
- 📱 Android 14 support
🚀 Installation
⚠️ Using React Native < 0.70?
The latest v2.x version may not be compatible with versions below 0.70.
It is recommended to usev1.9.17for better stability with older React Native projects.
Using npm
npm install react-native-capture-protection
Using yarn
yarn add react-native-capture-protection
Using with Expo
⚠️ Expo Dev Client only This library includes native code, so it does not work with Expo Go. You must use a custom dev client.
npx expo install react-native-capture-protection
🔧 iOS Setup
If you're developing for iOS, don't forget to install CocoaPods dependencies after installing the package.
cd ios && pod install
⚙️ Android Configuration (Required)
By default, it supports capture prevention, capture permission, and capture detection on Android 14 and above. On Android versions below 14 (Android 10-13), capture prevention and capture permission are supported by default; if you want capture detection support too, please refer to the Capture Detection Before Android 14 (Optional) below.
React Native CLI
add to android/app/build.gradle
defaultConfig {
...
missingDimensionStrategy "react-native-capture-protection", "base"
}
Expo (Dev Client only)
add to app.json
{
...
"plugins": [
...,
[
"react-native-capture-protection",
{
"captureType": "base"
}
]
]
}
Capture Detection Before Android 14 (Optional)
On Android versions below 14 (Android 10-13), capture prevention and capture permission are supported by default and require no more steps. However, if you want capture detection to work on Android versions below 14, please configure the settings as follows (it detects screen captures using the sensitive READ_MEDIA_IMAGES permission):
Google Play Store Policy (READ_MEDIA_IMAGES)
If publishing to the Play Store, explain the usage of READ_MEDIA_IMAGES like this:
Used by the application to detect screenshots, by checking for screenshot files in the user’s media storage.
React Native CLI
add to android/app/build.gradle
defaultConfig {
...
missingDimensionStrategy "react-native-capture-protection", "callbackTiramisu"
}
Expo (Dev Client only)
add to app.json
{
...
"plugins": [
...,
[
"react-native-capture-protection",
{
"captureType": "callbackTiramisu"
}
]
]
}
📦 Usage
import {
CaptureProtection,
useCaptureProtection,
CaptureEventType
} from 'react-native-capture-protection';
const Component = () => {
const { protectionStatus, status } = useCaptureProtection();
React.useEffect(() => {
// Prevent all capture events
CaptureProtection.prevent();
// Or prevent specific events
CaptureProtection.prevent({
screenshot: true,
record: true,
appSwitcher: true
});
}, []);
React.useEffect(() => {
// Check if any capture is prevented
console.log('Prevent Status:', protectionStatus);
// Check current protection status
console.log('Protection Status:', status);
}, [protectionStatus, status]);
// Allow all capture events
const onAllow = async () => {
await CaptureProtection.allow();
};
// Allow specific events
const onAllowSpecific = async () => {
await CaptureProtection.allow({
screenshot: true,
record: false,
appSwitcher: true
});
};
// Check if screen is being recorded
const checkRecording = async () => {
const isRecording = await CaptureProtection.isScreenRecording();
console.log('Is Recording:', isRecording);
};
return (
// Your component JSX
);
};
Jest integration
With Jest Setup
- Add to your
jest.config.js:
module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
};
- Create jest.setup.js:
jest.mock('react-native-capture-protection', () =>
require('react-native-capture-protection/jest/capture-protection-mock')
);
Overriding mock
import { CaptureProtection } from "react-native-capture-protection/jest/capture-protection-mock";
...
test("prevent is called", async () => {
await CaptureProtection.prevent();
expect(CaptureProtection.prevent).toHaveBeenCalled();
});
📚 Documentation
🧪 Methods – All available API methods
📘 Types – Type definitions and interfaces
🛠 Migration Guide – From v1.x to v2.x
🤝 Contributing
See CONTRIBUTING.md for details on contributing to this project.
📄 License
MIT
Made with create-react-native-library
