Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Using Google SignIn SDK Component with Xamarin.Forms PageRenderer Does Not Display Login UI

$
0
0

I'm attempting to use the Google Sign In SDK Component within a Xamarin.Forms application, however, I am unable to get the button click to actually display the Google Sign In SDK Login View.

I've attached the normal iOS sample solution that works [GoogleSignIn.zip]. I've also attached a Forms sample solution that uses a PageRenderer that does not work [GoogleSignInForms.zip]. I created it following this Xamarin Blog post: https://blog.xamarin.com/using-custom-uiviewcontrollers-in-xamarin-forms-on-ios/ that does not work.

The SignIn functionality requires a UIViewController to implement the ISignInUIDelegate interface which is why I am using the PageRenderer.

I'm referencing the documentation included with the component sample and the documentation from Google located here: https://developers.google.com/identity/sign-in/ios/sign-in

Any help is greatly appreciated as I've tried numerous ways to get this working and have been unable to get it to work.

Here's the guts of the PageRenderer:

using Xamarin.Forms;
using CoreGraphics;
using Google.SignIn;
using GoogleSignInForms.Views;
using GoogleSignInForms.iOS.Renderers;

[assembly:ExportRenderer(typeof(GoogleSignInPage), typeof(GoogleSignInPageRenderer))]
namespace GoogleSignInForms.iOS.Renderers
{
    public class GoogleSignInPageRenderer : Xamarin.Forms.Platform.iOS.PageRenderer, ISignInUIDelegate
    {
        private SignInButton signinButton;

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            signinButton = new SignInButton();
            signinButton.Frame = new CGRect(20, 100, 150, 44);
            View.AddSubview(signinButton);

            SignIn.SharedInstance.UIDelegate = this;

            SignIn.SharedInstance.SignedIn += (sender, e) => {
                // Perform any operations on signed in user here.
                if (e.User != null && e.Error == null)
                {

                }
            };

            SignIn.SharedInstance.Disconnected += (sender, e) => {
                // Perform any operations when the user disconnects from app here.

            };
        }
    }
}


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>