Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBSDKShareLinkContent is not setting the contentDescription and contentTitle

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];
like image 271
Minna Avatar asked Apr 28 '15 10:04

Minna


2 Answers

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.

like image 142
Tony Krasilnikov Avatar answered Nov 06 '22 13:11

Tony Krasilnikov


FBSDKShareDialogMode sets to FeedBrowser resolves my issue

let dialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = shareLink
dialog.mode = FBSDKShareDialogMode.FeedBrowser
dialog.show()
like image 29
kalpeshdeo Avatar answered Nov 06 '22 13:11

kalpeshdeo