跳过主要内容

__CAPGO_KEEP_0__ Capacitor

Capacitor Firebase Remote Config 插件

Install

bun add @capgo/capacitor-firebase-remote-config bunx cap sync
npm, pnpm 或 yarn
  • npm install @capgo/capacitor-firebase-remote-config
  • pnpm add @capgo/capacitor-firebase-remote-config
  • yarn add @capgo/capacitor-firebase-remote-config

指南

如何在 Capacitor 中使用 Firebase Remote Config

使用@capgo/capacitor-firebase-remote-config

Capacitor插件用于Firebase Remote Config。

安装

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

bunx cap sync 将插件的本机code复制到您的本机项目中。每次升级插件后都要重新运行它。

导入

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

API概览

方法 描述
activate 使最后获取的配置可供获取者使用。
fetchAndActivate 执行fetch和activate操作。
fetchConfig 从Remote Config服务中获取和缓存配置。
getBoolean 获取给定键的值作为布尔值。
getNumber 获取给定键的值作为数字。
getString 获取给定键的值作为字符串。
getAll 从远程配置服务获取所有值。
getInfo 获取最后一次 fetch 操作的信息。
setMinimumFetchInterval 设置最小 fetch interval。
setDefaults 设置默认命名空间配置的参数键和值。
setSettings 设置远程配置设置。
addConfigUpdateListener 添加一个监听器来监听配置更新事件。
removeConfigUpdateListener 移除一个监听器来监听配置更新事件。

示例

activate()

context

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

await FirebaseRemoteConfig.activate();

fetchAndActivate()

执行 fetch 和激活操作。

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

await FirebaseRemoteConfig.fetchAndActivate();

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);

getString()

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

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

const result = await FirebaseRemoteConfig.getString({ key: 'key-123' });
console.log(result);

上表列出了 13 个核心方法。监听器和版本辅助以及每个方法的完整契约都在__CAPGO_KEEP_0__仓库中文档化。 GitHub参考文档.

继续使用@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-firebase-远程配置

继续使用 @capgo/capacitor-firebase-remote-config

__CAPGO_KEEP_0__参考文档 使用@capgo/capacitor-firebase-远程配置 规划原生插件工作,连接它 Capgo 插件目录 在Capgo 插件目录中 Capacitor Capgo 由 Capgo 提供的插件 为 Capacitor 插件的实现细节提供 Capgo 插件的实现细节 在插件的实现细节中 添加或更新插件 在添加或更新插件中 Capgo 原生构建 为产品工作流程在Capgo原生构建中。

常见问题

Firebase Remote Config插件FAQ

如何在Capacitor应用中安装Firebase Remote Config插件?

运行 "bun add @capgo/capacitor-firebase-remote-config" (或 "npm install @capgo/capacitor-firebase-remote-config" ),然后运行 "bunx cap sync" 以便 iOS 和 Android 项目能够接收到原生 code。从 "@capgo/capacitor-firebase-remote-config" 中导入它到你的应用程序 code 中。

是否支持 @capgo/capacitor-firebase-remote-config 与 React、Vue 和 Angular 一起使用?

是的。Firebase Remote Config 是一个 Capacitor 包,因此它可以与任何运行在 Capacitor 内的 Web 框架一起使用,包括 Ionic、React、Vue、Angular、Svelte 和普通的 JavaScript。

哪个 Capacitor 版本支持 @capgo/capacitor-firebase-remote-config?

Capgo 插件遵循 Capacitor 的主要版本:使用与你的 Capacitor 主要版本匹配的插件主要版本(例如插件 v8 与 Capacitor 8)。在 GitHub README 中的兼容性表格中列出了维护的版本。

是否支持 @capgo/capacitor-firebase-remote-config 免费和开源?

是的。源代码 code 公开在 GitHub 上,https://github.com/Cap-go/capacitor-firebase/tree/main/packages/remote-config 中,包是免费安装的从 npm 中。欢迎 bug 报告和 pull 请求。

是否可以在 App Store 审核期间更新使用 Firebase Remote Config 的 code?

安装或升级插件会更改原生 code,因此需要一个新的商店构建。之后,JavaScript、HTML 和 CSS 的更改可以立即通过 Capgo 的实时更新发布。

无需等待应用程序审查即可将 Firebase Remote Config 更改推送到应用程序

一旦插件在您的商店构建中,Capgo实时更新将将您的 JavaScript、HTML 和 CSS 更改推送给用户几分钟内。

开始使用 Capgo