@capacitor-firebase/remote-config
Unofficial Capacitor plugin for Firebase Remote Config.1
Installation
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
This plugin will use the following project variables (defined in your app’s variables.gradle
file):
-
$firebaseConfigVersion
version ofcom.google.firebase:firebase-config
(default:21.2.0
)
Configuration
No configuration required for this plugin.
Demo
A working example can be found here: robingenz/capacitor-firebase-plugin-demo
Usage
import { FirebaseRemoteConfig } from '@capacitor-firebase/remote-config';
const activate = async () => {
await FirebaseRemoteConfig.activate();
};
const fetchAndActivate = async () => {
await FirebaseRemoteConfig.fetchAndActivate();
};
const fetchConfig = async () => {
await FirebaseRemoteConfig.fetchConfig({
minimumFetchIntervalInSeconds: 1200,
});
};
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;
};
API
activate()
fetchAndActivate()
fetchConfig(...)
getBoolean(...)
getNumber(...)
getString(...)
setMinimumFetchInterval(...)
- Interfaces
- Type Aliases
- Enums
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.
Param | Type |
---|---|
options |
FetchConfigOptions |
Since: 1.3.0
getBoolean(...)
getBoolean(options: GetBooleanOptions) => GetBooleanResult
Get the value for the given key as a boolean.
Param | Type |
---|---|
options |
GetOptions |
Returns: GetBooleanResult
Since: 1.3.0
getNumber(...)
getNumber(options: GetNumberOptions) => GetNumberResult
Get the value for the given key as a number.
Param | Type |
---|---|
options |
GetOptions |
Returns: GetNumberResult
Since: 1.3.0
getString(...)
getString(options: GetStringOptions) => GetStringResult
Get the value for the given key as a string.
Param | Type |
---|---|
options |
GetOptions |
Returns: GetStringResult
Since: 1.3.0
setMinimumFetchInterval(...)
setMinimumFetchInterval(options: SetMinimumFetchIntervalOptions) => Promise<void>
Set the minimum fetch interval.
Only available for Web.
Param | Type |
---|---|
options |
SetMinimumFetchIntervalOptions |
Since: 1.3.0
Interfaces
FetchConfigOptions
Prop | Type | Description | Default | Since |
---|---|---|---|---|
minimumFetchIntervalInSeconds |
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. Only available for Android and iOS. | 43200 |
1.3.0 |
GetBooleanResult
Prop | Type | Description | Since |
---|---|---|---|
value |
boolean |
The value for the given key as a boolean. | 1.3.0 |
source |
GetValueSource |
Indicates at which source this value came from. Only available for Android and iOS. | 1.3.0 |
GetOptions
Prop | Type | Description | Since |
---|---|---|---|
key |
string |
The key of the value to get. | 1.3.0 |
GetNumberResult
Prop | Type | Description | Since |
---|---|---|---|
value |
number |
The value for the given key as a number. | 1.3.0 |
source |
GetValueSource |
Indicates at which source this value came from. Only available for Android and iOS. | 1.3.0 |
GetStringResult
Prop | Type | Description | Since |
---|---|---|---|
value |
string |
The value for the given key as a string. | 1.3.0 |
source |
GetValueSource |
Indicates at which source this value came from. Only available for Android and iOS. | 1.3.0 |
SetMinimumFetchIntervalOptions
Prop | Type | Description | Default | Since |
---|---|---|---|---|
minimumFetchIntervalInSeconds |
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. | 43200 |
1.3.0 |
Type Aliases
GetBooleanOptions
GetNumberOptions
GetStringOptions
Enums
GetValueSource
Members | Value | Description | Since |
---|---|---|---|
Static |
0 |
Indicates that the value returned is the static default value. | 1.3.0 |
Default |
1 |
Indicates that the value returned was retrieved from the defaults set by the client. | 1.3.0 |
Remote |
2 |
Indicates that the value returned was retrieved from the Firebase Remote Config Server. | 1.3.0 |
Changelog
See CHANGELOG.md.
License
See LICENSE.
-
This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries.
↩