ahmadyusri / react-native-screenshot-detector

React Native Screenshot Detector

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy From https://github.com/blend/react-native-screenshot-detector

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 git://github.com/ahmadyusri/react-native-screenshot-detector.git#master --save

$ cd ios && pod install && cd ../

Usage

iOS

#import <RNScreenshotDetector/RNScreenshotDetector.h>

- (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

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

About

React Native Screenshot Detector

License:MIT License


Languages

Language:Objective-C 46.2%Language:JavaScript 25.0%Language:Starlark 12.2%Language:Java 10.5%Language:Ruby 6.1%