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

Open

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);
        }
    }

Activity

  1. alexshikov commented on Oct 10, 2023

    @alexshikov

    I have the same issue using Google.SignIn.SignIn.SharedInstance.SignedIn += OnSignedIn. It's never called and there are no errors or warning in the console.

    Zhangos have you been able to find a workaround or some ideas why it happens?

  2. alexshikov commented on Oct 10, 2023

    @alexshikov

    Surprisingly using SharedInstance.Delegate = this instead of SharedInstance.SignedIn += OnSignedIn started to work for me, where this implements ISignInDelegate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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