# react-native-screenshot-detect

> A tool for detecting ios screenshots on iOS

Latest version **1.1.0** (published 2019-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-screenshot-detect
pnpm add react-native-screenshot-detect
yarn add react-native-screenshot-detect
bun add react-native-screenshot-detect
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-12-04 |
| First published | 2019-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 185.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | gcarling & iamacup + others |
| Maintainers | iamacup |
| Keywords | react-native |

## Links

- npm: https://www.npmjs.com/package/react-native-screenshot-detect
- Repository: https://github.com/iamacup/react-native-screenshot-detect
- Issues: https://github.com/iamacup/react-native-screenshot-detect/issues
- npm.io page: https://npm.io/package/react-native-screenshot-detect

## Recent versions

- 1.1.0 (latest) — 2019-12-04

## README

# react-native-screenshot-detect

# This is a drop-in replacement for react-native-screenshot-detector with fixes for react-native > 0.60.0

Note: this project is designed to work with the newer version of React Native library imports, i.e. React Native >= 0.40.0, and will only work on iOS as Android does not provide the underlying functionality needed to track screenshots.

## Getting started

React Native < 0.60.0

`$ npm install react-native-screenshot-detect`

`$ react-native link react-native-screenshot-detect`

React Native >= 0.60.0

`$ npm install react-native-screenshot-detect`

## Usage

Update the AppDelegate.m file to include the following:

# iOS
```objectivec
#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
```javascript
import * as ScreenshotDetector from 'react-native-screenshot-detect';

// Subscribe callback to screenshots:
this.eventEmitter = ScreenshotDetector.subscribe(function() { ... });

// Unsubscribe later (a good place would be componentWillUnmount)
ScreenshotDetector.unsubscribe(this.eventEmitter);
```

---
_Source: https://npm.io/package/react-native-screenshot-detect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
