I've been following this tutorial here for adding google sign in to my iOS app:https://www.youtube.com/watch?v=TfYIH_23c6w&t=353s
and everything looks good except for this line here:
GIDSignIn.sharedInstance.signIn(with: config, presenting:ApplicationUtility.rootViewController) {
The error is Type of expression is ambiguous without more context
in this file:
//
// LoginVM.swift
// frcscout
//
// Created by Elliot Scher on 12/14/22.
//
import Foundation
import Firebase
import GoogleSignIn
class SignUpViewModel: ObservableObject {
@Published var isLogin: Bool = false
func signInWithGoogle() {
guard let clientId = FirebaseApp.app()?.options.clientID else { return }
let config = GIDConfiguration(clientID: clientId)
GIDSignIn.sharedInstance.signIn(with: config, presenting:ApplicationUtility.rootViewController) {
[self] user, err in
if let error = err {
print(error.localizedDescription)
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) { result, error in
if let error = err {
print(error.localizedDescription)
return
}
guard let user = result?.user else { return }
print(user.displayName)
isLogin.toggle()
}
}
}
}
I'm not sure what this error means. How can I fix it? Thanks!!
1/ Config info.plist
https://developers.google.com/identity/sign-in/ios/start-integrating#add_client_id
2/ Download new GoogleService-Info.plist from firebase
3/ use below function
@objc func signInWithGooglePressed(sender: Any) {