Home > Software design >  iOS SwiftUI - Google Sign-In error: Extra argument 'callback' in call
iOS SwiftUI - Google Sign-In error: Extra argument 'callback' in call

Time:08-09

I got this code:

func signIn(){

   guard let presentingViewController = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.windows.first?.rootViewController else {return}

    let signInConfig = GIDConfiguration.init(clientID: "xxxxx")
    GIDSignIn.sharedInstance.signIn(
        with: signInConfig,
        presenting: presentingViewController,
        callback: { user, error in
            if let error = error {
                self.errorMessage = "error: \(error.localizedDescription)"
            }
            self.checkStatus()
        }
    )
}

I get the error "Extra argument 'callback' in call"

on the brace in

callback: { user, error in

please help

CodePudding user response:

You can try

GIDSignIn.sharedInstance.signIn(
    with: signInConfig,
    presenting: presentingViewController) { user, error in
      if let error = error {
            self.errorMessage = "error: \(error.localizedDescription)"
      }
      self.checkStatus()
    } 

Refer to Docs section 4. Add a Google Sign-In button

  • Related