Android “访问”;远程配置";第二个项目
我们可以访问多个Firebase数据库Android “访问”;远程配置";第二个项目,android,firebase,firebase-realtime-database,firebase-remote-config,Android,Firebase,Firebase Realtime Database,Firebase Remote Config,我们可以访问多个Firebase数据库 // Retrieve my other app. FirebaseApp app = FirebaseApp.getInstance("secondary"); // Get the database for the other app. FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(app); 同样,有没有办法访问我的第二个项目远程配置 参考: 提前谢谢 不,远程
// Retrieve my other app.
FirebaseApp app = FirebaseApp.getInstance("secondary");
// Get the database for the other app.
FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(app);
同样,有没有办法访问我的第二个项目远程配置
参考:
提前谢谢 不,远程配置没有这种机制。远程配置与Firebase Analytics密切相关,Firebase Analytics也仅限于每个应用程序一个实例。远程配置使用分析来了解用户的一些情况,以确定他们应该为特定参数获得什么值。因此,您必须接受远程配置也将使用默认项目的“用户”计算。我不知道Firebase是什么时候添加此api的,但似乎他们添加了一个方法来返回
RemoteConfig
,参考FirebaseApp
,因为上次回答:
// Retrieve secondary app.
FirebaseApp app = FirebaseApp.getInstance("secondary");
// Get the remote config for the other app.
FirebaseRemoteConfig secondaryRemoteConfig = Firebase.remoteConfig(app);
// Or another way
// FirebaseRemoteConfig secondaryRemoteConfig = FirebaseRemoteConfig.getInstance(app);
注意:当然,您仍然需要在使用此远程配置之前获取它
secondRemoteConfig.fetch().addOnSuccessListener {
Log.d("RemoteConfig", "Secondary: finished fetch, ready to use.")
};
另外,请注意,如果您调用fetchAndActivate
并观察结果,那么在大多数情况下,它将返回success,结果为Booleanfalse
——因为您已经激活了一个远程配置(我猜是这样)
写在这里,帮助未来的谷歌人;) 我花了几个小时试图理解为什么远程配置只使用默认的本地值,而不真正获取任何内容。拯救生命的答案。谢谢。