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.
npm install @capacitor/privacy-screen
npx cap sync
The privacy screen behavior on Android varies depending on the navigation method used:
- When using gesture navigation or the recent apps button, the privacy screen will display as configured
- When using the home button to exit the app, the system must fall back to using
FLAG_SECURE
as it's the only way to prevent content visibility in this scenario
enable(config?: PrivacyScreenConfig | undefined) => Promise<{ success: boolean; }>
Enable privacy screen protection
Param | Type | Description |
---|---|---|
config |
PrivacyScreenConfig |
Optional configuration for platform-specific behavior |
Returns: Promise<{ success: boolean; }>
disable() => Promise<{ success: boolean; }>
Disable privacy screen protection
Returns: Promise<{ success: boolean; }>
isEnabled() => Promise<{ enabled: boolean; }>
Check if privacy screen is currently enabled
Returns: Promise<{ enabled: boolean; }>
Prop | Type |
---|---|
android |
{ dimBackground?: boolean; preventScreenshots?: boolean; } |
ios |
{ blurEffect?: 'light' | 'dark' | 'none'; } |