简体   繁体   中英

Birthday scope not showing in facebook login permission dialog

I am using xamarin.forms PCL Project having two project android and IOS

I have integrated facebook in my project. I pass three permission public_profile , email , user_birthday in facebook sdk. when I try to login through facebook, Facebook permission dialog page open but it ask to accept only two permission email , public_profile , It not ask user_birthday permission

Following is my code:

    public class FacebookLoginButtonRenderer : ButtonRenderer,IFacebook
    {
        private static Activity _activity;

        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged(e);

            _activity = this.Context as Activity;

            if (this.Control != null)
            {
                Android.Widget.Button button = this.Control;
                button.SetOnClickListener(ButtonClickListener.Instance.Value);
            }
        }

        void IFacebook.Logout()
        {
            LoginManager.Instance.LogOut();
        }

        private class ButtonClickListener : Object, IOnClickListener
        {
            public static readonly Lazy<ButtonClickListener> Instance = new Lazy<ButtonClickListener>(() => new ButtonClickListener());

            public void OnClick(View v)
            {
                LoginManager.Instance.LogInWithReadPermissions(_activity, new List<string> { "public_profile","email","user_birthday"});
            }
        }
    }

  FacebookClient fb = new FacebookClient(AccessToken);
   fb.GetTaskAsync("me?fields=id,email,first_name,last_name,gender,birthday").ContinueWith(t =>   
            {
                if (!t.IsFaulted)
                {

                    var obj = (IDictionary<string, object>)t.Result;
}
});

In login permission dialog not asking for birthday as shown in below image

在此处输入图片说明

Please suggest how to solve this

Thanks in advance

Since v2.0 of the Graph API, it´s not possible to get friend birthdays anymore. You can only get the birthday of the authorized user by using the user_birthday permission. See the changelog for more information: https://developers.facebook.com/docs/apps/changelog

There is only one other possibility: If the friend authorized the App with user_birthday, you can get his birthday with the following call: /friend-id?fields=birthday

Of course you need to authorize users with user_friends too, in order to make this work. And you can also just store the birthday of all authorized users and don´t waste an extra API call on it. Check This :

How to get friend's birthday list using facebook api?

更改 user_birthday 的生日和 user_gender 的性别,然后按照https://developers.facebook.com/docs/facebook-login/review上的说明提交应用程序以查看权限

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM