Git Product home page Git Product logo

react-native-screenshot-detector's Introduction

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

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

react-native-screenshot-detector's People

Contributors

gcarling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-screenshot-detector's Issues

works in debug build but not for release build - ios

posting an issue here as there was no issues section on the forked lib @iamacup/react-native-screenshot-detect

This lib works great on debug configuration, but for release configuration, detection does not work.
Is it possible to get it working for release config as well?

rn 0.62.2

No idea what I'm doing

I can't really figure out how to get this to work on ios. Taking screenshot does nothing. Is this correct? cc/ @gcarling

componentDidMount() {
    console.log('RNScreenshotDetector',RNScreenshotDetector);

    RNScreenshotDetector.subscribe(function(){
      alert('screenshot taken!')
      console.log('SUBSCRIBE');
    });

  }

Publish npm package

react-native-screenshot-detector isn't available on npm, so $ npm install react-native-screenshot-detector --save doesn't seem to work. There is a way to add it to package.json as "react-native-screenshot-detector": "git://github.com:blendlabs/react-native-screenshot-detector.git", but installing a package would be more convenient and robust (in terms of further updates).

Simulator

Hello there, can I test it on a simulator?

Apparently, I cannot, it doesn't detect the Screenshot.

Thank you.

Function not response

ScreenshotDetector.subscribe(() => {
Alert.alert('Screenshot detected!');
});

There is no response.

react-native version 0.43

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.