[英]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.我在 Android Studio 中使用 Flavor 在一台设备上部署不同的版本(Demo,Production),但我也使用 firebase 远程配置,我将它注册到一个包 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.是否可以让 firebase 远程配置在多个包 ID 中工作?,我想在我的演示和生产应用程序中使用它。
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 .对于每个环境,您的应用程序通常都有一个唯一的应用程序 ID ,这让它可以读取将要访问的项目的远程配置参数,这很容易使用Android 构建变体进行配置。
Here is my answer这是我的答案
Remote config can be setup for below conditions可以为以下条件设置远程配置
productFlavors
ex : amazonPay, amazonShopping不同的同一项目productFlavors
例如:amazonPay,amazonShoppingbuildTypes
ex : amazon.dev, amazon.prod, amazon.experiment具有不同buildTypes
相同项目,例如: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这是设置 remoteConfig 的示例代码,它可能会帮助您/其他人确保您在Application.java
文件的onCreate
中设置了 setupRemoteConfig
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.您可以在项目设置下添加多个应用程序包名称,以便它们都可以使用常见的 Firebase 服务。 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 .您可以为每个环境创建服务帐户,并且可以使用它,如果它是一个数据库,您可以为Production和Development创建两个单独的节点。
Thank You for reading感谢您的阅读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.