2015-03-03 79 views
1

要在android系統登錄時要求的Facebook publish_actions允許我做登錄時如何申請的Facebook publish_actions許可iOS中

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,這意味着我有最新最好的(以及相關的情況)。

+0

你永遠不應該要求在登錄publish_actions。你應該只在需要的時候這樣做 – WizKid 2015-03-03 04:08:14

+0

@WizKid感謝您的建議:)。這實際上是我整個應用程序需要的唯一一件事。所以基本上這就是我正在做的。 – 2015-03-03 04:12:44

+0

您在登錄時直接在人員時間表上發佈內容?在@WizKid上執行 – WizKid 2015-03-03 04:26:46

回答

0

一些documentation第一

請求與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/ 
             } 
            }]; 

檢查this部分的文檔許可管理

+0

感謝您的回覆。但我已經嘗試了你的建議,但它不起作用。看到以下問題,我作爲結果詢問:http://stackoverflow.com/questions/28843758/how-do-i-login-with-facebook-in-my-ios-app – 2015-03-04 15:22:41

+0

鏈接似乎不存在 ? – Slartibartfast 2015-03-05 00:50:50

+0

我發現自己問了一個基本相同的問題,只是因爲我無法得到完整的答案。所以我刪除了那個。 – 2015-03-05 18:42:53