0

I have problem to refresh remote config value in each seconds even i have set isDeveloperModeEnabled to be true. Here is the code to refresh cache in each second, i want to refresh it immediately because for testing purpose:

firebaseRemoteConfig.fetch(1) 
            .addOnCompleteListener { task ->
                if (task.isSuccessful) {
                    Log.d(TAG, "remote config is fetched.")
                    firebaseRemoteConfig.activateFetched()
                }
            }

and here i set developer mode becaome true:

val remoteConfig = FirebaseRemoteConfig.getInstance()
val configSettings = FirebaseRemoteConfigSettings.Builder()
            .setDeveloperModeEnabled(BuildConfig.DEBUG)
            .build()
    remoteConfig.setConfigSettings(configSettings)

the problem is still i cannot refresh remote config value in each second even though i have set developer mode become true ? should i wait 12 hour to test it ?

  • You do know remote config does not automatically refresh right? It will only refresh when you call `fetch` and the cache expiration has been hit so if you need to do it every second then you need some sort of polling interval to continually call that – tyczj Jan 18 '18 at 15:26

1 Answers1

0

check this out, see cache expires after 1hour, modify as your need

 private void fetch() {

    //loaded defaults..
    String result = mFirebaseRemoteConfig.getString(VERSION_CODE);
    Log.d(TAG, " remote  default value  before fetching : VERSION_CODE  : " + result);
    long cacheExpiration = 3600;
    if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
        cacheExpiration = 0;
    }

    mFirebaseRemoteConfig.fetch(cacheExpiration)
            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        Log.e(TAG, "Fetch Succeeded");
                        mFirebaseRemoteConfig.activateFetched();
                    } else {
                        Log.e(TAG, "Fetch Failed");
                    }
                    handlerResultRemoteConfig();
                }
            });
}
hemen
  • 1,460
  • 2
  • 16
  • 35