FBSDKShareLinkContent未设置contentDescription和contentTitle

时间:2015-04-28 10:16:10

标签: ios iphone facebook sdk share

我正在尝试使用FBSDKShareLinkContent在Facebook上分享链接。

我已设置了网址,说明和标题。 SDK会根据contentURL中删除的信息自动填充标题和说明。

但是我想设置我在代码中给出的自定义标题和描述。反正有没有避免这种行为?

  FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
[content setContentTitle:@"Testing title"];
[content setContentDescription:@"Testing description."];
content.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.google.co.in/"]];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];

3 个答案:

答案 0 :(得分:15)

我遇到了同样的问题,发现了一种解决方法 - 将FBSDKShareDialog实例直接设置为FBSDKShareDialogModeFeedWeb。

FBSDKShareDialog* dialog = [[FBSDKShareDialog alloc] init];
dialog.mode = FBSDKShareDialogModeFeedWeb;
dialog.shareContent = content;
dialog.fromViewController = self;
[dialog show];

它会在应用内的UIWebView中显示Feed对话框,其中包含正确标题和说明的帖子预览。

答案 1 :(得分:2)

FBSDKShareDialogMode设置为FeedBrowser解决了我的问题

let dialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = shareLink
dialog.mode = FBSDKShareDialogMode.FeedBrowser
dialog.show()

答案 2 :(得分:0)

使用FBSDKShareLinkContent的 quote 属性

FBSDKShareLinkContent *linkContent = [FBSDKShareLinkContent new];
linkContent.quote = @"your quote";

FBSDKShareDialog *shareDialog = [FBSDKShareDialog new];
shareDialog.shareContent = linkContent;
来自Graph API 2.9的

setContentTitlesetContentDescription已被弃用。 有关详细信息,请参阅https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations