Ios 谷歌登录后的Segue

Ios 谷歌登录后的Segue,ios,swift,segue,google-signin,google-login,Ios,Swift,Segue,Google Signin,Google Login,谷歌登录后,我的服务器无法工作。首先,我使用SwiftKeychainWrapper来存储用户信息。我在facebook上使用过它,但现在我正在设置谷歌登录,它坏了。我尝试了几种不同的方法:将委托放入appDelegate,但这不允许使用segue,将委托放入登录VC,它就是不移动 有人能帮忙吗 导入UIKit 进口火基 导入快捷键链包装器 导入FBSDKCoreKit 导入FBSDKLoginKit 进口谷歌签名 类签名:UIViewController、GIDSignInUIDelegat

谷歌登录后,我的服务器无法工作。首先,我使用SwiftKeychainWrapper来存储用户信息。我在facebook上使用过它,但现在我正在设置谷歌登录,它坏了。我尝试了几种不同的方法:将委托放入appDelegate,但这不允许使用segue,将委托放入登录VC,它就是不移动

有人能帮忙吗

导入UIKit
进口火基
导入快捷键链包装器
导入FBSDKCoreKit
导入FBSDKLoginKit
进口谷歌签名
类签名:UIViewController、GIDSignInUIDelegate、GIDSignInDelegate、UIExtFieldDelegate{
@IBOutlet弱var emailField:UITextField!
@IBOUTLE弱var密码字段:UITextField!
重写func viewDidLoad(){
super.viewDidLoad()
self.emailField.delegate=self
self.passwordField.delegate=self
GIDSignIn.sharedInstance().uiDelegate=self
GIDSignIn.sharedInstance().signizely()
GIDSignIn.sharedInstance().clientID=FirebaseApp.app()!.options.clientID
GIDSignIn.sharedInstance().delegate=self
}
覆盖函数视图显示(u动画:Bool){
如果let=KeychainWrapper.standard.string(forKey:KEY\u UID){
打印(“注意:在钥匙链中找到ID”)
性能检查(标识符为“goToFeed”,发送方为零)
}
}
func符号(signIn:GIDSignIn!,didsignin用户:GIDGoogleUser!,withError错误:error!){
if(GIDSignIn.sharedInstance().hasAuthInKeychain()){
打印(“已登录”)
performsgue(标识符为“goToFeed”,发送方为self)
}
}
func Googleb标签(uu发件人:任何){
如果let authentication=user.authentication
{
让credential=GoogleAuthProvider.credential(withIDToken:authentication.idToken,accessToken:authentication.accessToken)
Auth.Auth()?.signIn(使用:凭证,完成:{(用户,错误)->Void in
如果错误!=nil
{
打印(“使用google登录时出现问题,错误:\(错误)”)
}
如果错误==nil,则为else{
打印(“用户通过GOOGLE!uid:\(FIRAuth.auth()!.currentUser!.uid)成功登录”)
}
})
}
}
@iAction func FaceBookB已标记(u发件人:AnyObject){
让facebookLogin=FBSDKLoginManager()
facebookLogin.logIn(具有readPermissions:[“email”],发件人:self){(结果,错误)在中
如果错误!=nil{
打印(“注意:无法通过Facebook验证-\(字符串(描述:错误)))
}如果结果为?.isCancelled==true,则为else{
打印(“注意:用户已取消Facebook身份验证”)
}否则{
打印(“注意:已成功通过Facebook验证”)
让credential=FacebookAuthProvider.credential(withAccessToken:FBSDKAccessToken.current().tokenString)
self.firebaseAuth(凭证)
}
}

}
只需在您的
googleBtnTapped
函数中调用
GIDSignIn.sharedInstance().signIn()
,如下所示:

func googleBtnTapped(_ sender: Any) {
    GIDSignIn.sharedInstance().signIn()
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
    if let authentication = user.authentication {
        let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken, accessToken: authentication.accessToken)

        Auth.auth()?.signIn(with: credential, completion: { (user, error) -> Void in
            if error != nil {
                print("Problem at signing in with google with error : \(error)")
            } else if error == nil {
                print("user successfully signed in through GOOGLE! uid:\(FIRAuth.auth()!.currentUser!.uid)")
                print("signed in")
                performSegue(withIdentifier: "goToFeed", sender: self)
            }
        })
    }
}
然后将身份验证码放入
符号
函数中,如下所示:

func googleBtnTapped(_ sender: Any) {
    GIDSignIn.sharedInstance().signIn()
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
    if let authentication = user.authentication {
        let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken, accessToken: authentication.accessToken)

        Auth.auth()?.signIn(with: credential, completion: { (user, error) -> Void in
            if error != nil {
                print("Problem at signing in with google with error : \(error)")
            } else if error == nil {
                print("user successfully signed in through GOOGLE! uid:\(FIRAuth.auth()!.currentUser!.uid)")
                print("signed in")
                performSegue(withIdentifier: "goToFeed", sender: self)
            }
        })
    }
}

我也想在上面的解决方案中添加。不要忘记在
viewController
中添加
GIDSignIn.sharedInstance().delegate=self
,否则它将不起作用