我正在向我的应用程序介绍Google登录,虽然Google和Firebase文档都足够彻底,但我所做的工作还不够.我还在犯这个错误。希望这将有助于其他人在提前实现自己的SDK....thanks时找到解决问题的方法,以便对这个庞然大物进行审查:

所以

P.S.我没有在这里添加GIDSignInDelegate到AppDelegate,因为我计划使用VC来处理登录逻辑,如下所示.
然后这个,据我所见.应该是谷歌需要与Firebase对话的所有内容:
// Implementing the required GIDSignInDelegate methods
func googleSignIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
if (error == nil) {
// Auth with Firebase
let userId = user.userID
let idToken = user.authentication.idToken
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
ref.authWithOAuthProvider("google", token: user.authentication.accessToken, withCompletionBlock: { (error, authData) in
// User is logged in!
})
} else {
print("\(error.localizedDescription)")
}
}
func googleSignOut() {
GIDSignIn.sharedInstance().signOut()
ref.unauth()
}
// Implement the required GIDSignInDelegate methods and Unauth when disconnected from Google
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!, withError error: NSError!) {
ref.unauth()
}
// IBAction to handle the sign-in process
@IBAction func googleButtonPressed(sender: TKTransitionSubmitButton!) {
GIDSignIn.sharedInstance().signIn()
}莫名其妙?对于长时间的guys...but,我已经完成了Firebase指南所建议的所有操作,这意味着AppDelegate的Google中的逻辑都在ProfileVC中。有什么指示吗?
发布于 2016-07-18 10:31:27
它是说您的类还没有为您的GIDSignInDelegate实现必需的方法。Swift 3中的方法名称有很大的变化。因此,您的新方法将是
公共函数符号(_ signIn: GIDSignIn!,didSignInFor用户: GIDGoogleUser!,withError错误: NSError!)
请检查图书馆屏幕截图。因此,在新的方法或类命名的新的3种约定中,In是缺失的。

发布于 2016-06-25 18:15:01
我通过键入"func“并在”建议“框中搜索找到了所需的方法。
哦,我想念Android的Alt+Enter功能
(顺便说一句,这是XCode 8 beta版的Swift 3版)
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: NSError!) {
let authentication = user.authentication
let credential = FIRGoogleAuthProvider.credential(withIDToken: (authentication?.idToken)!,
accessToken: (authentication?.accessToken)!)
let comp:FIRAuthResultCallback = { (user:FIRUser?, error:NSError?) in
if error == nil {
DataStorage.inst.user.id = user?.uid
}
}
FIRAuth.auth()?.signIn(with: credential, completion: comp)
}
func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: NSError!) {
}发布于 2016-09-23 10:35:47
只需替换
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
withError error: NSError!) {
if (error == nil) {
// Perform any operations on signed in user here.
} else {
print("\(error.localizedDescription)")
}}使用
public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
//Code
}https://stackoverflow.com/questions/36296798
复制相似问题