A Comprehensive Guide on Firebase Remote Config for Android

A Comprehensive Guide on Firebase Remote Config for Android

What is Remote Config you may ask?

This. It’s just this: a set of key-value pairs stored on the Firebase servers. That’s it. That’s literally it.

But what can it do?

Well well well, where do I begin?

What you do with Remote Config is retrieve these parameters which can have different values for different users depending on certain conditions you can set (e.g. locale, random percentile).

Tailored App Experiences

You can give different segments of your users customised in-app experiences depending on their preferences. For example, you have a hard game level and you may find that this causes backlash in some countries while certain other countries actually like the challenge.

Each segment can have their settings tweaked (as fetched from Remote Config) so everyone’s happy. I touched on how to do this in detail in my User Segmentation series.

Gradually Roll Out Updates

If you have an update you think could potentially cause a major negative impact, you could slowly roll out your update to an increasing percentile of your users to avoid a potentially damaging aversion.

To do this, you can update your app to activate its updated version based on parameters fetched from Remote Config. In the Firebase Console, set the Remote Config parameters with a condition to Users in a Random Percentile and slowly increase this percentile whenever you feel like it.

Quickly Deploy Updates

If you have values in your app that sync their value with parameters fetched from Remote Config, changing the parameter values from Remote Config will update the data in the app almost instantly.

A/B Testing

Although A/B Tests have sort of become a separate thing, they are still essentially Remote Config at core. Different parameters are temporarily offered to different groups of users and each group is analysed with a goal set (for example, an increase in user engagement).

To do this, go to Firebase Console > A/B Testing and I’ll be honest, the rest is pretty self-explanatory.

Initial Setup

Before you can start fetching parameters, you need to setup. Setup is a thing people tend to do.

1. ConfigDefaults.xml

The first step is to create an xml file and put it in your res/xml directory (It doesn’t have to be called ConfigDefaults or put in res/xml but I recommend you do) which you’ll be referencing.

After that, go to the Firebase Console and in Remote Config, set up the same parameters with their same default values as you did in ConfigDefaults.xml.

Doing this will ensure your Remote Config delivers a smooth experience online and offline.

2. Import the Dependency

Add this to your app-level  build.gradle as you do.

3. Instantiate Remote Config and Set Defaults

Instantiate and set the defaults to your xml file you created just earlier. Just note that if your defaults in your xml file and the console differ (You would rather they not), the defaults from the console will take priority.

The Fetching Parameters Process

The process is divided into SettingFetching, and Getting.

Setting

In Remote Config in the Firebase Console, when you add (or edit) parameters, you’ll see a button that says Add Value for Condition. Here you define different values that will get fetched (with a function covered below) when the user meets certain conditions you also define here.

Fetching

Fetch the parameters to get the user’s corresponding value into the app. fetch is an async task so you have to add listeners and only when you call  activateFetched will the fetched values be activated in your app. Once activated, you can start getting values from the remote config with the newly fetched values.

Getting

After fetching the values and activating them, retrieving each parameter is as simple as calling any of these getSomething methods.

Conclusion

And that pretty much sums it up. If you want me to put together a sample app, just leave it as a comment and I’ll get around it eventually.