I've recently updated the current version of GoogleSignIn and can't find a solution to this problem Im facing. The error Im receiving is: Value of type 'GIDSignInResult' has no member 'authentication'
func googleSignInAction(){
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
let config = GIDConfiguration(clientID: clientID)
GIDSignIn.sharedInstance.signIn(withPresenting: self) { user, error in
if let error = error {
print("There is an error signing the user in ==> \(error)")
return
}
guard let authentication = user?.authentication, let idToken = authentication.idToken else { return }
let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: authentication.accessToken)
Auth.auth().signIn(with: credential) { authResult, error in
if error != nil {
print(error)
} else {
self.email = authResult?.user.email
self.photoURL = authResult?.user.photoURL!.absoluteString
self.checkIfUserAccountExists()
}
}
}
//PRevious code that worked
// GIDSignIn.sharedInstance.signIn(with: config, presenting: self) { [unowned self] user, error in
//
// if let error = error {
// print("There is an error signing the user in ==> \(error)")
// return
// }
//
// guard let authentication = user?.authentication, let idToken = authentication.idToken else { return }
// let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: authentication.accessToken)
//
// Auth.auth().signIn(with: credential) { authResult, error in
// if error != nil {
// print(error)
// } else {
// self.email = authResult?.user.email
// self.photoURL = authResult?.user.photoURL!.absoluteString
// self.checkIfUserAccountExists()
// }
// }
// }
}
The old closure is updated from user, error in
to authentication, error in
where authentication
is of type GIDSignInResult
func googleSignInAction() {
GIDSignIn.sharedInstance.signIn(withPresenting: self) { authentication, error in
if let error = error {
print("There is an error signing the user in ==> \(error)")
return
}
guard let user = authentication?.user, let idToken = user.idToken?.tokenString else { return }
let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: user.accessToken.tokenString)
Auth.auth().signIn(with: credential) { authResult, error in
if error != nil {
print(error)
} else {
self.email = authResult?.user.email
self.photoURL = authResult?.user.photoURL!.absoluteString
self.checkIfUserAccountExists()
}
}
}
}