跳过内容

Page/area: Capgo marketing website. Role: Website copy sentence. Seen in: component doc/SignupCta.astro, component Hero.astro. Message key `hero_subtitle_v2` (Hero Subtitle V2).

GitHub

您可以使用我们的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-remote-config` plugin in my project.

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

终端窗口
bun add @capgo/capacitor-firebase-remote-config
npx cap sync

导入

导入
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';

快速入门

快速入门
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.activate();

页面上下文:Capgo营销网站。角色:UI标签。见于:页面agents/[slug].astro。消息键`agents_page_copy_label`(Agents Page Copy Label)。

示例:fetchAndActivate
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchAndActivate();

页面标题:示例:fetchAndActivate

示例:fetchConfig
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchConfig();

页面标题:示例:fetchConfig

常见问题
  • 页面标题:常见问题原生同步 npx cap sync 在插件升级后。
  • 真实来源: 信任 src/definitions.ts 在 GitHub 仓库中。

使最后获取的配置可供获取者使用。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.activate();

fetchAndActivate

获取和激活

标题:fetchAndActivate

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchAndActivate();

fetchConfig

fetchConfig

从远程配置服务获取和缓存配置。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchConfig();

getBoolean

获取布尔值

获取给定键的布尔值。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getBoolean({ key: 'key-123' });
console.log(result);

getNumber

获取数字

获取给定键的数字值。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getNumber({ key: 'key-123' });
console.log(result);

获取给定键的字符串值。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getString({ key: 'key-123' });
console.log(result);

获取最后一次抓取操作的信息。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getInfo();
console.log(result);

setMinimumFetchInterval

setMinimumFetchInterval

Section titled “setMinimumFetchInterval”

设置最小抓取间隔。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.setMinimumFetchInterval({ minimumFetchIntervalInSeconds: 43200 });

Section titled “setSettings”

设置远程配置设置。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.setSettings({
fetchTimeoutInSeconds: 60,
minimumFetchIntervalInSeconds: 43200,
});

添加配置更新事件监听器。

仅适用于 Android 和 iOS。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.addConfigUpdateListener((event, error) => {
console.log(event);
});
console.log(result);

removeConfigUpdateListener

移除配置更新事件监听器

类型参考

仅适用于 Android 和 iOS。

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.removeConfigUpdateListener({ id: 'id-123' });

获取布尔选项

获取配置选项

FetchConfigOptions

配置更新事件监听器
export interface FetchConfigOptions {
/**
* Define the maximum age in seconds of an entry in the config cache before it is considered stale.
* During development, it's recommended to set a relatively low minimum fetch interval.
*
* Only available for Android and iOS.
*
* @since 1.3.0
* @default 43200
* @see https://firebase.google.com/docs/reference/js/firebase.remoteconfig.RemoteConfigSettings#minimumfetchintervalmillis
*/
minimumFetchIntervalInSeconds?: number;
}
export type GetBooleanOptions = GetOptions;

GetBooleanResult

获取布尔结果
export interface GetBooleanResult {
/**
* The value for the given key as a boolean.
*
* @since 1.3.0
*/
value: boolean;
/**
* Indicates at which source this value came from.
*
* Only available for Android and iOS.
*
* @since 1.3.0
*/
source?: GetValueSource;
}

GetNumberOptions

获取数字选项
export type GetNumberOptions = GetOptions;

GetNumberResult

获取数字结果
export interface GetNumberResult {
/**
* The value for the given key as a number.
*
* @since 1.3.0
*/
value: number;
/**
* Indicates at which source this value came from.
*
* Only available for Android and iOS.
*
* @since 1.3.0
*/
source?: GetValueSource;
}

GetStringOptions

获取字符串选项
export type GetStringOptions = GetOptions;

GetStringResult

获取字符串结果
export interface GetStringResult {
/**
* The value for the given key as a string.
*
* @since 1.3.0
*/
value: string;
/**
* Indicates at which source this value came from.
*
* Only available for Android and iOS.
*
* @since 1.3.0
*/
source?: GetValueSource;
}

GetInfoResult

获取信息结果
export interface GetInfoResult {
/**
* The Unix timestamp in milliseconds of the last successful fetch, or -1 if no fetch has occurred or initialization is incomplete.
* @since 7.5.0
* @example 1762864760
*/
lastFetchTime: number;
/**
* The status of the last fetch attempt.
* @since 7.5.0
* @example 1
*/
lastFetchStatus: LastFetchStatus;
}

SetMinimumFetchIntervalOptions

设置最小 fetchInterval 选项
export interface SetMinimumFetchIntervalOptions {
/**
* Define the maximum age in seconds of an entry in the config cache before it is considered stale.
* During development, it's recommended to set a relatively low minimum fetch interval.
*
* @since 1.3.0
* @default 43200
* @see https://firebase.google.com/docs/reference/js/remote-config.remoteconfigsettings#remoteconfigsettingsminimumfetchintervalmillis
*/
minimumFetchIntervalInSeconds: number;
}

SetSettingsOptions

设置设置选项
export interface SetSettingsOptions {
/**
* Defines the maximum amount of milliseconds to wait for a response when fetching configuration from the Remote Config server.
*
* @since 6.2.0
* @default 60
* @see https://firebase.google.com/docs/reference/js/remote-config.remoteconfigsettings#remoteconfigsettingsfetchtimeoutmillis
*/
fetchTimeoutInSeconds?: number;
/**
* Define the maximum age in seconds of an entry in the config cache before it is considered stale.
* During development, it's recommended to set a relatively low minimum fetch interval.
*
* @since 6.2.0
* @default 43200
* @see https://firebase.google.com/docs/reference/js/remote-config.remoteconfigsettings#remoteconfigsettingsminimumfetchintervalmillis
*/
minimumFetchIntervalInSeconds?: number;
}

AddConfigUpdateListenerOptionsCallback

添加配置更新监听器选项回调
export type AddConfigUpdateListenerOptionsCallback = (
event: AddConfigUpdateListenerOptionsCallbackEvent | null,
error: any,
) => void;

CallbackId

回调 ID
export type CallbackId = string;

获取 started src/definitions.ts. 当上游的 API 发生变化时,请重新运行同步。

继续从 Getting Started

标题:继续从 Getting Started

如果您正在使用 开始使用 来规划仪表板和 API 操作,请将其连接到 API 简介 查看 API Overview 中的实现细节 介绍 查看 Introduction 中的实现细节 API 键 查看 API Keys 中的实现细节 设备 了解设备的具体实现细节 包 了解包的具体实现细节