oleg.semen
oleg.semen

Reputation: 3061

Conditions in Firebase Remote Config Defaults

I'm trying to set up Firebase Remote Config. One of important parts in my project is correct localization. So I have conditions for different languages set up in console. But now I'd like to make defaults xml. Example on github is to simple. There are only few values without any conditions. Documentation does not describe this format at all. So I'm wondering if it is possible to specify all my localizations in defaults.xml and how do I do this.

Upvotes: 0

Views: 1718

Answers (3)

Vismay Patil
Vismay Patil

Reputation: 64

I was struggling with this problem for the past one day. Found a solution a few minutes back.

Firstly, create the required localized files for Remote Config Defaults. Screenshot of localized remote_config_defaults.xml

Then, before you call fetchAndActive() just get the required value. This will give you the values from the remote_config_defaults.xml

/*Use remoteConfig object to get values from defaults. 
If you have added multiple locales then it will give the values
from the respective locale basis on your device language.
Make sure you have used the same key for all the locales.*/
val defaultValue =
        remoteConfig.getValue(YOUR_KEY).asString()

    remoteConfig.fetchAndActivate()
        .addOnCompleteListener(activity) { task ->
            if (task.isSuccessful) {
//Use remoteConfig object to get the values from Firebase.
            }
        }

Upvotes: 0

Filfur
Filfur

Reputation: 1

Just put localized xml with defaults in folder xml-fr for French or xml-ru for Russian (just xml for other localizations).

Upvotes: 0

Doug Stevenson
Doug Stevenson

Reputation: 317382

The defaults file can't be used to specify conditions. It is just key/value pairs as shown. These values will be used before anything is actually fetched and cached from Firebase, for example, the first time your app is launched.

Upvotes: 1

Related Questions