I've followed the tutorial for Google Sign-In Swift and have the button showing, and am successfully redirected to log into an account. However, I want to segue to another view after a successful signin and the delegate function "didSignInFor" isn't being called. I've placed breakpoints at "didSignInFor" and "signIn Dispatch error" but none of them are being called.
Does anyone know what's wrong or what else I can check to figure out what's going wrong?
import UIKit import GoogleSignIn import FacebookLoginclass LoginViewController: UIViewController, GIDSignInUIDelegate, GIDSignInDelegate {
override func viewDidLoad() { super.viewDidLoad() var error: NSError? GIDSignIn.sharedInstance().uiDelegate = self GIDSignIn.sharedInstance().delegate = self } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { if let error = error { print("\(error.localizedDescription)") } else { // Perform any operations on signed in user here. let userId = user.userID // For client-side use only! let idToken = user.authentication.idToken // Safe to send to the server performSegue(withIdentifier: "LoginToDashboard", sender: self) } } func sign(inWillDispatch signIn: GIDSignIn!, error: Error!) { print(error) }
}
This is similar to this question but has not been answer: google signin not calling delegate method after success
GIDSignInDelegate? Maybe thedelegategets set to something else. - Julien Perrenoud