![](/img/trans.png)
[英]Facebook iOS SDK request permission publish_actions, but user need to input password again
[英]How to request Facebook publish_actions permission during login in iOS
要在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();
}
});
這就是我需要做的,我已經完成。 用戶將首先登錄,然后提示您授予發布權限。 如何在iOS中執行完全相同的操作?
請注意,我剛剛下載了Facebook SDK,這意味着我擁有最新和最好的(如果相關)。
首先介紹一些文檔
登錄期間使用publish_actions請求發布權限會在登錄UI中創建第二步。 因此,您應該在登錄期間請求最低讀取權限,然后在某人實際需要它們時請求任何其他權限或發布權限。 要優化您的權限請求,請參閱優化權限。
因此,如果您只需要授權您的iOS應用並授予publish_actions
權限,並且您確實要與iOS Facebook帳戶集成,則必須先獲得閱讀權限,然后才能獲得發布權限。 請參閱上面頁面鏈接的“ Request at Login portion
以獲取讀取權限。
然后,您可以為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/
}
}];
同時檢查文檔的這一部分以進行權限管理
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.