Login with Xamarin.Auth in IOS Project is not working

544 Views Asked by At

I'm using Xamarin.Auth to login to google and facebook, It works fine with Android Project but seem like presenter is not working with IOS, it can't opon the browser for login. Here is my code to call Presenter in viewmodel

var authenticator = new OAuth2Authenticator(
                    clientId,
                    constants.FacebookScope,
                    new Uri(constants.FacebookAuthorizeUrl),
                    new Uri(constants.FacebookAccessTokenUrl),
                    null,
                    true
                );

            authenticator.Completed += OnAuthCompleted;
            authenticator.Error += OnAuthError;

            AuthenticationState.Authenticator = authenticator;

            var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
            presenter.Login(authenticator);

And Here is my AppDelegate in IOS project

 public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    //
    // This method is invoked when the application has loaded and is ready to run. In this 
    // method you should instantiate the window, load the UI into it and then make the window
    // visible.
    //
    // You have 17 seconds to return from this method, or iOS will terminate your application.
    //
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        FFImageLoading.Forms.Platform.CachedImageRenderer.Init();
        Rg.Plugins.Popup.Popup.Init();

        global::Xamarin.Forms.Forms.Init();
        global::Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration.Init();
        //global::Xamarin.Auth.WebViewConfiguration.IOS.UserAgent = "moljac++";


        XamEffects.iOS.Effects.Init();
        FFImageLoading.Forms.Platform.CachedImageRenderer.Init();
        CachedImageRenderer.InitImageSourceHandler();



        LoadApplication(new App());

        return base.FinishedLaunching(app, options);
    }

    public override bool OpenUrl
    (
        UIApplication application,
        NSUrl url,
        string sourceApplication,
        NSObject annotation
    )
    {
        // Convert iOS NSUrl to C#/netxf/BCL System.Uri - common API
        Uri uri_netfx = new Uri(url.AbsoluteString);

        // load redirect_url Page (send it back to Xamarin.Auth)
        //  for Url parsing and raising Complete or Error events
        AuthenticationState.Authenticator.OnPageLoading(uri_netfx);

        return true;
    }
}
0

There are 0 best solutions below