[英]'AppDelegate' does not conform to protocol 'GIDSignInDelegate'
[英]AppDelegate does not conform to protocol 'GIDSignInDelegate' in Swift 3
我正在尝试通过将Google登录集成到应用中来使用他们的Google帐户对Firebase进行身份验证。
使用:
我在AppDelegate中实现了GIDSignInDelegate
的两种方法
// Sign-in flow has finished and was succcesful if error is nil:
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!){
if let error = error {
print(error.localizedDescription)
return
}
guard let authentication = user.authentication else { return }
let credential = FIRGoogleAuthProvider.credential(withIDToken: authentication.idToken,
accessToken: authentication.accessToken)
// Finished disconnecting user from the app succesfully if error is nil:
func sign(_ signIn: GIDSignIn!, didDisconnectWithUser user: GIDGoogleUser!,
withError error: Error!) {
// Perform any operations when the user disconnects from app here.
// ...
}
但我仍面临编译问题:
AppDelegate不符合协议'GIDSignInDelegate'
看起来您在AppDelegate
类之外定义了该协议的方法,因此它们只是全局函数,而不是方法。
你需要在关闭AppDelegate
的}
中移动它们(就在第一个协议方法之上)。
提示 :如果您选择该文件中的所有代码并按
Ctrl+I
Xcode将重新启动您的代码,这样可以更容易地查看出现了什么问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.