How to log in to Facebook in Xamarin.Forms

前端 未结 7 1083
礼貌的吻别
礼貌的吻别 2020-11-27 11:30

I want to make a Xamarin.Forms project, targeting iOS, Android and Windows Phone.

My app needs to authenticate users using Facebook.

Should I implement login

相关标签:
7条回答
  • 2020-11-27 12:19

    Another addition to @NovaJoe's code, on iOS8 with Facebook, you'd need to modify the Renderer class as below to close the View after successful authentication.

    auth.Completed += (sender, eventArgs) => {
                // We presented the UI, so it's up to us to dimiss it on iOS.
    

    /*Importand to add this line */

                DismissViewController (true, null);
    

    /* */

                if (eventArgs.IsAuthenticated) {
                    App.Instance.SuccessfulLoginAction.Invoke ();
    
                    // Use eventArgs.Account to do wonderful things
                    App.Instance.SaveToken (eventArgs.Account.Properties ["access_token"]);
    
    
                } else {
                    // The user cancelled
                }
            };
    
    0 讨论(0)
提交回复
热议问题