Installations
npm install @capacitor-community/privacy-screen
Developer
capacitor-community
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
18.20.4
NPM Version
10.7.0
Statistics
88 Stars
134 Commits
23 Forks
9 Watching
2 Branches
27 Contributors
Updated on 25 Nov 2024
Languages
Swift (49.91%)
Java (21.47%)
TypeScript (17.54%)
Ruby (4.92%)
Objective-C (3.75%)
JavaScript (2.41%)
Total Downloads
Cumulative downloads
Total Downloads
487,474
Last day
-20.2%
1,157
Compared to previous day
Last week
-0.7%
6,982
Compared to previous week
Last month
12.6%
35,779
Compared to previous month
Last year
54.3%
229,566
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Privacy Screen
@capacitor-community/privacy-screen
Capacitor Privacy Screen Plugin
Introduction
⚡️ Capacitor plugin that protects your app from displaying a screenshot in Recents screen/App Switcher.
On Android, this plugin sets the FLAG_SECURE flag to treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.
On iOS, this plugin hides the webview window when the app is no longer active and loses focus (UIApplicationWillResignActiveNotification) so that a gray screen is shown instead. It also prevents screenshots (a black screen will be captured).
Using the Camera Plugin
Disabling screenshots can interfere with plugins that hide the WebView like the Camera plugin. To avoid issues call disable
before using a plugin and then enable
after you are finished.
Maintainers
Maintainer | GitHub | Social |
---|---|---|
Robin Genz | robingenz | @robin_genz |
Installation
npm install @capacitor-community/privacy-screen
npx cap sync
Configuration
These configuration values are available:
Prop | Type | Description | Default | Since |
---|---|---|---|---|
enable | boolean | Configure whether the plugin should be enabled from startup. Only available for Android and iOS. | true | |
imageName | string | Configure whether the plugin should display a custom image from assets instead of a default background gray for the privacy screen. Only available for iOS. | "" | |
contentMode | 'center' | 'scaleToFill' | 'scaleAspectFit' | 'scaleAspectFill' | Configure the content mode of displayed image. Only available for iOS. | "center" | |
preventScreenshots | boolean | Configure whether the plugin should prevent screenshots if enabled. Only available for iOS. | true | 5.2.0 |
Examples
In capacitor.config.json
:
1{ 2 "plugins": { 3 "PrivacyScreen": { 4 "enable": true, 5 "imageName": "Splashscreen", 6 "contentMode": "scaleAspectFit", 7 "preventScreenshots": false 8 } 9 } 10}
In capacitor.config.ts
:
1/// <reference types="@capacitor/privacy-screen" /> 2 3import { CapacitorConfig } from '@capacitor/cli'; 4 5const config: CapacitorConfig = { 6 plugins: { 7 PrivacyScreen: { 8 enable: true, 9 imageName: "Splashscreen", 10 contentMode: "scaleAspectFit", 11 preventScreenshots: false, 12 }, 13 }, 14}; 15 16export default config;
Demo
A working example can be found here: robingenz/capacitor-plugin-demo
Usage
The plugin only needs to be installed. The protection is enabled by default.
However, you have the option to enable/disable the protection:
1import { PrivacyScreen } from '@capacitor-community/privacy-screen'; 2 3const enable = async () => { 4 await PrivacyScreen.enable(); 5}; 6 7const disable = async () => { 8 await PrivacyScreen.disable(); 9};
API
enable()
1enable() => Promise<void>
Enables the privacy screen protection.
Only available for Android and iOS.
Since: 1.1.0
disable()
1disable() => Promise<void>
Disables the privacy screen protection.
Only available for Android and iOS.
Since: 1.1.0
addListener('screenRecordingStarted', ...)
1addListener(eventName: 'screenRecordingStarted', listenerFunc: () => void) => Promise<PluginListenerHandle>
Called when the screen recording is started.
Only available on iOS for now.
Param | Type |
---|---|
eventName | 'screenRecordingStarted' |
listenerFunc | () => void |
Returns: Promise<PluginListenerHandle>
Since: 3.0.2
addListener('screenRecordingStopped', ...)
1addListener(eventName: 'screenRecordingStopped', listenerFunc: () => void) => Promise<PluginListenerHandle>
Called when the screen recording is stopped.
Only available on iOS for now.
Param | Type |
---|---|
eventName | 'screenRecordingStopped' |
listenerFunc | () => void |
Returns: Promise<PluginListenerHandle>
Since: 3.0.2
addListener('screenshotTaken', ...)
1addListener(eventName: 'screenshotTaken', listenerFunc: () => void) => Promise<PluginListenerHandle>
Called when the screenshot is taken.
Only available on iOS for now.
Param | Type |
---|---|
eventName | 'screenshotTaken' |
listenerFunc | () => void |
Returns: Promise<PluginListenerHandle>
Since: 3.2.0
removeAllListeners()
1removeAllListeners() => Promise<void>
Remove all listeners for this plugin.
Since: 3.0.2
Interfaces
PluginListenerHandle
Prop | Type |
---|---|
remove | () => Promise<void> |
Changelog
See CHANGELOG.md.
License
See LICENSE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: android/gradle/wrapper/gradle-wrapper.jar:1
Reason
3 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/lock.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/lock.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/needs-reply.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/capacitor-community/privacy-screen/needs-reply.yml/main?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 2 out of 2 npmCommand dependencies pinned
Reason
Found 11/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/needs-reply-remove.yml:1
- Warn: no topLevel permission defined: .github/workflows/needs-reply.yml:1
- Warn: no topLevel permission defined: .github/workflows/needs-triage.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 12 are checked with a SAST tool
Score
3.7
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to @capacitor-community/privacy-screen
@capacitor-community/in-app-review
Lets you prompt users to submit app store ratings and reviews without leaving your app - using platform native dialogs.
@capacitor/preferences
The Preferences API provides a simple key/value persistent store for lightweight data.
@capacitor-community/screen-brightness
control screen brightness on ios and android
@capacitor-community/keep-awake
Prevent your screen from getting some sleep!