2013-08-04 44 views
1

我試圖在Facebook上分享。 但每次它請求發佈權限時,它都會指示一個屏幕 「您已授權給」AppName「」。當我點擊確定。它把我帶到了黑屏。面向iOS的Facebook Sdk發佈-dark屏幕

這是我的流程。 1.登錄Facebook 2.申請發佈許可。 3.發佈到Facebook牆上。

[FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"] 
             defaultAudience:FBSessionDefaultAudienceFriends 
            completionHandler:^(FBSession *session, NSError *error) { 
             if (!error) { 
              // Now have the permission 
              [self publishStory]; 
             } else { 
              // Facebook SDK * error handling * 
              // if the operation is not user cancelled 
              if (error.fberrorCategory != FBErrorCategoryUserCancelled) { 
               [self presentAlertForError:error]; 
              } 
             } 
            }]; 
+0

沒有u盤了烏爾facebookAppId和URL方案....? –

+0

是的。我可以登錄Facebook。 – user1302602

+0

[見這裏] [1],可以幫助你,張貼一些更多的代碼 [1]:http://stackoverflow.com/questions/16052078/facebook-registration-the-operation-couldnt-be -completed-COM-Facebook的SDK-ER –

回答

0

你可以這樣做,

在打開的會話指定權限發佈後

NSArray *permissions = [[NSArray alloc] initWithObjects:@"publish_actions",@"publish_stream",nil]; //permissions 
    return [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session,FBSessionState state,NSError *error) 


,每當你要發佈,做這樣的


NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithObjectsAndKeys:TextView.text, @"message",nil]; // set the formats 
if([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] != NSNotFound) 
{ 
    [FBRequestConnection startWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) 
    { 
     NSString *alertText; 
     if(error) 
     { 
       //if error occurred 

     } 
     else 
     { 
      //successfull 
     } 

    }]; 

    } 

} 


相關問題