This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo 剪贴板
一个通用库,允许获取和设置剪贴板内容。
expo-clipboard 提供了一个接口,用于在 Android、iOS 和网页上获取和设置剪贴板内容。
安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
将剪贴板内容标记为敏感(安卓)
🌐 Mark clipboard content as sensitive (Android)
当你复制敏感数据,比如密码、一次性密码(OTP)、访问令牌、支付信息或个人身份信息(PII)时,请在 setStringAsync 和 setImageAsync 中设置 android.isSensitive。
🌐 When you copy sensitive data such as passwords, one-time passwords (OTPs), access tokens, payment details, or personally identifiable information (PII), set android.isSensitive in setStringAsync and setImageAsync.
设置 android.isSensitive: true 会将剪贴板内容标记为敏感,基于 Android 关于安全剪贴板处理的指导。这可以帮助:
🌐 Setting android.isSensitive: true marks clipboard content as sensitive, based on Android guidance for secure clipboard handling. This can help:
- 混淆键盘显示的剪贴板预览
- 在安卓13及更高版本隐藏剪贴板预览覆盖
- 减少被肩窥意外暴露
import * as Clipboard from 'expo-clipboard'; // Sensitive text await Clipboard.setStringAsync('my-secret-token', { android: { isSensitive: true }, }); // Sensitive image await Clipboard.setImageAsync(base64Image, { android: { isSensitive: true }, });
应用接口
🌐 API
import * as Clipboard from 'expo-clipboard';
警告 在网页端,该模块使用了
AsyncClipboardAPI, 该 API 在不同浏览器上的行为可能有所不同,或者可能不完全支持。 特别是在 WebKit 上,该 API 在异步代码中无法使用。 点击此处了解更多信息。
No API data file found, sorry!