What is Firebase Remote Config Developer Mode
Asked Answered
R

1

5

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.

Ransom answered 7/5, 2019 at 9:15 Comment(0)
C
24

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

Cincture answered 1/6, 2019 at 23:20 Comment(7)
Interesting! How do you know that setDeveloperModeEnabled() is deprecated?Ransom
Firebase Remote Config docs. AndroidStudio should also flag it as deprecated if you are using the right version of firebaseCincture
@RedaHammoud: In this code, you haven't specified the developer mode.So if we make the setMinimumFetchIntervalInSeconds() as 10 in production app, then how will firebase know if it is developer mode or prodcution?Settler
@adi: setMinimumFetchIntervalInSeconds(BuildConfig.DEBUG ? 0 : 300)Selfcontrol
@frapeti: But as per you, we are checking debug mode ourselves and setting the time ourselves, but then also , firebase can't differentiate between whether developer is using a dev mode or production mode?Settler
@Settler you check debug mode yourself to set a lower delay for yourself as a dev and a higher delay for other users. As far as I know, Firebase doesn't care much about the mode, they just care about you not hitting your fetch limitsCincture
For your information - the default minimum fetch interval lasts 12 hours. More information here: firebase.google.com/docs/remote-config/…Gerita

© 2022 - 2024 — McMap. All rights reserved.