gpt4 book ai didi

android - Firebase 远程配置 isDeveloperModeEnabled() 已弃用

转载 作者:行者123 更新时间:2023-12-05 00:20:05 26 4
gpt4 key购买 nike

我正在尝试使用 Firebase 的远程配置功能拥有一个远程配置参数,以便我可以从 Firebase 获取值并在应用程序中使用它。我已经毫无问题地使用它,但是在 Firebase 更新后,我收到了以下警告:

screenshot

我尝试使用 getMinimumFetchIntervalInSeconds()而不是 isDeveloperModeEnabled()为了避免警告。

这是我的代码:

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();
}
}
});

知道如何解决这个问题吗?

最佳答案

关于 setMinimumFetchIntervalInSeconds , 是 officially said :

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. 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.



虽然可以 setMinimumFetchIntervalInSeconds除了默认值(= 12 小时),是否达到配额完全取决于您,并且可能导致 FirebaseRemoteConfigFetchThrottledException .

现在,新的 API 要求您使用 setMinimumFetchIntervalInSeconds用于更改间隔。这是 的方法FirebaseRemoteConfigSettings.Builder .所以你必须建立一个 FirebaseRemoteConfigSettingssetMinimumFetchIntervalInSeconds 之后通过构建器创建对象,然后是 setConfigSettingsAsync内置 FirebaseRemoteConfigSettings给您的 FirebaseRemoteConfig .

这是我自己的实现示例:
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);

- - - - - - - - - - - - - - 修改 - - - - - - - - - - - -----

为了你的建议

checking if package name is the same



你不需要 isDeveloperModeEnabled()或任何间隔设置。只需 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();
}
}
});

关于android - Firebase 远程配置 isDeveloperModeEnabled() 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61237265/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com