SLServiceTypeFacebook setInitialText不起作用

时间:2015-04-28 17:13:03

标签: ios social-framework

我正在尝试在IOS 8.3上使用SLServiceTypeFacebook在Facebook上分享文本。但弹出文本框显示为空。我希望它在文本中显示。下面你可以看到我用的代码。

 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) 
 {
       SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

       [controller setInitialText:@"First post from my iPhone app"];
       [self presentViewController:controller animated:YES completion:Nil];
  }

3 个答案:

答案 0 :(得分:32)

安装最新的Facebook应用更新(v29)似乎是一个问题。删除它"修复"问题。

https://developers.facebook.com/bugs/1632385646995079/ https://developers.facebook.com/bugs/962985360399542/

更新(2015年6月3日)

好。似乎新的Facebook政策表明,通过setInitialText:预先填写邮件是违规行为。

https://developers.facebook.com/docs/apps/review/prefill

所以我想从现在开始分享内容的唯一方法是FBSDKShareDialog

https://developers.facebook.com/docs/sharing/ios

答案 1 :(得分:1)

一定要喜欢Facebook的效率。我有点晚了但可能会帮助别人。

#import <FBSDKShareKit/FBSDKShareKit.h>

FBSDKShareLinkContent  *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = self.urlForSocialMedia;
content.contentDescription = self.textForFB;
content.contentTitle = @"Results.";

[FBSDKShareDialog showFromViewController:self
                             withContent:content
                                delegate:self];

答案 2 :(得分:0)

在setInitialText之前,在此测试之前添加#。代码如下。这对我有用

SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    [mySLComposerSheet setInitialText:@"#myInitialTextIsHere"];
    [mySLComposerSheet addURL:[NSURL URLWithString:strURL]];

    [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {

        switch (result) {
            case SLComposeViewControllerResultCancelled:
                NSLog(@"Post Canceled");
                break;
            case SLComposeViewControllerResultDone:
                NSLog(@"Post Sucessful");
                break;

            default:
                break;
        }
    }];

    [self presentViewController:mySLComposerSheet animated:YES completion:nil];