ASA*_*EED 8 ios firebase firebase-authentication flutter
我尝试使用 flutterfire 命令行工具将 firebase 添加到我的 flutter 项目中。我正在使用 firebase 的 Google 身份验证服务并调用SignIn函数,它给出以下错误。ios文件夹中有GoogleService-Info.plist文件。
Unhandled Exception: PlatformException(missing-config, GoogleService-Info.plist file not found and clientId was not provided programmatically., null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
<asynchronous suspension>
#2 GoogleSignInPlatform.initWithParams (package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart:98:5)
<asynchronous suspension>
#3 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:267:5)
<asynchronous suspension>
#4 GoogleSignIn.signIn.isCanceled (package:google_sign_in/google_sign_in.dart:402:5)
Run Code Online (Sandbox Code Playgroud)
Mäd*_*din 12
FlutterFire 命令行工具会生成一个 Dart 文件,因此您不需要GoogleService-Info.plist. GoogleService-Info.plist使用命令行工具插入while 是多余的。但是,您还必须在初始化时指定生成的选项:
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
Run Code Online (Sandbox Code Playgroud)
usingDefaultFirebaseOptions是将 Firebase 与 Flutter 结合使用的新方式,手动插入配置文件是旧方式。
编辑:我不明白这个问题与GoogleSignIn插件有关(我没有真正阅读堆栈跟踪)。在这种情况下,错误与错误消息中的错误完全相同。您尚未指定客户端 ID:
GoogleSignIn(clientId: DefaultFirebaseOptions.currentPlatform.iosClientId).signIn()
Run Code Online (Sandbox Code Playgroud)
编辑:是的,新版本flutterfire还会生成相应的文件,例如GoogleService-Info.plist,但您不再需要这些文件,因为参数clientId存在于GoogleSignIn插件中。