1.2.0 • Published 3 years ago

@awolinski/cordova-plugin-firebase-config v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Cordova plugin for Firebase Remote Config

NPM version NPM downloads NPM total downloads PayPal donate Twitter

DonateYour help is appreciated. Create a PR, submit a bug or just grab me :beer:

Index

Supported Platforms

  • iOS
  • Android

Installation

$ cordova plugin add cordova-plugin-firebase-config

Use variables IOS_FIREBASE_CONFIG_VERSION and ANDROID_FIREBASE_CONFIG_VERSION to override dependency versions for Firebase SDKs.

Preferences

You can specify FirebaseRemoteConfigDefaults in config.xml to define filename of a file with default values.

On Android the file is located at platforms/android/res/xml/${filename}.xml and has a structure like below:

<?xml version="1.0" encoding="utf-8"?>
<defaultsMap>
    <entry>
        <key>param1</key>
        <value>value1</value>
    </entry>
    <entry>
        <key>param2</key>
        <value>value2</value>
    </entry>
</defaultsMap>

On iOS file the file is located at platforms/ios/<Your App Name>/${filename}.plist and has a structure like below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>param1</key>
    <string>value1</string>
    <key>param2</key>
    <string>value2</string>
</dict>
</plist>

Methods

Every method call returns a promise which is optionally fulfilled with an appropriate value.

fetch(expirationDuration)

Starts fetching configs, adhering to the specified minimum fetch interval.

cordova.plugins.firebase.config.fetch(8 * 3600).then(function() {
    // your config was fetched
});

activate()

Asynchronously activates the most recently fetched configs, so that the fetched key value pairs take effect.

cordova.plugins.firebase.config.activate().then(function() {
    // your config was activated
});

fetchAndActivate()

Asynchronously fetches and then activates the fetched configs.

cordova.plugins.firebase.config.fetchAndActivate().then(function() {
    // your config was fetched and activated
});

getBoolean(key)

cordova.plugins.firebase.config.getBoolean("myBool").then(function(value) {
    // use value from remote config
});

getString(key)

cordova.plugins.firebase.config.getString("myStr").then(function(value) {
    // use value from remote config
});

getNumber(key)

cordova.plugins.firebase.config.getNumber("myNumber").then(function(value) {
    // use value from remote config
});

getBytes(key)

cordova.plugins.firebase.config.getBytes("myByteArray").then(function(value) {
    // use value from remote config
});