---
title: ScreenCapture
description: A library that allows you to protect screens in your app from being captured or recorded.
sourceCodeUrl: https://github.com/expo/expo/tree/sdk-51/packages/expo-screen-capture
packageName: expo-screen-capture
platforms: ["android", "ios"]
---
`expo-screen-capture` allows you to protect screens in your app from being captured or recorded, as well as be notified if a screenshot is taken while your app is foregrounded. The two most common reasons you may want to prevent screen capture are:
- If a screen is displaying sensitive information (password, credit card data, and so on)
- You are displaying paid content that you don't want to be recorded and shared
This is especially important on Android since the [`android.media.projection`](https://developer.android.com/about/versions/android-5.0.html#ScreenCapture) API allows third-party apps to perform screen capture or screen sharing (even if the app is in the background).
> **warning** Currently, taking screenshots on iOS cannot be prevented. This is due to underlying OS limitations.
> **important** For testing screen capture functionality: On Android Emulator, run `adb shell input keyevent 120` in a separate terminal to trigger a screenshot. On iOS Simulator, you can trigger screenshots using **Device** > **Trigger Screenshot** from the menu bar.
## Installation
## Usage
### Example: hook
```jsx
usePreventScreenCapture();
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>As long as this component is mounted, this screen is unrecordable!</Text>
</View>
);
}
```
### Example: functions
```jsx
const hasPermissions = async () => {
const { status } = await ScreenCapture.requestPermissionsAsync();
return status === 'granted';
};
useEffect(() => {
let subscription;
const addListenerAsync = async () => {
if (await hasPermissions()) {
subscription = ScreenCapture.addScreenshotListener(() => {
alert('Thanks for screenshotting my beautiful app 😊');
});
} else {
console.error('Permissions needed to subscribe to screenshot events are missing!');
}
};
addListenerAsync();
return () => {
subscription?.remove();
};
}, []);
const activate = async () => {
await ScreenCapture.preventScreenCaptureAsync();
};
const deactivate = async () => {
await ScreenCapture.allowScreenCaptureAsync();
};
return (
<View style={styles.container}>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
```
## API
```js
```