CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

UIViewController - issue

Open DanielVagner opened this issue 3 years ago • 0 comments

Hi, I'm trying to get back to you with a problem.

I am using capacitor 4 with your library version 3.2.0. I add ios with npx cap ios add and then open xcode with npx cap ios open. Same steps like always.

In xcode, I add a file from google - plist and then add the reverse client id to the url. And I will build the application. At this point I get build failed and a link to the GoogleAuth plugin.

The error is: node_modules/@codetrix-studio/capacitor-google-auth/ios/Plugin/Plugin.swift:65:92: error build: Value of optional type 'UIViewController?' must be unwrapped to a value of type 'UIViewController'

Your code:

 @objc
    func signIn(_ call: CAPPluginCall) {
        signInCall = call;
        DispatchQueue.main.async {
            if self.googleSignIn.hasPreviousSignIn() && !self.forceAuthCode {
                self.googleSignIn.restorePreviousSignIn() { user, error in
                if let error = error {
                    self.signInCall?.reject(error.localizedDescription);
                    return;
                }
                self.resolveSignInCallWith(user: user!)
                }
            } else {
                let presentingVc = self.bridge!.viewController;       
                self.googleSignIn.signIn(with: self.googleSignInConfiguration, presenting: presentingVc) { user, error in
                    if let error = error {
                        self.signInCall?.reject(error.localizedDescription, "\(error._code)");
                        return;
                    }
                    if self.additionalScopes.count > 0 {
                        // requesting additional scopes in GoogleSignIn-iOS SDK 6.0 requires that you sign the user in and then request additional scopes,
                        // there's no method to include the additional scopes in the initial sign in request
                        self.googleSignIn.addScopes(self.additionalScopes, presenting: presentingVc) { user, error in
                            if let error = error {
                                self.signInCall?.reject(error.localizedDescription);
                                return;
                            }
                            self.resolveSignInCallWith(user: user!);
                        }
                    } else {
                        self.resolveSignInCallWith(user: user!);
                    }
                };
            }
        }
    }

I am using xcode version 14.0.1

Thanks in advance for your help

DanielVagner avatar Dec 07 '22 17:12 DanielVagner