[英]How to request Facebook publish_actions permission during login in iOS
To request facebook publish_actions permission during login in android I do 要在Android登录期间请求Facebook publish_actions权限,我需要
loginButton = (LoginButton) view.findViewById(R.id.login_button);
loginButton.setPublishPermissions(“publish_actions”);
loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {
@Override
public void onUserInfoFetched(GraphUser user) {
FacebookOptInFragment.this.user = user;
updateUI();
}
});
That's all I need to do and I am done. 这就是我需要做的,我已经完成。 User will first login and then get prompted to grant publishing permission.
用户将首先登录,然后提示您授予发布权限。 How do I do the exact same thing in iOS?
如何在iOS中执行完全相同的操作?
Note that I just now downloaded the Facebook SDK, which means I have the latest and greatest (in case that is relevant). 请注意,我刚刚下载了Facebook SDK,这意味着我拥有最新和最好的(如果相关)。
Some documentation first 首先介绍一些文档
Requesting publishing permissions with publish_actions during login creates a second step in the login UI.
登录期间使用publish_actions请求发布权限会在登录UI中创建第二步。 So you should request minimum read permissions during login then request any additional or publish permissions when someone actually needs them.
因此,您应该在登录期间请求最低读取权限,然后在某人实际需要它们时请求任何其他权限或发布权限。 To optimize your permission requests, see Optimizing Permissions.
要优化您的权限请求,请参阅优化权限。
So If all you need is to authorize your iOS app and grant publish_actions
permission and if you really want integrate with iOS Facebook account, you have to ask for reading permission before you ask for the publishing permission. 因此,如果您只需要授权您的iOS应用并授予
publish_actions
权限,并且您确实要与iOS Facebook帐户集成,则必须先获得阅读权限,然后才能获得发布权限。 See the Request at Login portion
of the page link above for getting read permissions. 请参阅上面页面链接的“
Request at Login portion
以获取读取权限。
Then you can request additional permissions for publish_actions
like 然后,您可以为
publish_actions
请求其他权限,例如
// Request publish_actions
[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
__block NSString *alertText;
__block NSString *alertTitle;
if (!error) {
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound){
// Permission not granted, tell the user we will not publish
alertTitle = @"Permission not granted";
alertText = @"Your action will not be published to Facebook.";
[[[UIAlertView alloc] initWithTitle:alertTitle
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil] show];
} else {
// Permission granted, publish the OG story
[self publishStory];
}
} else {
// There was an error, handle it
// See https://developers.facebook.com/docs/ios/errors/
}
}];
Check this portion of the docs for permission management as well 同时检查文档的这一部分以进行权限管理
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.