@capgo/capacitor-privacy-screen

中文文档
8.3.14发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4.4万

Protect app content in Android screenshots and obscure the iOS app switcher snapshot.

原始使用文档
文档目录14 节
  1. ➡️ Get started for free
  2. Key features
  3. Documentation
  4. Compatibility
  5. Install
  6. Configuration
  7. Usage
  8. Behavior
  9. API
  10. enable(...)
  11. disable()
  12. isEnabled()
  13. getPluginVersion()
  14. Interfaces

@capgo/capacitor-privacy-screen

Keep sensitive screens private in your Capacitor app: block screenshots and screen recording on Android and hide your content in the iOS app switcher. Built for banking, health and messaging apps.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-privacy-screen in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-privacy-screen to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-privacy-screen for Capacitor apps

Key features

  • Enable and disable: enable() and disable() turn protection on and off at runtime.
  • Android: sets FLAG_SECURE, which blocks screenshots and screen recording, with a configurable overlay in recent apps.
  • iOS: hides app content from the app switcher snapshot with a light or dark blur, or your launch screen.
  • State: isEnabled() reports the current state.
  • Platforms: iOS and Android. A Capacitor port of PrivacyScreenPlugin. Web only tracks the enabled state.

Protect sensitive app content from appearing in Android screenshots and iOS app-switcher previews.

Capgo's Privacy Screen plugin is a Capacitor port of PrivacyScreenPlugin with a modern native implementation for Capacitor 8.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/privacy-screen/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation. Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-privacy-screen` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-privacy-screen
npx cap sync

Configuration

Protection is disabled by default. Enable it on native startup with Capacitor config:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.example.app',
  appName: 'Example',
  webDir: 'dist',
  plugins: {
    PrivacyScreen: {
      enabled: true,
      android: {
        dimBackground: true,
        privacyModeOnActivityHidden: 'splash',
      },
      ios: {
        blurEffect: 'dark',
      },
    },
  },
};

export default config;

Usage

import { PrivacyScreen } from '@capgo/capacitor-privacy-screen';

await PrivacyScreen.enable({
  android: {
    dimBackground: true,
    privacyModeOnActivityHidden: 'splash',
  },
  ios: {
    blurEffect: 'dark',
  },
});

const { enabled } = await PrivacyScreen.isEnabled();

await PrivacyScreen.disable();

await PrivacyScreen.enable();

// Perform a flow where screenshots or previews should be protected.

await PrivacyScreen.disable();

Use JavaScript calls when protection should only apply to specific screens or flows.

Behavior

  • Android uses WindowManager.LayoutParams.FLAG_SECURE, which hides app content from screenshots, screen recording, and the recent apps preview.
  • Android can show a temporary dim or splash overlay for recent-apps and activity-hidden states.
  • iOS places app content in a secure rendering subtree while enabled and adds a temporary overlay while the app resigns active so the app-switcher snapshot does not expose your content, with optional light or dark blur.
  • Web keeps an in-memory enabled flag for API parity, but browsers cannot enforce native privacy-screen behavior.

API

Capacitor API for protecting app content from screenshots, screen recording, and native app-switcher previews.

enable(...)

enable(config?: PrivacyScreenConfig | undefined) => Promise<PrivacyScreenActionResult>

Enables privacy screen protection.

On Android this sets FLAG_SECURE, which also blocks screenshots and screen recording. On iOS this places app content in a secure rendering subtree while enabled and adds an overlay while the app is backgrounded so app content does not appear in the app-switcher snapshot.

ParamTypeDescription
configPrivacyScreenConfigOptional platform-specific behavior.

Returns: Promise<PrivacyScreenActionResult>


disable()

disable() => Promise<PrivacyScreenActionResult>

Disables privacy screen protection.

Use this only when you explicitly want the current screen to remain visible in system previews.

Returns: Promise<PrivacyScreenActionResult>


isEnabled()

isEnabled() => Promise<PrivacyScreenStatus>

Returns the current enabled state.

Returns: Promise<PrivacyScreenStatus>


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Returns the native implementation version marker.

Returns: Promise<PluginVersionResult>


Interfaces

PrivacyScreenActionResult

Result returned when privacy protection is toggled.

PropTypeDescription
successbooleanWhether the native operation completed.

PrivacyScreenConfig

Native startup and runtime configuration for privacy protection.

PropTypeDescriptionDefault
enabledbooleanEnable privacy protection automatically when the native plugin loads. This option is read from Capacitor config only.false
android{ dimBackground?: boolean; preventScreenshots?: boolean; privacyModeOnActivityHidden?: 'none' | 'dim' | 'splash'; }Android-only behavior.
ios{ blurEffect?: 'none' | 'light' | 'dark'; }iOS-only behavior.

PrivacyScreenStatus

Current privacy screen state.

PropTypeDescription
enabledbooleanWhether privacy protection is currently enabled.

PluginVersionResult

Plugin version payload.

PropTypeDescription
versionstringVersion identifier returned by the platform implementation.

版本与发布记录

@capgo/capacitor-privacy-screen 共发布 19 个版本,首次发布于 2026/03/17;过去 12 个月发布了 19 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.3.14latest2026/10/1525 天前
8.3.132026/10/1327 天前
8.3.122026/10/091 个月前
8.3.112026/10/081 个月前
8.3.102026/09/161 个月前
8.3.92026/08/202 个月前

关于 @capgo/capacitor-privacy-screen 的常见问题

@capgo/capacitor-privacy-screen 是什么?

Protect app content in Android screenshots and obscure the iOS app switcher snapshot.

如何安装 @capgo/capacitor-privacy-screen?

在项目目录运行 npm install @capgo/capacitor-privacy-screen,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-privacy-screen 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-privacy-screen 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-privacy-screen 可以商用吗?

@capgo/capacitor-privacy-screen 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-privacy-screen 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-privacy-screen 在 2026/10/09 – 2026/11/07 这 30 天内被下载 44,092 次,日均约 1,470 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-privacy-screen 还在维护吗?

最新版本 8.3.14 发布于 2026/10/15(25 天前);至今共发布 19 个版本,其中过去 12 个月发布了 19 个;首次发布于 2026/03/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。