Xamarin.Auth Facebook 给出 NullReferenceException 2

Xamarin.Auth Facebook gives NullReferenceException 2

我正在关注 This Page 以及 Xamarin.Auth github 存储库中的一些示例,因此设置了 facebook 登录。我创建了以下登录功能:

public void Authenticate()
{
    string clientId = Config.FacebookAppID;
    string redirectUri = redirectUri = "MyApp:/authorize";
    var authenticator = new OAuth2Authenticator(
        clientId: clientId,
        scope: "public_profile,email",
        authorizeUrl: new Uri("https://www.facebook.com/v2.9/dialog/oauth"),
        redirectUrl: new Uri(redirectUri),
        getUsernameAsync: null,
        isUsingNativeUI: true);

    authenticator.AllowCancel = true;
    authenticator.Completed += OnAuthCompleted;
    authenticator.Error += OnAuthError;
    Authenticator = authenticator;

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

但我在最后一行收到以下异常:

{System.NullReferenceException: Object reference not set to an instance of an object.
  at Xamarin.Auth.Presenters.OAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00011] in C:\cxa\source\Xamarin.Auth.LinkSource\Request.cs:290 
  at MyApp.Components.AuthorisationManager.Authenticate () [0x00078] in D:\Dev\MenuSystem.AdminApp\MyApp\MyApp\MyApp\Components\AuthorisationManager.cs:56 
  at MyApp.ViewModels.MainPageViewModel.NavigateToMenuItem () [0x00008] in D:\Dev\MenuSystem.AdminApp\MyApp\MyApp\MyApp\ViewModels\MainPageViewModel.cs:63 }

知道我做错了什么吗?

我知道这已经有一年多了,但是,我 运行 在接受了指导性的链接培训后遇到了同样的问题。

答案是在AppDelegateclass中的FinishedLaunching方法中初始化AuthenticationConfiguration

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    // Override point for customization after application launch.
    // If not required for your application you can safely delete this method
    // Add the Init() method here
    global::Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration.Init();
    return true;
}