This module is used to prevent screen shots and detect screen shots.
The screen shot detection will only work on iOS, as Android does not provide the underlying functionality needed to track screenshots. But on Android, we can prevent user screen shots by using the forbid()
method.
yarn add rn-screenshot-detect
import { allow, forbid, useScreenshotDeterrent } from 'rn-screenshot-detect';
// ...
const [subscribe] = useScreenshotDeterrent();
React.useEffect(() => {
forbid(); // work on android
const unsubscribe = subscribe(() => {
console.warn('user took screen shots');
});
return () => {
allow(); // work on android
unsubscribe();
};
}, [subscribe]);
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library