访问第二个项目的 "Remote config"

Access "Remote config" of second project

我们可以访问多个 Firebase 数据库,

// Retrieve my other app.
FirebaseApp app = FirebaseApp.getInstance("secondary");
// Get the database for the other app.
FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(app);

同理,我的第二个项目Remote config有什么方法可以访问吗??

参考: Accessing the Databases from two different Firebase projects

提前致谢!

不,远程配置没有这样的机制。 Remote Config 与 Firebase Analytics 紧密相关,后者也仅限于每个应用程序一个实例。 Remote Config 使用 Analytics 了解有关用户的一些信息,以确定他们应该为特定参数获得什么值。因此,您必须接受 Remote Config 也将使用的默认项目计算 "user"。

我不知道 Firebase 是什么时候添加这个 api 的,但他们似乎已经添加了一个方法到 return a 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 并观察结果,它会 return 成功并在大多数情况下得到布尔值 false 的结果——因为您已经得到了一个激活远程配置(我猜)。

只需在此处写下以帮助未来的 google 员工;)