Cordova plugin for Firebase Remote Config
npm install cordova-plugin-firebase-config[![NPM version][npm-version]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![NPM total downloads][npm-total-downloads]][npm-url] ![PayPal donate][donate-url] [![Twitter][twitter-follow]][twitter-url]
| ![Donate][donate-url] | Your help is appreciated. Create a PR, submit a bug or just grab me :beer: |
|-|-|
[npm-url]: https://www.npmjs.com/package/cordova-plugin-firebase-config
[npm-version]: https://img.shields.io/npm/v/cordova-plugin-firebase-config.svg
[npm-downloads]: https://img.shields.io/npm/dm/cordova-plugin-firebase-config.svg
[npm-total-downloads]: https://img.shields.io/npm/dt/cordova-plugin-firebase-config.svg?label=total+downloads
[twitter-url]: https://twitter.com/chemerisuk
[twitter-follow]: https://img.shields.io/twitter/follow/chemerisuk.svg?style=social&label=Follow%20me
[donate-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YYRKVZJSHLTNC&source=url
- Supported Platforms
- Installation
- Adding required configuration files
- Preferences
- Variables
- VALUE\_SOURCE\_DEFAULT
- VALUE\_SOURCE\_REMOTE
- VALUE\_SOURCE\_STATIC
- Functions
- activate
- fetch
- fetchAndActivate
- getBoolean
- getBytes
- getNumber
- getString
- getValueSource
- iOS
- Android
$ cordova plugin add cordova-plugin-firebase-config
Use variables IOS_FIREBASE_POD_VERSION and ANDROID_FIREBASE_BOM_VERSION to override dependency versions for Firebase SDKs:
$ cordova plugin add cordova-plugin-firebase-config \
--variable IOS_FIREBASE_POD_VERSION="9.3.0" \
--variable ANDROID_FIREBASE_BOM_VERSION="30.3.1"
Cordova supports resource-file tag for easy copying resources files. Firebase SDK requires google-services.json on Android and GoogleService-Info.plist on iOS platforms.
1. Put google-services.json and/or GoogleService-Info.plist into the root directory of your Cordova project
2. Add new tag for Android platform
``xml`
...
...
...
in config.xml to define filename of a file with default values. Keep in mind that android and ios have different naming convensions there it's useful to specify different file names.`xml
...
...
`On Android platform file
remote_config_defaults.xml has a structure like below:
`xml
param1
value1
param2
value2
`On iOS platform file
RemoteConfigDefaults.plist has a structure like below:
`xml
param1
value1
param2
value2
`Variables
$3
VALUE\_SOURCE\_DEFAULT:
numberIndicates that the value returned was retrieved from the defaults set by the client.
Constant___
$3
VALUE\_SOURCE\_REMOTE:
numberIndicates that the value returned was retrieved from the Firebase Remote Config Server.
Constant___
$3
VALUE\_SOURCE\_STATIC:
numberIndicates that the value returned is the static default value.
ConstantFunctions
$3
activate():
Promise<boolean\>Asynchronously activates the most recently fetched configs, so that the fetched key value pairs take effect.
Example`ts
cordova.plugins.firebase.config.activate();
`#### Returns
Promise<boolean\>Fulfills promise with flag if current config was activated
___
$3
fetch(
expirationDuration): Promise<void\>Starts fetching configs, adhering to the specified minimum fetch interval.
Example`ts
cordova.plugins.firebase.config.fetch(8 * 3600);
`#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
|
expirationDuration | number | Minimum fetch interval in seconds |#### Returns
Promise<void\>Callback when operation is completed
___
$3
fetchAndActivate():
Promise<boolean\>Asynchronously fetches and then activates the fetched configs.
Example`ts
cordova.plugins.firebase.config.fetchAndActivate();
`#### Returns
Promise<boolean\>Fulfills promise with flag if current config was activated
___
$3
getBoolean(
key): Promise<boolean\>Returns the boolean parameter value for the given key
Example`ts
cordova.plugins.firebase.config.getBoolean("myBool").then(function(value) {
// use value from remote config
});
`#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
|
key | string | Parameter key |#### Returns
Promise<boolean\>Fulfills promise with parameter value
___
$3
getBytes(
key): Promise<ArrayBuffer\>Returns the bytes parameter value for the given key
Example`ts
cordova.plugins.firebase.config.getBytes("myByteArray").then(function(value) {
// use value from remote config
});
`#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
|
key | string | Parameter key |#### Returns
Promise<ArrayBuffer\>Fulfills promise with parameter value
___
$3
getNumber(
key): Promise<number\>Returns the number parameter value for the given key
Example`ts
cordova.plugins.firebase.config.getNumber("myNumber").then(function(value) {
// use value from remote config
});
`#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
|
key | string | Parameter key |#### Returns
Promise<number\>Fulfills promise with parameter value
___
$3
getString(
key): Promise<string\>Returns the string parameter value for the given key
Example`ts
cordova.plugins.firebase.config.getString("myStr").then(function(value) {
// use value from remote config
});
`#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
|
key | string | Parameter key |#### Returns
Promise<string\>Fulfills promise with parameter value
___
$3
getValueSource(
key): Promise<number\>Returns source of the value for the specified key.
Example`ts
cordova.plugins.firebase.config.getValueSource("myArbitraryValue").then(function(source) {
if (source === cordova.plugins.firebase.config.VALUE_SOURCE_DEFAULT) {
// ...
}
});
`#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
|
key | string | Parameter key |#### Returns
Promise<number`\>Fulfills promise with parameter value