[英]Firebase Remote Config isDeveloperModeEnabled() is deprecated
I'm trying to have a remote config parameter using the Remote Config feature of Firebase so I can get values from Firebase and use it in app.我正在尝试使用 Firebase 的远程配置功能来获得远程配置参数,以便我可以从 Firebase 获取值并在应用程序中使用它。 I already use it with no problem but after a Firebase update, I get this warning:
我已经毫无问题地使用它,但在 Firebase 更新后,我收到以下警告:
I tried to use getMinimumFetchIntervalInSeconds()
instead of isDeveloperModeEnabled()
in order to avoid the warning.我尝试使用
getMinimumFetchIntervalInSeconds()
而不是isDeveloperModeEnabled()
以避免警告。
Here is my code:这是我的代码:
final FirebaseRemoteConfig mFirebaseRemopteconfig = FirebaseRemoteConfig.getInstance();
long cachExpiration = 0;
if (mFirebaseRemopteconfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cachExpiration = 0;
}
mFirebaseRemopteconfig.fetch(cachExpiration)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
final String funct = mFirebaseRemopteconfig.getString("functionn");
if (getPackageName().compareTo(funct) != 0) {
finish();
}
mFirebaseRemopteconfig.activateFetched();
}
}
});
Any idea how to solve this problem?知道如何解决这个问题吗?
About setMinimumFetchIntervalInSeconds
, it is officially said :关于
setMinimumFetchIntervalInSeconds
, 官方说:
Keep in mind that this setting should be used for development only, not for an app running in production.
请记住,此设置应仅用于开发,而不应用于在生产中运行的应用程序。 If you're just testing your app with a small 10-person development team, you are unlikely to hit the hourly service-side quota limits.
如果您只是在一个 10 人的小型开发团队中测试您的应用程序,那么您不太可能达到每小时服务端配额限制。 But if you pushed your app out to thousands of test users with a very low minimum fetch interval, your app would probably hit this quota.
但是,如果您以非常低的最小获取间隔将您的应用程序推送给数千名测试用户,您的应用程序可能会达到这个配额。
Although you can setMinimumFetchIntervalInSeconds
other than the default value (= 12 hours), it's all up to you about whether it would hit the quota or not, and may lead to FirebaseRemoteConfigFetchThrottledException
.虽然您可以设置除默认值(= 12 小时)以外的
setMinimumFetchIntervalInSeconds
,但它是否会达到配额完全取决于您,并且可能导致FirebaseRemoteConfigFetchThrottledException
。
Now, the new API requires you to setMinimumFetchIntervalInSeconds
for altering the interval.现在,新的 API 要求您
setMinimumFetchIntervalInSeconds
来更改间隔。 It is a method of FirebaseRemoteConfigSettings.Builder
.它是
FirebaseRemoteConfigSettings.Builder
的一种方法。 So you must build a FirebaseRemoteConfigSettings
object through the builder after setMinimumFetchIntervalInSeconds
, and then setConfigSettingsAsync
the built FirebaseRemoteConfigSettings
to your FirebaseRemoteConfig
.因此,您必须在
setMinimumFetchIntervalInSeconds
之后通过构建器构建一个FirebaseRemoteConfigSettings
object ,然后将构建的FirebaseRemoteConfigSettings
设置为setConfigSettingsAsync
到您的FirebaseRemoteConfig
。
Here is an example of my own implementation:这是我自己的实现示例:
if (BuildConfig.DEBUG) {
cacheExpiration = 0;
} else {
cacheExpiration = 43200L; // 12 hours same as the default value
}
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings
.Builder()
.setMinimumFetchIntervalInSeconds(cacheExpiration)
.build();
config = FirebaseRemoteConfig.getInstance();
config.setConfigSettingsAsync(configSettings);
config.fetch(cacheExpiration).addOnCompleteListener(activity, onCompleteListener);
--------------------------- revised --------------------------- - - - - - - - - - - - - - - 修改 - - - - - - - - - - - -----
For your porpose为了你的建议
checking if package name is the same
检查 package 名称是否相同
you don't need isDeveloperModeEnabled()
or any interval settings.您不需要
isDeveloperModeEnabled()
或任何间隔设置。 Just fetch()
without any settings (but with default settings):只需
fetch()
没有任何设置(但使用默认设置):
mFirebaseRemopteconfig = FirebaseRemoteConfig.getInstance();
mFirebaseRemopteconfig.fetch()
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
final String funct = mFirebaseRemopteconfig.getString("functionn");
if (getPackageName().compareTo(funct) != 0) {
finish();
}
mFirebaseRemopteconfig.activateFetched();
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.