开始使用
复制一个带有安装步骤和此插件的完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-privacy-screen`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/privacy-screen/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
-
安装插件
终端窗口 bun add @capgo/capacitor-privacy-screen -
同步本机平台
终端窗口 bunx cap sync -
查看平台行为
- 阅读 iOS 关于应用切换行为的说明
- 阅读 Android注意事项 截图和录屏行为。
默认行为
标题:默认行为该插件在原生实现加载时自动启用隐私保护。
- 在Android上,安全模式阻止截图、屏幕录屏捕获和最近应用预览。
- 在iOS上,插件在应用切换快照生成时隐藏您的应用。
- 在Web上,插件仅在API对齐时为内存启用标志。
基本使用
标题:基本使用import { PrivacyScreen } from '@capgo/capacitor-privacy-screen';
await PrivacyScreen.disable();
// Run a flow where screenshots or previews are temporarily allowed.
await PrivacyScreen.enable();
const { enabled } = await PrivacyScreen.isEnabled();console.log('Privacy screen enabled:', enabled);何时临时禁用它
当需要临时禁用它时仅在系统预览中保持当前屏幕可见或允许用户捕获时使用,例如: disable() 需要用户截图以获取支持的账户验证步骤
- 需要可见的应用切换预览的支付或身份提供者流
- 在信任的设备上进行受控的调试会话
- 立即之后恢复保护
编辑页面 enable().