Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

Xamarin.Google.iOS.SignIn 5.0.2.4 does not call ISignInUIDelegate methods #629

@Zhangos

Description

@Zhangos

Xamarin.Google.iOS.SignIn version 5.0.2.4 does not call ISignInUIDelegate methods when calling SignIn.SharedInstance.SignInUser();

 var topViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
 if (topViewController.PresentedViewController != null)
       topViewController = topViewController.PresentedViewController;
 if (topViewController is UINavigationController navigationController)
       topViewController = navigationController.TopViewController;
 Google.SignIn.SignIn.SharedInstance.PresentingViewController = topViewController;
 Google.SignIn.SignIn.SharedInstance.Delegate = new GoogleSignInDelegate(signInResponse, googleTimer);
 Google.SignIn.SignIn.SharedInstance.SignInUser();
    class GoogleSignInDelegate : NSObject, ISignInDelegate
    {
        private Timer googleTimer;
        private readonly TaskCompletionSource<WebAuthenticatorResult> signInResponse;
        public GoogleSignInDelegate(TaskCompletionSource<WebAuthenticatorResult> signInResponse, Timer googleTimer)
        {
            this.signInResponse = signInResponse;
            this.googleTimer = googleTimer;
        }
        public async void DidSignIn(SignIn signIn, GoogleUser user, NSError error)
        {
            System.Diagnostics.Debug.Write("GoogleSignInDelegate >>>>> call DidSignIn");
            if (error != null)
            {
                if (error.Code == -5)
                {
                    signInResponse?.TrySetCanceled();
                }
                else
                {
                    signInResponse?.TrySetException(new Exception(error.Description));
                }
                System.Diagnostics.Debug.Write($"GoogleSignInDelegate error>>>>> {error.Description}");
                return;
            }
            var authenticatorResult = new WebAuthenticatorResult();
            authenticatorResult.Properties.Add("code", user.ServerAuthCode);
            signInResponse?.TrySetResult(authenticatorResult);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions