在我的iPhone集成Facebook应用程序,但当我在我的墙上发布我的朋友无法分享我该怎么办?

时间:2012-05-25 07:01:44

标签: iphone ios facebook

我使用facebook集成我的一个iOS应用程序它共享报价。但问题是,当我的时间线上的帖子发布时,我的朋友们无法分享“赞”和“评论”。我想分享请看附加截图 那么最好的解决方案就是我的FB应用程序中存在问题,或者我要在iOS中为此做代码。

Screenshot of FB

先谢谢

1 个答案:

答案 0 :(得分:0)

我检查了你的截图。这看起来像fb“喜欢帖子”基本上。由于没有人不能分享这篇文章。我建议你使用最新的ios fb sdk 3.1.1,然后将你的FB sdk与你的ios应用程序集成。然后使用以下代码

对于ios 6及更高版本,使用ios 6原生fb post方法:

if(NSClassFromString(@"SLComposeViewController") != nil) {

        UIApplication* app = [UIApplication sharedApplication];
        app.networkActivityIndicatorVisible = NO;

        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {

                NSLog(@"\nCancelled");                
            } else
            {
                NSLog(@"\nDone");
            }

            [controller dismissViewControllerAnimated:YES completion:Nil];
        };
        controller.completionHandler =myBlock;

        [controller setInitialText:FB_POST_FEED_INITIAL_TEXT_MSG];
        [controller addURL:[NSURL URLWithString:BITLY_VIEW_LINK]]; // youtube video link

        [self presentViewController:controller animated:YES completion:Nil];
}

否则使用此FB sdk方法:

    [FBSession openActiveSessionWithReadPermissions:nil
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session,
       FBSessionState state, NSError *error) {
         switch (state) {
             case FBSessionStateOpen:
                 //first shows the hud view then initiating the post message feed process
                 [self postFBMessageOnUserWall];
                  break;
             case FBSessionStateClosed:
                 //need to handle
                 break;
             case FBSessionStateClosedLoginFailed:
                 //need to handle
                 break;
             default:
                 break;
         }
     }];


-(void)postFBMessageOnUserWall {
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                             FB_POST_FEED_INITIAL_TEXT_MSG, @"name", BITLY_VIEW_LINK, @"link", nil];

     [FBRequestConnection
      startWithGraphPath:@"me/feed"
      parameters:params
      HTTPMethod:@"POST"
      completionHandler:^(FBRequestConnection *connection,
                          id result,
                          NSError *error) {

          //show the alert says that message successfully posted in your wall
          [self performSelectorOnMainThread:@selector(showAlertFromMainThread:) withObject:error waitUntilDone:NO];

          NSLog(@"\n\nfb post feed error status  = %@", error);
      }];
}