@capacitor/privacy-screen
The Privacy Screen plugin provides functionality to prevent sensitive information from being visible in app switchers and when leaving an app.
Note: This plugin is supported on Android and iOS platforms only. It is not available for web platforms.
Install
npm install @capacitor/privacy-screen@latest-7
npx cap sync
Platform Notes
Android
FLAG_SECURE Behavior
When the privacy screen is enabled, the plugin automatically applies Android's FLAG_SECURE flag to the window. This provides comprehensive content protection:
- Screenshot Prevention: Prevents users from taking screenshots or screen recordings of your app
- App Switcher/Recent Apps: When the app appears in the recent apps view, FLAG_SECURE causes the system to show either a black screen or the last frame captured before FLAG_SECURE was applied (typically blank)
- Non-Secure Display Protection: Prevents the window content from appearing on non-secure displays such as TVs, projectors, or screen mirroring to untrusted devices
- Live View Protection: In cases where FLAG_SECURE doesn't fully protect content (such as with gesture navigation or live view fragments that can persist for minutes), the plugin displays a temporary privacy screen overlay. This overlay can be configured via
dimBackground(shows a dim overlay) or shows the splash screen by default.
Navigation Method Differences
The privacy screen behavior varies depending on how the user navigates away from the app:
- Recent Apps Button/Gesture: The privacy dialog displays as configured when viewing the app switcher
- Home Button: FLAG_SECURE ensures content protection in the app switcher snapshot
- Activity Background Events: Controlled separately via
privacyModeOnActivityHiddenfor scenarios like biometric prompts