[英]Birthday scope not showing in facebook login permission dialog
我正在使用 xamarin.forms PCL 項目有兩個項目 android 和 IOS
我已經在我的項目中集成了 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 開始,不可能再獲得朋友的生日了。 您只能通過 user_birthday 權限獲取授權用戶的生日。 有關更多信息,請參閱變更日志: https : //developers.facebook.com/docs/apps/changelog
只有另一種可能:如果好友使用 user_birthday 授權應用程序,您可以通過以下調用獲取他的生日:/friend-id?fields=birthday
當然,您也需要使用 user_friends 來授權用戶,以便完成這項工作。 而且您還可以只存儲所有授權用戶的生日,而不會浪費額外的 API 調用。 檢查這個:
更改 user_birthday 的生日和 user_gender 的性別,然后按照https://developers.facebook.com/docs/facebook-login/review上的說明提交應用程序以查看權限
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.