@@ -22,11 +22,6 @@ import GoogleSignIn
2222 }
2323
2424 @objc public func signIn( completion: @escaping ( _ result: SignInResult ? , _ error: Error ? ) -> Void ) {
25- guard let viewController = plugin. bridge? . viewController else {
26- completion ( nil , CustomError . viewControllerUnavailable)
27- return
28- }
29-
3025 let signInCompletion : ( GIDSignInResult ? , Error ? ) -> Void = { result, error in
3126 if let error = error {
3227 if ( error as NSError ) . code == GIDSignInError . canceled. rawValue {
@@ -76,10 +71,16 @@ import GoogleSignIn
7671 completion ( signInResult, nil )
7772 }
7873
79- if let scopes = self . scopes, !scopes. isEmpty {
80- GIDSignIn . sharedInstance. signIn ( withPresenting: viewController, hint: nil , additionalScopes: scopes, completion: signInCompletion)
81- } else {
82- GIDSignIn . sharedInstance. signIn ( withPresenting: viewController, completion: signInCompletion)
74+ DispatchQueue . main. async {
75+ guard let viewController = self . plugin. bridge? . viewController else {
76+ completion ( nil , CustomError . viewControllerUnavailable)
77+ return
78+ }
79+ if let scopes = self . scopes, !scopes. isEmpty {
80+ GIDSignIn . sharedInstance. signIn ( withPresenting: viewController, hint: nil , additionalScopes: scopes, completion: signInCompletion)
81+ } else {
82+ GIDSignIn . sharedInstance. signIn ( withPresenting: viewController, completion: signInCompletion)
83+ }
8384 }
8485 }
8586
0 commit comments