iamfozzy / cordova-plugin-firebase-config

Cordova plugin for Firebase Remote Config

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cordova plugin for Firebase Remote Config

NPM version NPM downloads Twitter

Donate Your help is appreciated. Create a PR, submit a bug or just grab me 🍺

Index

Supported Platforms

  • iOS
  • Android

Installation

$ cordova plugin add cordova-plugin-firebase-config

Use variable FIREBASE_CONFIG_VERSION and FIREBASE_CORE_VERSION to override dependency version on Android.

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

About

Cordova plugin for Firebase Remote Config

License:MIT License


Languages

Language:Objective-C 46.8%Language:Java 42.5%Language:JavaScript 10.7%