Search code examples
androidfirebasefirebase-remote-config

What is Firebase Remote Config Developer Mode


I am adding Firebase Remote Config to an app and I am confused about the purpose of .setMinimumFetchIntervalInSeconds(...) & .setDeveloperModeEnabled(true/false) . The docs talk about a developer mode, but I'm not sure they clearly explain what it actually does. Does it have to be used in tandem with setMinimumFetchIntervalInSeconds or can it be used on its own , and if on its own, what does it then do?

Secondly I'm testing my test boolean value in a debug build of the app, with values set to 5 minutes or hours but still I always get my value within 3 seconds. when I set setDeveloperModeEnabled to false or not add the FirebaseRemoteConfigSettings to my instance at all, I still have not observed the famed throttle exception and I get my values immediately. It basically looks like my cache settings are being ignored and I always get fresh data from the backend and I can set the cache as low as I want.


Solution

  • setDeveloperModeEnabled() is deprecated. They use setMinimumFetchIntervalInSeconds() instead now to set the cache expiration delay.

    Check your gradle for this line and make sure it's version 19.1.4 (as of today) or newer: implementation 'com.google.firebase:firebase-config:19.1.4'

    Firebase has a quota for the number of fetch requests you can make. Developer mode is a way to greenlight your own device to be able to fetch at any time without restriction but you can't release your app with developer mode enabled (in which you still have to specify the interval)

    if you are on v17.0.0, use this code by changing the cacheExpiration value to your desired one.

    long cacheExpiration = 3600;
        mFirebaseRemoteConfig.setConfigSettingsAsync(new FirebaseRemoteConfigSettings.Builder() 
           .setMinimumFetchIntervalInSeconds(cacheExpiration)
           .build());
    
    //** deprecated */
    //mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
    
    mFirebaseRemoteConfig.setDefaultsAsync(R.xml.remote_config_defaults);
    
    mFirebaseRemoteConfig.fetchAndActivate()
    .addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
        @Override
        public void onComplete(@NonNull Task<Boolean> task) {
            if (task.isSuccessful()) {
                boolean updated = task.getResult();
                Log.d(TAG, "Config params updated: " + updated);
                Toast.makeText(MainActivity.this, "Fetch and activate succeeded " + updated,
                        Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(MainActivity.this, "Fetch failed",
                        Toast.LENGTH_SHORT).show();
            }
            updateConfig();
        }
    });
    

    setDeveloperModeEnabled is not supported anymore, which is probably why you didn't observe any change in its behaviour