跳过内容

开始

Terminal window
bun add @capgo/capacitor-firebase-remote-config
bunx cap sync

导入

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

API概述

API概述

activate

激活

激活

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

fetchAndActivate

__CAPGO_KEEP_0__激活

执行fetch和激活操作

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

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

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

获取给定键的值作为布尔值。

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

获取给定键的值作为数字。

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

获取给定键的值作为字符串。

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

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

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

setMinimumFetchInterval

标题:setMinimumFetchInterval

设置最小 fetch interval

仅适用于 Web。

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

设置远程配置设置

在 Android 上,设置值会被保存在 SharedPreferences 中。

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

addConfigUpdateListener

标题:addConfigUpdateListener

添加配置更新事件的监听器.

仅适用于 Android 和 iOS。

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

removeConfigUpdateListener

标题:移除配置更新监听器

移除配置更新事件的监听器。

仅适用于 Android 和 iOS。

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

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

《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

《GetNumberOptions》
export type GetNumberOptions = GetOptions;

GetNumberResult

《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

《GetStringOptions》
export type GetStringOptions = GetOptions;

GetStringResult

《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

《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;
}
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;
}
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;
}
export type AddConfigUpdateListenerOptionsCallback = (
event: AddConfigUpdateListenerOptionsCallbackEvent | null,
error: any,
) => void;
export type CallbackId = string;

本页面是由插件生成的 src/definitions.ts当公共 API 在上游发生变化时,请重新同步

继续从 Getting Started

继续从 Getting Started 的部分

如果您正在使用 Getting Started 来规划仪表板和 API 操作,连接它与 API Overview 了解 API Overview 中的实现细节 Introduction 了解 Introduction 中的实现细节 API Keys 了解 API Keys 中的实现细节 Devices 为设备中的实现细节 Bundles 为Bundles中的实现细节