Use Firebase Remote Config on Android

Updated 24 November 2017

Save

Firebase remote config helps you to change the appearance and behavior of your app without updating it on Playstore. It actually provides you the facility to override some defaults value which was defined in the app from Firebase console at runtime and using those values you can change the appearance and behavior of your app. You can also control the time for which the values will be cached in the app and after that, they will be fetched again. It helps you to perform A/B testing because you can set the values with conditions like countries and many more. Remote Config includes a client library that handles tasks like fetch and caching and provide you the easy control over the time for caching and all.

Let us look at the steps to use Firebase Remote Config in your android app.

  1. Add Firebase Remote Config to your app: You will have to add the dependency to access the classes of remote config.
  2. Get the FirebaseRemoteConfig object: By using the static method getInstance() of class FirebaseRemoteConfig to get the instance which will be used to set the defaults and fetch the new values from firebase.
  3. Set in-app default parameter values: You should set in-app default values so that your app will behave properly till the values been fetched from the server. To set the default value you need to create an xml file and use the setDefaults() to set the xml.

    your remote_config_defaults.xml may look like below given example

    the keys loading_phrase, welcome_message_caps, and welcome_message are already defined in the firebase console and their values are be set in the console.
  4. Get parameter values to use in your app: Now to get the values from the firebase you will have to use the FirebaseRemoteConfig object. It provide various methods like getString(), getBoolean() etc which will provide you the value you have set for them.

     

    That’s all, This is a free facility provided by Google so make the best use of it and make your app with dynamic behavior. For more details, you can always refer to the documentation provided by google.

    Thank you very much. This is Vedesh Kumar signing off.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home