![](/img/trans.png)
[英]'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.