我已经将我的应用程序连接到Firebase,并使用谷歌登录方法。整个签到的代码块发生在AppDelegate中。从那里,如果登录成功,我想把用户带到另一个视图控制器。
我读到过,这是通过提到 window?.rootViewController
但似乎AppDelegate不再包含了 window
.
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
// ...
if let error = error {
print(error)
return
}
guard let authentication = user.authentication else { return }
let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
accessToken: authentication.accessToken)
Auth.auth().signIn(with: credential, completion: { (authResult, error) in
if let error = error {
print(error)
}
// take me somewhere here //
})
// ...
}