This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo ScreenCapture
A library that allows you to protect screens in your app from being captured or recorded.
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 API allows third-party apps to perform screen capture or screen sharing (even if the app is in the background).
On Android, the screen capture callback works without additional permissions only for Android 14+. You don't need to request or check permissions for blocking screen capture or using the callback on Android 14+.
If you want to use the screen capture callback on Android 13 or lower, you need to add the READ_MEDIA_IMAGES permission to your AndroidManifest.xml file. You can use the android.permissions key in your app config. See Android permissions for more information.
TheREAD_MEDIA_IMAGESpermission can be added only for apps needing broad access to photos. See Details on Google Play's Photo and Video Permissions policy.
For testing screen capture functionality: On Android Emulator, runadb shell input keyevent 120in a separate terminal to trigger a screenshot. On iOS Simulator, you can trigger screenshots using Device > Trigger Screenshot from the menu bar.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Example: hook
Example: Blocking screen capture imperatively
Example: Callback for screen capture
API
import * as ScreenCapture from 'expo-screen-capture';
Hooks
Check or request permissions necessary for detecting when a screenshot is taken.
This uses both requestPermissionsAsync and getPermissionsAsync to interact with the permissions.
[PermissionResponse | null, RequestPermissionMethod<PermissionResponse>, GetPermissionMethod<PermissionResponse>]Example
const [status, requestPermission] = ScreenCapture.usePermissions();
A React hook to prevent screen capturing for as long as the owner component is mounted.
voidA React hook that listens for screenshots taken while the component is mounted.
voidMethods
Re-allows the user to screen record or screenshot your app. If you haven't called
preventScreenCapture() yet, this method does nothing.
Promise<void>Disables the privacy protection overlay that was previously enabled with enableAppSwitcherProtectionAsync.
Promise<void>Enables a privacy protection blur overlay that hides sensitive content when the app is not in focus. The overlay applies a customizable blur effect when the app is in the app switcher, background, or during interruptions (calls, Siri, Control Center, etc.), and automatically removes it when the app becomes active again.
This provides visual privacy protection by preventing sensitive app content from being visible in:
- App switcher previews
- Background app snapshots
- Screenshots taken during inactive states
For Android, app switcher protection is automatically provided by preventScreenCaptureAsync()
using the FLAG_SECURE window flag, which shows a blank screen in the recent apps preview.
Promise<void>Checks user's permissions for detecting when a screenshot is taken.
Only Android requires additional permissions to detect screenshots. On iOS devices, this method will always resolve to a
grantedpermission response.
Promise<PermissionResponse>A promise that resolves to a PermissionResponse object.
Returns whether the Screen Capture API is available on the current device.
Promise<boolean>A promise that resolves to a boolean indicating whether the Screen Capture API is available on the current
device.
Prevents screenshots and screen recordings until allowScreenCaptureAsync is called or the app is restarted. If you are
already preventing screen capture, this method does nothing (unless you pass a new and unique key).
On iOS, this prevents screen recordings and screenshots, and is only available on iOS 11+ (recordings) and iOS 13+ (screenshots). On older iOS versions, this method does nothing.
Promise<void>Asks the user to grant permissions necessary for detecting when a screenshot is taken.
Only Android requires additional permissions to detect screenshots. On iOS devices, this method will always resolve to a
grantedpermission response.
Promise<PermissionResponse>A promise that resolves to a PermissionResponse object.
Event subscriptions
Adds a listener that will fire whenever the user takes a screenshot while the app is foregrounded.
Permission requirements for this method depend on your device’s Android version:
- Before Android 13: Requires
READ_EXTERNAL_STORAGE. - Android 13: Switches to
READ_MEDIA_IMAGES. - Post-Android 13: No additional permissions required.
You can request the appropriate permissions by using
MediaLibrary.requestPermissionsAsync().
EventSubscriptionA Subscription object that you can use to unregister the listener, either by calling
remove() or passing it to removeScreenshotListener.
Deprecated: use subscription.remove() instead.
Removes the subscription you provide, so that you are no longer listening for screenshots.
voidA React hook that listens for screenshots taken while the component is mounted.
voidInterfaces
A subscription object that allows to conveniently remove an event listener from the emitter.
Types
Literal type: union
Acceptable values are: PermissionHookBehavior | Options