Авторизуйтесь через Xamarin.Auth в IOS Проект не работает - PullRequest
0 голосов
/ 29 апреля 2020

Я использую Xamarin.Auth для входа в Google и Facebook, он отлично работает с Android Project, но, похоже, докладчик не работает с IOS, он не может открыть браузер для входа в систему. Вот мой код для вызова Presenter в 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);

А вот мой AppDelegate в IOS проекте

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