Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blend/react-native-screenshot-detector
Screenshot detection in React Native (iOS only)
https://github.com/blend/react-native-screenshot-detector
react-native screenshot
Last synced: 11 days ago
JSON representation
Screenshot detection in React Native (iOS only)
- Host: GitHub
- URL: https://github.com/blend/react-native-screenshot-detector
- Owner: blend
- License: mit
- Created: 2017-01-12T20:43:49.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-16T16:29:05.000Z (almost 2 years ago)
- Last Synced: 2024-03-26T12:59:01.637Z (11 months ago)
- Topics: react-native, screenshot
- Language: Objective-C
- Size: 106 KB
- Stars: 54
- Watchers: 8
- Forks: 34
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-screenshot-detector
Note: this project is designed to work with the newer version of React Native library imports, i.e. React Native >= 0.40.0
## Getting started
`$ npm install react-native-screenshot-detector --save`
`$ react-native link react-native-screenshot-detector`
## Usage
# iOS
```objectivec
#import- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ... setup code// Somewhere React Native will have placed something like
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL...]// Somewhere below this you can setup the screenshot detector to listen for events
RNScreenshotDetector* screenshotDetector = [[RNScreenshotDetector alloc] init];
[screenshotDetector setupAndListen:rootView.bridge];
}
```# In JS
```javascript
import * as ScreenshotDetector from 'react-native-screenshot-detector';// Subscribe callback to screenshots:
this.eventEmitter = ScreenshotDetector.subscribe(function() { ... });// Unsubscribe later (a good place would be componentWillUnmount)
ScreenshotDetector.unsubscribe(this.eventEmitter);
```