ios - 在 Firebase 中,使用 FlutterFire,如何在 iOS 上初始化辅助应用程序?InitializeApp 与选项给出 GOOGLE_APP_ID 错误
问题描述
在 Flutter 应用程序中,使用 FlutterFire 连接到 Firebase,使用以下代码连接到辅助存储:
FirebaseApp hostApp;
try {
hostApp = Firebase.app("HostApp");
} catch (e) {
hostApp = await Firebase.initializeApp(
name: 'HostApp',
options: FirebaseOptions(
appId: ConfigService.hostAppId,
apiKey: ConfigService.hostApiKey,
authDomain: ConfigService.hostAuthDomain,
storageBucket: ConfigService.hostStorageBucket,
projectId: ConfigService.hostProjectId,
messagingSenderId: ConfigService.hostMessagingSenderId));
}
_storage = firebase_storage.FirebaseStorage.instanceFor(app: hostApp);
在 Android 上有效,但在 iOS 上,initializeApp 出现此错误:
7.3.0 - [Firebase/Core][I-COR000009] The GOOGLE_APP_ID either in the plist file 'GoogleService-Info.plist' or the one set in the customized options is invalid.
If you are using the plist file, use the iOS version of bundle identifier to download the file, and do not manually edit the GOOGLE_APP_ID. You may change your app's bundle identifier to 'app.myapp'.
Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.
*** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c627b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010c08c141 objc_exception_throw + 48
2 CoreFoundation 0x000000010c690625 +[NSException raise:format:] + 197
3 Runner 0x00000001088fb926 +[FIRApp addAppToAppDictionary:] + 278
4 Runner 0x00000001088fab12 +[FIRApp configureWithName:options:] + 1266
我添加了 iosClientId 和 iosBundleId 选项,但给出了同样的错误。
默认应用程序已经初始化:
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
捆绑包标识符是正确的。
如何在 iOS 上初始化辅助应用程序?
解决方案
我使用的是网络 appId(例如 1:12345678: web :123abcd456efg78)。我已经更改了 iOS appId 的 appId 并且它可以工作。
在 Android 上有效,但在 iOS 上给出此错误。
推荐阅读
- javascript - 从 Firestore 读取不返回任何内容
- sql - 从表中删除额外的匹配项
- python-3.x - Agg 和 groupby 按特定条件
- linux - 如何在 tsv 文件列表(数百个)中查找单词列表(以千为单位),输出为每个文件中每个字符串的匹配数,在 linux 中?
- javascript - 如何根据范围滑块更改图像?
- node.js - 如何从没有外部 smtp 服务器的云服务器使用 Node.js 发送电子邮件?
- ios - 从 iOS 快捷方式中的字典中提取特定值以显示在从列表中选择菜单中?
- ruby-on-rails - rails 如何以及在何处为模型属性定义 getter 和 setter 方法
- python - ValueError:无法在 Django 外键中分配错误
- intellij-idea - 黄瓜报告在带有 inteliij 的黄瓜的控制台中显示 Given 而不是 And