簡體   English   中英

AppDelegate不符合Swift 3中的協議'GIDSignInDelegate'

[英]AppDelegate does not conform to protocol 'GIDSignInDelegate' in Swift 3

我正在嘗試通過將Google登錄集成到應用中來使用他們的Google帳戶對Firebase進行身份驗證。

使用:

  • 斯威夫特3
  • Xcode 8
  • Firebase 3.11.1

我在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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM