首页 > 解决方案 > 仅在 iOS / Flutter 中获取远程配置失败

问题描述

我已经为我的 Flutter 应用程序设置了 Firebase 远程配置。

final remoteConfig = RemoteConfig.instance;

final defaultValues = <String, dynamic>{
  'default_url': '',
};

await remoteConfig.setDefaults(defaultValues);
RemoteConfigValue(null, ValueSource.valueStatic);

try {
  await remoteConfig.setConfigSettings(RemoteConfigSettings(
    fetchTimeout: const Duration(seconds: 10),
    minimumFetchInterval: const Duration(hours: 1),
  ));
  await remoteConfig.fetchAndActivate();
} on PlatformException catch (exception) {
  print(exception);
} catch (exception) {
  print('Unable to fetch remote config. Cached or default values will be '
      'used');
  print(exception);
}

它在 Android 模拟器上运行良好,但只有在 iOS 模拟器和实际设备(我的 iPhone)上运行时才会输出错误。

flutter: Unable to fetch remote config. Cached or default values will be used
flutter: [firebase_remote_config/internal] internal remote config fetch error

而且,这在升级到 Flutter 2 (2.2.3) 后开始发生。

为什么会这样?

谢谢您的帮助。

标签: iosfirebaseflutterfirebase-remote-config

解决方案


推荐阅读