我正在使用具有两个项目 android 和 IOS 的 xamarin.forms PCL 项目
我在我的项目中集成了 facebook。
我在 facebook sdk 中传递了三个权限 public_profile
,email
,user_birthday
。
当我尝试通过 facebook 登录时,Facebook 权限对话框页面打开但它只要求接受两个权限 email
,public_profile
,它不询问 user_birthday
许可
以下是我的代码:
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;
}
});
在登录权限对话框中不询问生日,如下图所示
请提出解决办法
提前致谢
最佳答案
自 Graph API v2.0 以来,无法再获取 friend 的生日。您只能通过使用 user_birthday 权限来获取授权用户的生日。有关详细信息,请参阅更改日志:https://developers.facebook.com/docs/apps/changelog
只有另一种可能:如果 friend 使用user_birthday授权应用,你可以通过以下调用获取他的生日:/friend-id?fields=birthday
当然,您还需要使用 user_friends 对用户进行授权,才能完成这项工作。你也可以只存储所有授权用户的生日,不要浪费额外的 API 调用。 检查这个:
关于android - Facebook 登录权限对话框中未显示生日范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40885643/