Search code examples
androidfirebasefirebase-analyticsfirebase-remote-config

Firebase remote config values not consistent after user properties are changed on app


So I've tried to use a custom user property (user_code) as a conditional for my feature toggle in Firebase Remote Config. My use case is, I set the custom user property and fetch and activate (via fetchAndActivate) the remote configs on successful log in, and reset the user property on log out by passing null to setUserProperty on log ou. I also set it on app start up if user is already logged in, alongside with fetching and activate remote configs.

// on log in success
FirebaseAnalytics.getInstance(context).setUserProperty("user_code", someUserCode)
firebaseRemoteConfig.fetchAndActivate().addOnCompleteListener { task ->
  if (task.isSuccessful) {
     Log.w(TAG, "Config params updated and activated: ${task.result}")
  } else {
     Log.w(TAG, "Config params update failed")
  }
}

I've set up a conditional in such a way that if user_code user property is equal to abcd, the remote flag value that I should be getting is true, false if user_code is equal to something else. I can confirm that this is indeed the case, when I log in using the account with user_code equal to abcd. If I try to log out and log in using a different account, I get the correct feature toggle value (false). But when I try to log in again using the account with abcd as the user_code , the previous remote config values are still being used, i.e., the feature toggle is still false, when it is supposed to be true. However, when I restart my app, I get the updated values (the flag is now equal to true).

During app startup, if user is logged in, I set the user property and initialize Firebase Remote config and call fetchAndActivate:

//inside App class
if (someUserCode != null) {
   FirebaseAnalytics.getInstance(context).setUserProperty("some_user_code", someUserCode)
}
with(firebaseRemoteConfig) {
 setConfigSettingsAsync(
    remoteConfigSettings {
       minimumFetchIntervalInSeconds = 0L
    }
 )
 setDefaultsAsync(R.xml.remote_config_defaults)
 fetchAndActivate()
}

I am consistently seeing this behavior by logging in and logging out multiple times. The only way to get the updated remote config values is by restarting the app. I want to get the updated remote configs after log in, not just when the app is restarted. Has anyone encountered this?


Solution

  • I got in touch with Firebase customer support and they clarified that my use case won't work with Firebase Remote Config. Fetching remote config values in quick succession will be subject to throttling.