跳过内容

开始

GitHub

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-firebase-app-check` plugin in my project.

如果您更喜欢手动设置,请通过运行以下命令安装插件,并按照以下平台特定的说明进行操作:

终端窗口
bun add @capgo/capacitor-firebase-app-check
npx cap sync
import { FirebaseAppCheck } from '@capgo/capacitor-firebase-app-check';

快速入门

快速入门部分
import { FirebaseAppCheck } from '@capgo/capacitor-firebase-app-check';
const result = await FirebaseAppCheck.getToken();
// The result holds sensitive values: use it without logging it.

示例:初始化

示例:初始化
import { FirebaseAppCheck } from '@capgo/capacitor-firebase-app-check';
await FirebaseAppCheck.initialize();

示例:设置令牌自动刷新

示例:设置令牌自动刷新
import { FirebaseAppCheck } from '@capgo/capacitor-firebase-app-check';
await FirebaseAppCheck.setTokenAutoRefreshEnabled({ enabled: true });
  • 监听器: 移除屏幕卸载时的句柄。
  • : 只初始化一次。: 在应用程序引导期间运行设置。
  • 真实来源: 信任 src/definitions.ts 在 GitHub 仓库中。

获取当前 App Check token。

import { FirebaseAppCheck } from '@capgo/capacitor-firebase-app-check';
const result = await FirebaseAppCheck.getToken();
// The result holds sensitive values: use it without logging it.

标题:initialize

import { FirebaseAppCheck } from '@capgo/capacitor-firebase-app-check';
await FirebaseAppCheck.initialize();

设置 App Check token 是否自动刷新。

import { FirebaseAppCheck } from '@capgo/capacitor-firebase-app-check';
await FirebaseAppCheck.setTokenAutoRefreshEnabled({ enabled: true });

类型参考

类型参考
export interface GetTokenOptions {
/**
* If `true`, will always try to fetch a fresh token.
* If `false`, will use a cached token if found in storage.
*
* @since 1.3.0
* @default false
*/
forceRefresh?: boolean;
}
export interface GetTokenResult {
/**
* The App Check token in JWT format.
*
* @since 1.3.0
*/
token: string;
/**
* The timestamp after which the token will expire in milliseconds since epoch.
*
* Only available for Android and iOS.
*
* @since 1.3.0
*/
expireTimeMillis?: number;
}

InitializeOptions

初始化选项
export interface InitializeOptions {
/**
* If `true`, the debug provider is used.
*
* ⚠️ **Attention**: The debug provider allows access to your Firebase resources from unverified devices.
* Don't use the debug provider in production builds of your app, and don't share your debug builds with untrusted parties.
*
* ⚠️ **Deprecated**: Use `debugToken` instead. This option will be removed in the next major version.
*
* Read more: https://firebase.google.com/docs/app-check/web/debug-provider
*
* @since 1.3.0
* @deprecated Use `debugToken` instead. This option will be removed in the next major version.
* @default false
*/
debug?: boolean;
/**
* If `true`, the debug provider is used.
*
* On **Web**, you can also set a predefined debug token string instead of `true`. On Android and iOS, you have to use environment variables for this.
*
* ⚠️ **Attention**: The debug provider allows access to your Firebase resources from unverified devices.
* Don't use the debug provider in production builds of your app, and don't share your debug builds with untrusted parties.
*
* @since 7.1.0
* @default false
* @see https://firebase.google.com/docs/app-check/android/debug-provider#ci
* @see https://firebase.google.com/docs/app-check/ios/debug-provider#ci
* @see https://firebase.google.com/docs/app-check/web/debug-provider
*/
debugToken?: boolean | string;
/**
* If `true`, the SDK automatically refreshes App Check tokens as needed.
*
* @since 1.3.0
* @default false
*/
isTokenAutoRefreshEnabled?: boolean;
/**
* The provider to use for App Check. Must be an instance of
* `ReCaptchaV3Provider`, `ReCaptchaEnterpriseProvider`, or `CustomProvider`.
*
* Only available for Web.
*
* @since 7.1.0
* @default ReCaptchaV3Provider
* @see https://firebase.google.com/docs/app-check/web/custom-provider
*/
provider?: any;
/**
* The reCAPTCHA v3 site key (public key). This option is ignored when `provider` is set.
*
* Only available for Web.
*
* @deprecated Use `provider` instead.
* @since 1.3.0
*/
siteKey?: string;
}

SetTokenAutoRefreshEnabledOptions

设置 App Check token 自动刷新选项
export interface SetTokenAutoRefreshEnabledOptions {
/**
* If `true`, the SDK automatically refreshes App Check tokens as needed.
* This overrides any value set during initializeAppCheck().
*
* @since 1.3.0
*/
enabled: boolean;
}

TokenChangedListener

TokenChangedListener

接收令牌变化事件的回调。

export type TokenChangedListener = (event: TokenChangedEvent) => void;

GetPluginVersionResult

context
export interface GetPluginVersionResult {
/**
* The semantic version of this plugin.
*
* @since 8.0.1
*/
version: string;
}

TokenChangedEvent

TokenChanged事件
export interface TokenChangedEvent {
/**
* The App Check token in JWT format.
*
* @since 1.3.0
*/
token: string;
}

GetPluginVersionResult

TokenChangedEvent

真实来源 src/definitions.ts重新同步时,當上游的公共API發生變化時,重新執行同步。

本页由插件生成的。重新同步公共__CAPGO_KEEP_0__时,重新运行上游的同步。

Section titled “继续从 Getting Started”

如果您正在使用 开始使用 来规划仪表板和API操作,连接它与 API 简介 查看API Overview中的实施细节 介绍 查看介绍中的实施细节 API 键 查看API Keys中的实施细节 设备 查看设备中的实施细节 【插件】 为插件详细信息。