reCAPTCHA __CAPGO_KEEP_0__ 仓库
复制一个包含安装步骤和本插件的完整Markdown指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-recaptcha`
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/recaptcha/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.
Install
准备好粘贴您可以使用我们的AI辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-recaptcha` plugin in my project.如果您更喜欢手动设置,请运行以下命令安装插件,并按照以下平台特定说明进行操作:
bun add @capgo/capacitor-recaptchabunx cap sync配置站点密钥
标题:配置站点密钥在Google Cloud reCAPTCHA中创建平台密钥,然后将它们添加到 capacitor.config.ts.
import type { CapacitorConfig } from '@capacitor/cli';import '@capgo/capacitor-recaptcha';
const config: CapacitorConfig = { appId: 'com.example.app', appName: 'Example', webDir: 'dist', plugins: { Recaptcha: { androidSiteKey: 'ANDROID_SITE_KEY', iosSiteKey: 'IOS_SITE_KEY', webSiteKey: 'WEB_SITE_KEY', enterprise: true, }, },};
export default config;androidSiteKey, iosSiteKey,并 webSiteKey 覆盖共享设置 siteKey您也可以传递一个 siteKey 直接传递到 load() 或 execute() 当关键字取决于您的环境。
生成令牌
生成令牌import { Recaptcha } from '@capgo/capacitor-recaptcha';
const { token } = await Recaptcha.execute({ action: 'login',});
await fetch('/api/recaptcha-assessment', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ token, action: 'login' }),});execute() 调用 load() 自动调用客户端未准备好时,因此显式预加载步骤是可选的。
Web标准 reCAPTCHA v3
生成令牌设置 enterprise: false 加载 Google 的标准 Web reCAPTCHA v3 脚本。
const { token } = await Recaptcha.execute({ siteKey: 'WEB_V3_SITE_KEY', enterprise: false, action: 'signup',});在 Android 和 iOS 上,Google 的原生移动 SDK 路径仅限企业/移动。传递 enterprise: false 迁移说明
并 sitekeyAndroid and sitekeyWeb 作为 iOS 迁移别名。尽量使用 Capacitor 配置名称来代替新 __CAPGO_KEEP_1__。 sitekeyIos and sitekeyIOS 作为 iOS 迁移别名。尽量使用 Capacitor 配置名称来代替新 code。
继续从 Getting Started
标题:继续从 Getting Started如果您正在使用 开始使用 来规划身份验证和帐户流程,连接它到 使用 @capgo/capacitor-recaptcha 为在使用 @capgo/capacitor-recaptcha 中的原生能力 使用 @capgo/capacitor-social-login 为在 @capgo/capacitor-social-login 中的实现细节 使用 @capgo/capacitor-passkey 为在 @capgo/capacitor-passkey 中的实现细节 使用 @capgo/capacitor-native-biometric 为@capgo/capacitor-native-biometric的实现细节 双因素认证 为双因素认证的实现细节