是否可以针对用户行为获取特定的Firebase远程配置设置?

时间:2018-09-16 06:37:23

标签: android kotlin firebase-remote-config

是否可以根据用户输入或行为获取一组特定的Firebase远程配置参数?假设我们要求用户输入自己喜欢的颜色,然后我们想为使用该颜色的用户提供量身定制的远程配置,有什么方法可以做到?

我希望做类似的事情:

val settings = FirebaseRemoteConfigSettings.Builder()
  .setString(USER_FAVORITE_COLOR, editTextFavoriteColor.text)
  .build()

firebaseRemoteConfig.setConfigSettings(settings)
firebaseRemoteConfig.fetch()
  .addOnCompleteListener {
    if (it.isSuccessful) {
      firebaseRemoteConfig.activateFetched()
      textViewGreeting.text = "Hello, fellow 
      ${firebaseRemoteConfig.getString(BACKGROUND_COLOR)} lover"
    }
}

1 个答案:

答案 0 :(得分:0)

With a coworker's help we were able to figure this out!

firebaseAnalytics.setUserProperty(USER_FAVORITE_COLOR, favoriteColor)
firebaseRemoteConfig.fetch(0).addOnCompleteListener(remoteConfigFetchListener)

It even happens immediately! By the time remoteConfigFetchListener gets called the Remote Config values we can activateFetched() with are the ones that we configured in the Firebase Remote Config web console. :D