简体   繁体   中英

How to use Firebase Remote Config in multiple package id (same project) Android

I have used Flavour in Android studio for deploy different version(Demo,Production) in one device, but I also use firebase remote config where I registered it to one package id. is it possible to make firebase remote config works in multiple package id?, I want to use it in my Demo and Production app.

The documented advice for working with multiple environments , such as development and production, is to have one project for each environment. Your app will typically have a unique application ID for each environment, which lets it read remote config parameters for the project that it will access, which is easy to configure with Android build variants .

Here is my answer

Remote config can be setup for below conditions

  • Only for different projects : ex : amazon, flipkart
  • Same project with different productFlavors ex : amazonPay, amazonShopping
  • Same project with different buildTypes ex : amazon.dev, amazon.prod, amazon.experiment

Here is sample code to setup remoteConfig, it might help you/others Make sure you setupRemoteConfig in onCreate of Application.java file

private void setupRemoteConfig() {
    final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
    remoteConfig.setDefaults(R.xml.remote_config_default);
    remoteConfig.fetch(300).addOnCompleteListener(task -> {
        if (task.isSuccessful()) {
            remoteConfig.activateFetched();
        }
    });
}

You can add multiple application package names under project settings so that they all can use common firebase services. In this way, you can share single project resources among multiple applications.

You can create service accounts for every environment and you can use that, if its a database you can create two separate nodes for Production and Development .

Thank You for reading

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM