Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where did configuration argument go from GIDSignIn method?

I was rebuilding pet IOS project with google and facebook authorization. Google flow used to be like:

GIDSignIn.sharedInstance.signIn(with: config, presenting: presentingViewController) {

        user, error in ///bla bla bla }

But when the GoogleSignIn package was redownloaded, xcode started showing an error. And google authorization flow changed to

GIDSignIn.sharedInstance.signIn(withPresenting: presentingViewController) {

            user, error in ///bla bla bla }

The problem is when I'm doing auth in this "new" way my app crashes with message

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No active configuration.  Make sure GIDClientID is set in Info.plist.'

Also there is no information in google documentation and in github rep. Please help!

like image 863
Anna Avatar asked Dec 04 '25 14:12

Anna


1 Answers

The function updated and with: config parameter removed. Client_ID value from googleservice-info should be added info.plist as GIDClientID key. your function should be

func googleSign(){
  
    
    guard let presentingVC = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.windows.first?.rootViewController else {return}
    // Start the sign in flow!
    GIDSignIn.sharedInstance.signIn(withPresenting: presentingVC) { user, error in
        if let error = error {
            print(error.localizedDescription)
            return
          }

          guard let authentication = user?.authentication, let idToken = authentication.idToken
          else {
            return
          }

          let credential = GoogleAuthProvider.credential(withIDToken: idToken,
                                                         accessToken: authentication.accessToken)
        self.showCustomAlertLoading = true
        Auth.auth().signIn(with: credential) { authResult, error in
            guard let user = authResult?.user, error == nil else {
                self.signUpResultText = error?.localizedDescription ?? "Error Occured"
                DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
                    self.showCustomAlertLoading = false
                })
                return}
            self.signUpResultText = "\(user.email!)\nSigning Succesfully"
            self.isSignUpSucces = true
            DispatchQueue.main.asyncAfter(deadline: .now() + 3, execute: {
                self.showCustomAlertLoading = false
                DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
                    self.navigateHome = true
                })
            })
            print("\(user.email!) signed****")
            
        }
    }
}
like image 62
Abdullah Avatar answered Dec 07 '25 08:12

Abdullah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!