0.2.1 • Published 7 years ago

react-native-screenshot-observer v0.2.1

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

Installation

Installation can be done through npm:

$ npm i react-native-screenshot-observer --save
$ react-native link react-native-screenshot-observer

Usage

iOS截屏手势捕获通知 支持react native 0.40+

import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import {
  View,
  StyleSheet,
  Text,
  TouchableOpacity,
  NativeModules,
  DeviceEventEmitter,
} from 'react-native';

class App extends React.Component {
  componentWillUnmount () {
    this.screenshotObserver.remove();
  }

  render() {
    return (
      const RNScreenshotNotification = NativeModules.RNScreenshotNotification;

      this.screenshotObserver = DeviceEventEmitter.addListener('ScreenshotObserver', (data) => { this.setState({ screenShotUri: data.imagePath }) });
      RNScreenshotNotification.addObserverScreenshot();
    )
  }
}