大佬教程收集整理的这篇文章主要介绍了swift – 通过Firebase登录Google:GIDSignInDelegate不符合ViewController,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是Firebase guide和Google guide:
所以
>将Google添加到podfile – checK
>在Bridging-Header中添加了行 – checK
>添加了Googleservice-Info.plist&捆绑标识符&将客户端ID反转为URL方案 – 检查
> App Delegate有以下@L_262_9@,没有错误,但我注意到Facebook登录(正常工作)和新Google之间可能存在冲突,我不知道如何一起处理:
附:我没有在这里向AppDelegate添加GIDSignInDelegate,因为我正计划让我的VC处理登录逻辑,如下所示……
> LoginVC ViewController代码:
class LoginVC: UIViewController,UIViewControllerTransitioningDelegate,UITextViewDelegate,UITextFieldDelegate,GIDSignInDelegate,GIDSignInUIDelegate { override func viewDidLoad() { super.viewDidLoad() let ref = Firebase(url: "https://MYAPPID.firebaseio.com") GIDDSignIn.sharedInstance().delegate = self GIDSignIn.sharedInstance().uiDelegate = self GIDSignIn.sharedInstance().signInSilently() // for if the user has recently been authenticated }
然后,从我所看到的……应该是Google需要与Firebase交流的所有@L_262_9@:
// 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() }
百思不得其解?很抱歉这些人很久……但我已经完成了Firebase指南建议的所有@L_262_9@,这意味着AppDelegate的Google文档中的逻辑就在ProfileVC中.有什么指针吗?
以上是大佬教程为你收集整理的swift – 通过Firebase登录Google:GIDSignInDelegate不符合ViewController全部内容,希望文章能够帮你解决swift – 通过Firebase登录Google:GIDSignInDelegate不符合ViewController所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。