Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIViewController - issue #242

Open
DanielVagner opened this issue Dec 7, 2022 · 0 comments
Open

UIViewController - issue #242

DanielVagner opened this issue Dec 7, 2022 · 0 comments

Comments

@DanielVagner
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant