FBSDKShareLinkContent is not setting the contentDe

2020-07-01 04:10发布

I am trying to share a link on the Facebook using FBSDKShareLinkContent.

I have set the URL, description and title. SDK is automatically populates the title and description by information scraped from the contentURL.

But I want to set custom title and description that I have given in code. Is there anyway to avoid this behaviour?

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

4条回答
唯我独甜
2楼-- · 2020-07-01 04:39

I tried this code and it works perfectly on my virtual device, until I setted up Facebook account in setting of phone. After I set that, every time that I want to open dialog was opened default iOS social share dialog. Delete your account, if it exist in settings, or just install FB application, in documentation I saw that we need FB app for sharing.

If this will not help, you can always use Social Share framework of iOS, here is the example.

http://www.appcoda.com/ios-programming-101-integrate-twitter-and-facebook-sharing-in-ios-6/

Hope this will help, by the way, today I stack on this problems too, now every thing working great with this Social Sharing framework of iOS.

查看更多
孤傲高冷的网名
3楼-- · 2020-07-01 04:42

FBSDKShareDialogMode sets to FeedBrowser resolves my issue

let dialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = shareLink
dialog.mode = FBSDKShareDialogMode.FeedBrowser
dialog.show()
查看更多
SAY GOODBYE
4楼-- · 2020-07-01 04:43

Use quote property of FBSDKShareLinkContent instead

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

FBSDKShareDialog *shareDialog = [FBSDKShareDialog new];
shareDialog.shareContent = linkContent;

setContentTitle and setContentDescription have been deprecated from Graph API 2.9. For more information, see https://developers.facebook.com/docs/apps/changelog#v2_9_deprecations

查看更多
啃猪蹄的小仙女
5楼-- · 2020-07-01 04:52

I've faced a same problem and found out one workaround - direct setting mode of FBSDKShareDialog instance to FBSDKShareDialogModeFeedWeb.

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

It displays the feed dialog in a UIWebView within the app with preview of your post with right title and description.

查看更多
登录 后发表回答