@capacitor-firebase/remote-config

中文文档
8.6.0发布于 2026/10/31Apache-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 5.1万

Capacitor plugin for Firebase Remote Config on Android, iOS, and Web.

原始使用文档
文档目录45 节
  1. Use Cases
  2. Compatibility
  3. Guides
  4. Installation
  5. Android
  6. iOS
  7. Configuration
  8. Demo
  9. Starter templates
  10. Usage
  11. Fetch and activate the configuration
  12. Read configuration values
  13. Configure the fetch behavior
  14. Set custom signals
  15. Listen for configuration updates in real time
  16. Remove all listeners
  17. API
  18. activate()
  19. fetchAndActivate()
  20. fetchConfig(...)
  21. getBoolean(...)
  22. getNumber(...)
  23. getString(...)
  24. getAll()
  25. getInfo()
  26. setMinimumFetchInterval(...)
  27. setCustomSignals(...)
  28. setDefaults(...)
  29. setSettings(...)
  30. addConfigUpdateListener(...)
  31. removeConfigUpdateListener(...)
  32. removeAllListeners()
  33. Interfaces
  34. Type Aliases
  35. Enums
  36. FAQ
  37. Why do the getters return default values instead of the rem…
  38. How often does the plugin fetch new configuration values?
  39. How can I react to configuration changes in real time?
  40. Do I need the Firebase Analytics plugin to use Remote Confi…
  41. How can I tell where a configuration value came from?
  42. Related Plugins
  43. Newsletter
  44. Changelog
  45. License

Capacitor Firebase Remote Config Plugin

Unofficial Capacitor plugin for Firebase Remote Config.[^1]

Use Cases

The Firebase Remote Config plugin is typically used to change the behavior and appearance of your app without publishing an app update, for example:

  • Feature flags: Roll out new features gradually by toggling boolean parameters remotely.
  • Promotions: Activate sales or promotions remotely, for example via an is_sale parameter.
  • Maintenance announcements: Inform users about upcoming maintenance without releasing a new app version.
  • Real-time updates: React to configuration changes in real time using the config update listener.
  • Default values: Provide in-app default values so your app behaves predictably before the first fetch.

Compatibility

Plugin VersionCapacitor VersionStatus
8.x.x>=8.x.xActive support
7.x.x7.x.xDeprecated
6.x.x6.x.xDeprecated
5.x.x5.x.xDeprecated

Guides

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:

npx skills add capawesome-team/skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capacitor-firebase/remote-config` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capacitor-firebase/remote-config firebase
npx cap sync

Add Firebase to your project if you haven't already (Android / iOS / Web).

Android

Google Analytics is required for the conditional targeting of app instances to user properties and audiences. Make sure that you install the Capacitor Firebase Analytics plugin in your project.

Variables

If needed, you can define the following project variable in your app’s variables.gradle file to change the default version of the dependency:

  • $firebaseConfigVersion version of com.google.firebase:firebase-config (default: 23.0.1)

This can be useful if you encounter dependency conflicts with other plugins in your project.

iOS

Swift Package Manager

Add the following to your capacitor.config.json (or capacitor.config.ts) to avoid a SwiftPM package identity collision:

{
  "experimental": {
    "ios": {
      "spm": {
        "packageOptions": {
          "@capacitor-firebase/remote-config": {
            "symlink": true
          }
        }
      }
    }
  }
}

Attention: SPM packageOptions support requires Capacitor CLI 8.4.0+.

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-firebase-plugin-demo

Starter templates

The following starter templates are available:

Usage

The following examples show how to fetch and activate the configuration, read configuration values, configure the fetch behavior, set custom signals, and listen for configuration updates in real time.

Fetch and activate the configuration

Fetch the latest configuration from the Remote Config service and activate it to make it available to the getters. Use fetchAndActivate() to perform both operations at once. On Android and iOS, you can pass a minimum fetch interval to fetchConfig(...):

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

const fetchConfig = async () => {
  await FirebaseRemoteConfig.fetchConfig({
    minimumFetchIntervalInSeconds: 1200,
  });
};

const activate = async () => {
  await FirebaseRemoteConfig.activate();
};

const fetchAndActivate = async () => {
  await FirebaseRemoteConfig.fetchAndActivate();
};

Read configuration values

Read the value for a given key as a boolean, number, or string:

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

const getBoolean = async () => {
  const { value } = await FirebaseRemoteConfig.getBoolean({
    key: 'is_sale',
  });
  return value;
};

const getNumber = async () => {
  const { value } = await FirebaseRemoteConfig.getNumber({
    key: 'upcoming_maintenance',
  });
  return value;
};

const getString = async () => {
  const { value } = await FirebaseRemoteConfig.getString({
    key: 'license_key',
  });
  return value;
};

Configure the fetch behavior

Set the fetch timeout and the minimum fetch interval. During development, it's recommended to set a relatively low minimum fetch interval:

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

const setSettings = async () => {
  await FirebaseRemoteConfig.setSettings({
    fetchTimeoutInSeconds: 10,
    minimumFetchIntervalInSeconds: 0,
  });
};

Set custom signals

Set custom signals for the app instance that can be used for targeting in Remote Config conditions. Signals with a null value will be removed:

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

const setCustomSignals = async () => {
  await FirebaseRemoteConfig.setCustomSignals({
    customSignals: {
      city: 'Berlin',
      preferred_event_category: 'concerts',
    },
  });
};

Listen for configuration updates in real time

Add a listener for the config update event to be notified as soon as parameter values change. Only available on Android and iOS:

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

const addConfigUpdateListener = async () => {
  const callbackId = await FirebaseRemoteConfig.addConfigUpdateListener(
    (event, error) => {
      if (error) {
        console.error(error);
      } else {
        console.log(event);
      }
    }
  );
  return callbackId;
};

const removeConfigUpdateListener = async (callbackId: string) => {
  await FirebaseRemoteConfig.removeConfigUpdateListener({
    callbackId,
  });
};

Remove all listeners

Remove all listeners that have been added for this plugin:

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

const removeAllListeners = async () => {
  await FirebaseRemoteConfig.removeAllListeners();
};

API

activate()

activate() => Promise<void>

Make the last fetched configuration available to the getters.

Since: 1.3.0


fetchAndActivate()

fetchAndActivate() => Promise<void>

Perform fetch and activate operations.

Since: 1.3.0


fetchConfig(...)

fetchConfig(options?: FetchConfigOptions | undefined) => Promise<void>

Fetch and cache configuration from the Remote Config service.

ParamType
optionsFetchConfigOptions

Since: 1.3.0


getBoolean(...)

getBoolean(options: GetBooleanOptions) => Promise<GetBooleanResult>

Get the value for the given key as a boolean.

ParamType
optionsGetOptions

Returns: Promise<GetBooleanResult>

Since: 1.3.0


getNumber(...)

getNumber(options: GetNumberOptions) => Promise<GetNumberResult>

Get the value for the given key as a number.

ParamType
optionsGetOptions

Returns: Promise<GetNumberResult>

Since: 1.3.0


getString(...)

getString(options: GetStringOptions) => Promise<GetStringResult>

Get the value for the given key as a string.

ParamType
optionsGetOptions

Returns: Promise<GetStringResult>

Since: 1.3.0


getAll()

getAll() => Promise<GetAllResult>

Get all the values from the Remote Config service.

Returns: Promise<GetAllResult>

Since: 8.3.0


getInfo()

getInfo() => Promise<GetInfoResult>

Get information about the last fetch operation.

Returns: Promise<GetInfoResult>

Since: 7.5.0


setMinimumFetchInterval(...)

setMinimumFetchInterval(options: SetMinimumFetchIntervalOptions) => Promise<void>

Set the minimum fetch interval.

Only available for Web.

ParamType
optionsSetMinimumFetchIntervalOptions

Since: 1.3.0


setCustomSignals(...)

setCustomSignals(options: SetCustomSignalsOptions) => Promise<void>

Set custom signals for the app instance that can be used for targeting in Remote Config conditions.

ParamType
optionsSetCustomSignalsOptions

Since: 8.4.0


setDefaults(...)

setDefaults(options: SetDefaultsOptions) => Promise<void>

Sets config defaults for parameter keys and values in the default namespace config.

ParamType
optionsSetDefaultsOptions

Since: 8.3.0


setSettings(...)

setSettings(options: SetSettingsOptions) => Promise<void>

Set the remote config settings.

On Android, the settings values are persisted in SharedPreferences.

ParamType
optionsSetSettingsOptions

Since: 6.2.0


addConfigUpdateListener(...)

addConfigUpdateListener(callback: AddConfigUpdateListenerOptionsCallback) => Promise<CallbackId>

Add a listener for the config update event.

Only available for Android and iOS.

ParamType
callbackAddConfigUpdateListenerOptionsCallback

Returns: Promise<string>

Since: 5.4.0


removeConfigUpdateListener(...)

removeConfigUpdateListener(options: RemoveConfigUpdateListenerOptions) => Promise<void>

Remove a listener for the config update event.

Only available for Android and iOS.

ParamType
optionsRemoveConfigUpdateListenerOptions

Since: 5.4.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 5.4.0


Interfaces

FetchConfigOptions

PropTypeDescriptionDefaultSince
minimumFetchIntervalInSecondsnumberDefine 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.432001.3.0

GetBooleanResult

PropTypeDescriptionSince
valuebooleanThe value for the given key as a boolean.1.3.0
sourceGetValueSourceIndicates at which source this value came from.1.3.0

GetOptions

PropTypeDescriptionSince
keystringThe key of the value to get.1.3.0

GetNumberResult

PropTypeDescriptionSince
valuenumberThe value for the given key as a number.1.3.0
sourceGetValueSourceIndicates at which source this value came from.1.3.0

GetStringResult

PropTypeDescriptionSince
valuestringThe value for the given key as a string.1.3.0
sourceGetValueSourceIndicates at which source this value came from.1.3.0

GetAllResult

PropTypeDescriptionSince
valuesRecord<string, GetAllResultValue>The values for all keys.8.3.0

GetAllResultValue

PropTypeDescriptionSince
valuestringThe value as a string.8.3.0
sourceGetValueSourceIndicates at which source this value came from.8.3.0

GetInfoResult

PropTypeDescriptionSince
lastFetchTimenumberThe Unix timestamp in milliseconds of the last successful fetch, or -1 if no fetch has occurred or initialization is incomplete.7.5.0
lastFetchStatusLastFetchStatusThe status of the last fetch attempt.7.5.0

SetMinimumFetchIntervalOptions

PropTypeDescriptionDefaultSince
minimumFetchIntervalInSecondsnumberDefine 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.432001.3.0

SetCustomSignalsOptions

PropTypeDescriptionSince
customSignalsRecord<string, string | number | null>The custom signals to set for the app instance. Signals with a null value will be removed.8.4.0

SetDefaultsOptions

PropTypeDescriptionSince
defaultsRecord<string, string | number | boolean>Defines the dictionary of values to set as defaults.8.3.0

SetSettingsOptions

PropTypeDescriptionDefaultSince
fetchTimeoutInSecondsnumberDefines the maximum amount of milliseconds to wait for a response when fetching configuration from the Remote Config server.606.2.0
minimumFetchIntervalInSecondsnumberDefine 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.432006.2.0

AddConfigUpdateListenerOptionsCallbackEvent

PropTypeDescriptionSince
updatedKeysstring[]Parameter keys whose values have been updated from the currently activated values.5.4.0

RemoveConfigUpdateListenerOptions

PropTypeDescriptionSince
idCallbackIdThe id of the listener to remove.5.4.0

Type Aliases

GetBooleanOptions

GetOptions

GetNumberOptions

GetOptions

GetStringOptions

GetOptions

AddConfigUpdateListenerOptionsCallback

(event: AddConfigUpdateListenerOptionsCallbackEvent | null, error: any): void

CallbackId

string

Enums

GetValueSource

MembersValueDescriptionSince
Static0Indicates that the value returned is the static default value.1.3.0
Default1Indicates that the value returned was retrieved from the defaults set by the client.1.3.0
Remote2Indicates that the value returned was retrieved from the Firebase Remote Config Server.1.3.0

LastFetchStatus

MembersValue
NoFetchYet0
Success1
Failure2
Throttled3

FAQ

Why do the getters return default values instead of the remote ones?

Fetched configuration values must be activated before they are available to the getters. Call fetchConfig(...) followed by activate(), or use fetchAndActivate() to perform both operations at once, as shown in the usage example above.

How often does the plugin fetch new configuration values?

Fetched configuration values are cached. The minimum fetch interval defines the maximum age in seconds of an entry in the config cache before it is considered stale, with a default of 43200 seconds (12 hours). During development, it's recommended to set a relatively low minimum fetch interval using setSettings(...) on Android and iOS or setMinimumFetchInterval(...) on Web.

How can I react to configuration changes in real time?

Use addConfigUpdateListener(...) to be notified as soon as parameter values change, including the keys whose values have been updated. This method is only available on Android and iOS. You can remove the listener again with removeConfigUpdateListener(...) or removeAllListeners().

Do I need the Firebase Analytics plugin to use Remote Config?

Google Analytics is only required for the conditional targeting of app instances to user properties and audiences. If you want to use conditions, make sure to also install the Capacitor Firebase Analytics plugin in your project.

How can I tell where a configuration value came from?

The getters return a source property in addition to the value. It indicates whether the value is the static default value, was retrieved from the defaults set by the client, or was retrieved from the Firebase Remote Config server.

  • Firebase Analytics: Log events and user properties with Firebase Analytics.
  • Live Update: Update your app remotely in real-time without requiring users to download a new version from the app store.

Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.

Changelog

See CHANGELOG.md.

License

See LICENSE.

[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries.

版本与发布记录

@capacitor-firebase/remote-config 共发布 39 个版本,首次发布于 2022/11/17;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.6.0latest2026/10/319 天前
8.5.22026/09/171 个月前
8.5.12026/09/022 个月前
8.5.02026/08/312 个月前
8.4.02026/08/122 个月前
8.3.02026/06/045 个月前

其他发布通道:dev → 7.0.0-dev.1765887457。

关于 @capacitor-firebase/remote-config 的常见问题

@capacitor-firebase/remote-config 是什么?

Capacitor plugin for Firebase Remote Config on Android, iOS, and Web.

如何安装 @capacitor-firebase/remote-config?

在项目目录运行 npm install @capacitor-firebase/remote-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capacitor-firebase/remote-config 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capacitor-firebase/remote-config 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capacitor-firebase/remote-config 可以商用吗?

@capacitor-firebase/remote-config 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@capacitor-firebase/remote-config 的下载量有多少?

根据 npm 官方下载统计,@capacitor-firebase/remote-config 在 2026/10/09 – 2026/11/07 这 30 天内被下载 50,691 次,日均约 1,690 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capacitor-firebase/remote-config 还在维护吗?

最新版本 8.6.0 发布于 2026/10/31(9 天前);至今共发布 39 个版本,其中过去 12 个月发布了 13 个;首次发布于 2022/11/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。