[英]'Unable to fetch remote config. Cached or default values will be 'used' flutter
我已经为 flutter 设置了 firebase 配置
根据文档https://pub.dev/packages/firebase_remote_config#-readme-tab-
我的关键是
然后我也发布了然后我尝试了以下代码,它会返回
'无法获取远程配置。 缓存或默认值将被“使用”
你能指出问题吗
我也试过那些
try {
remoteConfig.getString('welcome')[![enter image description here][1]][1]
// Using default duration to force fetching from remote server.
await remoteConfig.fetch(expiration: const Duration(seconds: 0));
await remoteConfig.activateFetched();
} on FetchThrottledException catch (exception) {
// Fetch throttled.
print(exception);
} catch (exception) {
print(
'Unable to fetch remote config. Cached or default values will be '
'used');
}
这对我有用
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instance;
initializeRemote() async {
// remoteConfig = await setupRemoteConfig();
//!- must be active firebase remote config
bool updated = await remoteConfig.fetchAndActivate();
if (updated) {
print("found");
// the config has been updated, new parameter values are available.
} else {
print("not print");
// the config values were previously updated.
}
await remoteConfig.ensureInitialized().then((value) async {
print("remote value -> ${await remoteConfig.getString("app_version")}");
});
}
通常当你与这些问题作斗争时,最后,一切都会变得混乱。 我认为在发布后您已经可以看到配置的值,但是在查询另一个参数名称时会发生错误。 添加以下行以查看您得到的实际错误。
print('例外:$例外');
try {
await remoteConfig.fetch(expiration: const Duration(seconds: 0));
await remoteConfig.activateFetched();
String forceUpdateCurrentVersion =
remoteConfig.getString('force_update_current_version');
double newVersion =
double.parse(forceUpdateCurrentVersion.trim().replaceAll(".", ""));
if (newVersion > currentVersion) {
_showVersionDialog(context);
}
} on FetchThrottledException catch (exception) {
// Fetch throttled.
print(exception);
} catch (exception) {
print('EXCEPTION: $exception');
print('Unable to fetch remote config. Cached or default values will be '
'used');
}
如果您使用的是 Android 模拟器,请确保它启用了 Google Play 服务。
这对我来说很好,
await remoteConfig.ensureInitialized();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.