react-native-screenshot-prevention
v1.0.6
Published
A implementation of FLAG_SECURE in Android and ScreenShieldKit to IOS for prevent screenshots
Downloads
578
Maintainers
Readme
react-native-screenshot-prevention
A simple implementation of FLAG_SECURE in Android and UIApplicationUserDidTakeScreenshotNotification IOS for prevent screenshots
Installation
npm install react-native-screenshot-prevention
iOS
cd ios && pod install
Usage
import { allowScreenCapture, preventScreenCapture, addScreenshotListener } from "react-native-screenshot-prevention";
// Enable screenshot (android only)
allowScreenCapture()
//Disable screenshot (android only)
preventScreenCapture()
useEffect(() => {
// Function to execute when user did a screenshot(ios only)
const onScreenshot = () => {
console.log("Hey, screenshot detected!")
}
// Its important have an "unsubscribe" to remove listener from screen is dismounted
const unsubscribe = addScreenshotListener(onScreenshot);
return () => {
unsubscribe()
}
}, [])
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT