I am using Firebase and GoogleSignIn to sign up user's to my iOS App. I have written all the code, as instructed, in the AppDelegate.swift file. After the login is successful, I want to take the user to another ViewController. My current code is;
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if (error) != nil {
return
}
print("User signed into Google")
guard let authentication = user.authentication else { return }
let credential = FIRGoogleAuthProvider.credential(withIDToken: authentication.idToken,
accessToken: authentication.accessToken)
FIRAuth.auth()?.signIn(with: credential, completion: { (user, error) in
print("User Signed In to Firebase")
self.databaseRef = FIRDatabase.database().reference()
self.databaseRef.child("Google User Profiles").child(user!.uid).observeSingleEvent(of: .value, with: { (snapshot) in
let snapshot = snapshot.value as? NSDictionary
if(snapshot == nil)
{
self.databaseRef.child("Google User Profiles").child(user!.uid).child("name").setValue(user?.displayName)
self.databaseRef.child("Google User Profiles").child(user!.uid).child("email").setValue(user?.email)
}
})
})
}