1.0.6 • Published 3 years ago

react-native-screenshot-prevention v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm.io

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