Facebook SDK, How do I check if a user has accepte

2019-07-21 15:25发布

I've got to a point in my app where a user can login via the Facebook SDK. The app requests read and publish permissions. Is there a way to check if they have accepted the publish permissions before carrying on? The permission is "publish_actions". I tried doing Session.getPermissions(); but only the read permissions are listed there (basic_info, user_birthday, user_friends).

It seems like there is no way to check if the user accepted my publish permission, is there a possible workaround to this?

The reason I need to check for this is because the permissions can be revoked by the user at any time from their profile, so I can't have them login then revoke the permissions, otherwise that would defeat the purpose of asking for it.

Would really appreciate some help, thank you. Hopefully it's possible and not a Facebook restriction (Although I can sort of see why if it was).

3条回答
贼婆χ
2楼-- · 2019-07-21 16:12

I think the Best way to check for permission:

Facebook SDK 4.+ :

if (AccessToken.getCurrentAccessToken().getPermissions().contains("publish_actions")) { 
    //permission exists
}
查看更多
手持菜刀,她持情操
3楼-- · 2019-07-21 16:14

According to Facebook SDK v4+:

To get the list of permissions associated with the current access token, call:

AccessToken.getCurrentAccessToken().getPermissions();

To get the list of declined permissions, call:

AccessToken.getCurrentAccessToken().getDeclinedPermissions();
查看更多
对你真心纯属浪费
4楼-- · 2019-07-21 16:18

For your app, you can use any valid user access token, and make a call to /me/permissions, and it will return a list of permissions that the user has granted your app.

For more docs, see https://developers.facebook.com/docs/graph-api/reference/user/permissions/

查看更多
登录 后发表回答