什么是Firebase远程配置开发人员模式

Tom*_*ala 0 android firebase firebase-remote-config

我将Firebase Remote Config添加到应用程序,并且对.setMinimumFetchIntervalInSeconds(...)& 的用途感到困惑.setDeveloperModeEnabled(true/false)。这些文档讨论的是开发人员模式,但我不确定他们是否清楚地解释了其实际功能。它必须与之串联使用setMinimumFetchIntervalInSeconds还是可以单独使用,如果单独使用,它会做什么?

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.

Red*_*oud 7

不推荐使用setDeveloperModeEnabled()。他们现在使用setMinimumFetchIntervalInSeconds()来设置缓存过期延迟。

检查此行的通讯座,并确保它是17.0.0版(截至今天)或更高版本:实现'com.google.firebase:firebase-config:17.0.0'

Firebase对您可以进行的提取请求数量有一个配额。开发人员模式是一种使您自己的设备能够在没有限制的情况下随时进行获取的方式,但是您不能在启用了开发人员模式的情况下发布您的应用程序(在该模式下,您仍然必须指定间隔)

如果您使用的是v17.0.0,请通过将cacheExpiration值更改为所需的值来使用此代码。

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();
    }
});
Run Code Online (Sandbox Code Playgroud)

setDeveloperModeEnabled不再受支持,这可能就是为什么您没有观察到其行为发生任何变化的原因

  • [Firebase 远程配置文档](https://firebase.google.com/docs/reference/android/com/google/firebase/remoteconfig/FirebaseRemoteConfigSettings.Builder.html#setDeveloperModeEnabled(boolean))。如果您使用的是正确版本的 firebase,AndroidStudio 也应该将其标记为已弃用 (3认同)