forked from blend/react-native-screenshot-detector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.android.js
More file actions
33 lines (26 loc) · 918 Bytes
/
index.android.js
File metadata and controls
33 lines (26 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { NativeModules } from 'react-native'
const LINKING_ERROR =
`@exodus/react-native-screenshot-detector: native module 'RNScreenshotDetector' is not linked. ` +
`Rebuild the Android app from source so the native module is bundled. ` +
`Refusing to no-op for security-critical screenshot protection.`
const { RNScreenshotDetector } = NativeModules
const unsubscribe = () => {}
const subscribe = () => unsubscribe
const disableScreenshots = () => {
if (!RNScreenshotDetector || !RNScreenshotDetector.disableScreenshots) {
throw new Error(LINKING_ERROR)
}
RNScreenshotDetector.disableScreenshots()
}
const enableScreenshots = () => {
if (!RNScreenshotDetector || !RNScreenshotDetector.enableScreenshots) {
throw new Error(LINKING_ERROR)
}
RNScreenshotDetector.enableScreenshots()
}
const Detector = {
subscribe,
disableScreenshots,
enableScreenshots,
}
export default Detector