什么是Firebase远程配置开发人员模式 [英] What is Firebase Remote Config Developer Mode

查看:60
本文介绍了什么是Firebase远程配置开发人员模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

第二,我在应用程序的调试版本中测试我的测试布尔值,其值设置为5分钟或小时,但仍然总是在3秒内得到我的值.当我将 setDeveloperModeEnabled 设置为false或根本没有将 FirebaseRemoteConfigSettings 添加到我的实例时,我仍然没有观察到著名的节气门异常,并且立即获得了我的值.基本上看起来好像我的缓存设置被忽略了,而且我总是从后端获取新数据,并且可以将缓存设置为所需的低水平.

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.

推荐答案

setDeveloperModeEnabled()已弃用.他们现在使用 setMinimumFetchIntervalInSeconds()来设置缓存过期延迟.

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

检查此行的gradle,并确保它的版本为 19.1.4 (截至今天)或更高版本:实现'com.google.firebase:firebase-config:19.1.4'

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对您可以进行的提取请求数量有一个配额.开发人员模式是一种使自己的设备可以随时获取而不受限制的方式,但是您不能在启用了开发人员模式的情况下发布您的应用程序(仍然需要指定间隔)

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)

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

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 不再受支持,这可能就是为什么您没有观察到其行为发生任何变化的原因

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

这篇关于什么是Firebase远程配置开发人员模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆