npm.io
1.0.4 • Published 2 years ago

rn-screenshot-detect

Licence
MIT
Version
1.0.4
Deps
0
Size
22 kB
Vulns
0
Weekly
0

rn-screenshot-detect

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.

Installation

yarn add rn-screenshot-detect

Usage

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]);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Keywords