在我的iPhone集成Facebook应用程序,但是当我发布在我的墙上,我的朋友无法分享我应该怎么办? [英] In my iPhone integrating Facebook app but when i post on my wall my friend unable to share what should i do?

查看:177
本文介绍了在我的iPhone集成Facebook应用程序,但是当我发布在我的墙上,我的朋友无法分享我应该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Facebook整合我的一个iOS应用程序它共享报价。但问题是,当我的时间线上的报价发布时,我的朋友们无法分享赞和评论。我想要分享,请看附件截图
所以最好的解决方案是在我的FB应用程序有问题,或者我必须在iOS中做代码。



FB的屏幕截图



感谢提前

解决方案

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



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

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

UIApplication * app = [UIApplication sharedApplication];
app.networkActivityIndi​​catorVisible = NO;

SLComposeViewController * controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

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

NSLog(@\\\
Cancelled);
} else
{
NSLog(@\\\
Done);
}

[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:
//首先显示Hud视图,然后启动post message feed进程
[self postFBMessageOnUserWall];
break;
case FBSessionStateClosed:
//需要处理
break;
case FBSessionStateClosedLoginFailed:
//需要处理
break;
默认值:
break;
}
}];


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

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

//显示警告说该消息成功发布在你的墙上
[self performSelectorOnMainThread:@selector(showAlertFromMainThread :) withObject:error waitUntilDone:NO];

NSLog(@\\\
\\\
fb post feed error status =%@,error);
}];
}


I using facebook integrate for one of my iOS application it share quote. But problem is that when quote post on my timeline my friends not able to share just "Like" and "Comment". I want share to please see attach screenshots so whats the best solution for that is there problem in my FB app or I've to do code for that in iOS.

Screenshot of FB

Thanks in Advance

解决方案

I checked your screenshot. That looks like fb "like post" basically. Since no one can't share this post. I would suggest you to use latest ios fb sdk 3.1.1 and then integrate that FB sdk with your ios app. Then use the following code

For ios 6 and later use ios 6 native fb post method:

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];
}

otherwise use this FB sdk method:

    [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);
      }];
}

这篇关于在我的iPhone集成Facebook应用程序,但是当我发布在我的墙上,我的朋友无法分享我应该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆