{"id":28822873,"url":"https://github.com/wn-na/react-native-capture-protection","last_synced_at":"2025-12-26T08:03:34.454Z","repository":{"id":64354142,"uuid":"573223039","full_name":"wn-na/react-native-capture-protection","owner":"wn-na","description":"🛡️ 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.","archived":false,"fork":false,"pushed_at":"2025-06-16T11:41:12.000Z","size":841,"stargazers_count":191,"open_issues_count":2,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-18T20:49:41.743Z","etag":null,"topics":["android","app-switcher","detector","expo","ios","mobile-security","privacy","react-native","screen-capture","screenrecord","screenshot","screenshot-protection","security"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-native-capture-protection","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wn-na.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"buy_me_a_coffee":"arang"}},"created_at":"2022-12-02T00:49:58.000Z","updated_at":"2025-06-18T18:47:37.000Z","dependencies_parsed_at":"2024-05-22T03:42:47.771Z","dependency_job_id":"b1622070-9ad1-403f-91d8-a3f9fdc0570f","html_url":"https://github.com/wn-na/react-native-capture-protection","commit_stats":null,"previous_names":["wn-na/react-native-capture-protection","0xlethe/react-native-capture-protection"],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/wn-na/react-native-capture-protection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wn-na%2Freact-native-capture-protection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wn-na%2Freact-native-capture-protection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wn-na%2Freact-native-capture-protection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wn-na%2Freact-native-capture-protection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wn-na","download_url":"https://codeload.github.com/wn-na/react-native-capture-protection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wn-na%2Freact-native-capture-protection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260632990,"owners_count":23039352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","app-switcher","detector","expo","ios","mobile-security","privacy","react-native","screen-capture","screenrecord","screenshot","screenshot-protection","security"],"created_at":"2025-06-19T00:01:22.813Z","updated_at":"2025-12-26T08:03:34.447Z","avatar_url":"https://github.com/wn-na.png","language":"Swift","funding_links":["https://buymeacoffee.com/arang"],"categories":[],"sub_categories":[],"readme":"# 🛡️ react-native-capture-protection\n\nA React Native library to **prevent screen capture, screenshots, and app switcher previews**—providing enhanced security for your app.  \nFully compatible with **React Native CLI** and **Expo (Dev Client only)**.\n\n---\n\n## 📸 Screenshots\n\n| Screenshot Protection                                                                                                      | App Switcher Protection                                                                                                        |\n| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| ![Screen Recording](https://user-images.githubusercontent.com/37437842/206644553-e4c3f2bc-b624-47ac-a005-132199e049b2.gif) | ![App Switcher](https://github.com/wn-na/react-native-capture-protection/assets/37437842/ac98e942-8dba-4e5d-9f23-fa10f946b26b) |\n\n---\n\n## ✨ Features\n\n- 🔒 iOS: Screenshot, Screen Recording \u0026 App Switcher protection\n- 🔒 Android: Screenshot \u0026 Screen Recording protection\n- 📡 Event listeners for capture events\n- 🧩 Hooks \u0026 Provider support\n- 📱 Android 14 support\n\n---\n\n## 🚀 Installation\n\n\u003e ⚠️ **Using React Native \u003c 0.70?**  \n\u003e The latest v2.x version may not be compatible with versions below 0.70.  \n\u003e It is recommended to use [`v1.9.17`](https://github.com/wn-na/react-native-capture-protection/releases/tag/v1.9.17) for better stability with older React Native projects.\n\n### Using npm\n\n```sh\nnpm install react-native-capture-protection\n```\n\n### Using yarn\n\n```sh\nyarn add react-native-capture-protection\n```\n\n### Using with Expo\n\n\u003e ⚠️ Expo Dev Client only\n\u003e This library includes native code, so it does not work with Expo Go. You must use a custom dev client.\n\n```sh\nnpx expo install react-native-capture-protection\n```\n\n### 🔧 iOS Setup\n\nIf you're developing for iOS, don't forget to install CocoaPods dependencies after installing the package.\n\n```sh\ncd ios \u0026\u0026 pod install\n```\n\n## ⚙️ Android Configuration (Required)\n\nBy default, it supports capture prevention, capture permission, and capture detection on Android 14 and above.\nIf you want capture detection(not prevent, only listener) support for versions below 14 (Android 10–13), please refer to the [Support Below Android 14, Capture Detection (Optional)](#support-below-android-14-capture-detection-optional) below.\n\n### **React Native CLI**\n\nadd to `android/app/build.gradle`\n\n```gradle\ndefaultConfig {\n    ...\n    missingDimensionStrategy \"react-native-capture-protection\", \"base\"\n}\n```\n\n### **Expo (Dev Client only)**\n\nadd to `app.json`\n\n```json\n{\n  ...\n  \"plugins\": [\n    ...,\n    [\n      \"react-native-capture-protection\",\n      {\n        \"captureType\": \"base\"\n      }\n    ]\n  ]\n}\n```\n\n## Support Below Android 14, Capture Detection (Optional)\n\nOn Android versions below 14, it detects screen captures using the sensitive READ_MEDIA_IMAGES permission.\nIf you want detection to work on Android versions below 14, please configure the settings as follows.\n\n### Google Play Store Policy (READ_MEDIA_IMAGES)\n\nIf publishing to the Play Store, explain the usage of READ_MEDIA_IMAGES like this:\n\n```\nUsed by the application to detect screenshots, by checking for screenshot files in the user’s media storage.\n```\n\n### **React Native CLI**\n\nadd to `android/app/build.gradle`\n\n```gradle\ndefaultConfig {\n    ...\n    missingDimensionStrategy \"react-native-capture-protection\", \"callbackTiramisu\"\n}\n```\n\n### **Expo (Dev Client only)**\n\nadd to `app.json`\n\n```json\n{\n  ...\n  \"plugins\": [\n    ...,\n    [\n      \"react-native-capture-protection\",\n      {\n        \"captureType\": \"callbackTiramisu\"\n      }\n    ]\n  ]\n}\n```\n\n## 📦 Usage\n\n```js\nimport {\n  CaptureProtection,\n  useCaptureProtection,\n  CaptureEventType\n} from 'react-native-capture-protection';\n\nconst Component = () =\u003e {\n  const { protectionStatus, status } = useCaptureProtection();\n\n  React.useEffect(() =\u003e {\n    // Prevent all capture events\n    CaptureProtection.prevent();\n\n    // Or prevent specific events\n    CaptureProtection.prevent({\n      screenshot: true,\n      record: true,\n      appSwitcher: true\n    });\n  }, []);\n\n  React.useEffect(() =\u003e {\n    // Check if any capture is prevented\n    console.log('Prevent Status:', protectionStatus);\n\n    // Check current protection status\n    console.log('Protection Status:', status);\n  }, [protectionStatus, status]);\n\n  // Allow all capture events\n  const onAllow = async () =\u003e {\n    await CaptureProtection.allow();\n  };\n\n  // Allow specific events\n  const onAllowSpecific = async () =\u003e {\n    await CaptureProtection.allow({\n      screenshot: true,\n      record: false,\n      appSwitcher: true\n    });\n  };\n\n  // Check if screen is being recorded\n  const checkRecording = async () =\u003e {\n    const isRecording = await CaptureProtection.isScreenRecording();\n    console.log('Is Recording:', isRecording);\n  };\n\n  return (\n    // Your component JSX\n  );\n};\n```\n\n## Jest integration\n\n### With Jest Setup\n\n1. Add to your `jest.config.js`:\n\n```javascript\nmodule.exports = {\n  setupFilesAfterEnv: ['\u003crootDir\u003e/jest.setup.js'],\n};\n```\n\n2. Create jest.setup.js:\n\n```javascript\njest.mock('react-native-capture-protection', () =\u003e\n  require('react-native-capture-protection/jest/capture-protection-mock')\n);\n```\n\n### Overriding mock\n\n```typescript\nimport { CaptureProtection } from \"react-native-capture-protection/jest/capture-protection-mock\";\n\n...\n\n    test(\"prevent is called\", async () =\u003e {\n        await CaptureProtection.prevent();\n        expect(CaptureProtection.prevent).toHaveBeenCalled();\n    });\n\n```\n\n## 📚 Documentation\n\n🧪 [Methods](./docs/method.md) – All available API methods\n\n📘 [Types](./docs/type.md) – Type definitions and interfaces\n\n🛠 [Migration Guide](./docs/MIGRATION.md) – From v1.x to v2.x\n\n## 🤝 Contributing\n\nSee CONTRIBUTING.md for details on contributing to this project.\n\n## 📄 License\n\nMIT\n\n---\n\nMade with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwn-na%2Freact-native-capture-protection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwn-na%2Freact-native-capture-protection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwn-na%2Freact-native-capture-protection/lists"}