In facebook SDK 3.x it was possible to use the share dialog to add a caption. Is this feature available in 4.x? Should the caption now be part of the web page the share is pointing to?
As of right now, the caption being shown is just the weblink.
Here's some code to clarify question:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"www.google.com"];
content.contentDescription = #"2-4 sentences of description.";
content.contentTitle = #"Title";
content.contentCaption = ?
shareDialog.shareContent = content;
shareDialog.delegate = self;
[shareDialog show];
Note - obviously there is no 'contentCaption' setter but maybe it's a property? Not sure if it's even available anymore but figured I would ask.
I am using Facebook sdk v4.10.1 now and this is work for me.
[content setValue:#{#"caption":#"?"} forKey:#"feedParameters"];
Related
I'm using FBSDKShareLinkContent to display a dialog to share a link to Facebook. No matter the link I use (I even tried with https://google.com/) when the post / link is tapped in the Facebook app my app is launched.
I want, however, to load the link in a web browser or the FB browser instead (and not have it launch my app or navigate to the app store). Is there anyway to achieve this? I tried both FBSDKShareDialogModeFeedWeb and FBSDKShareDialogModeAutomatic.
Here is my current code:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"https://google.com/"];
FBSDKShareDialog* dialog = [[FBSDKShareDialog alloc] init];
dialog.mode = FBSDKShareDialogModeFeedWeb;
dialog.shareContent = content;
dialog.fromViewController = self;
[dialog show];
Add this to your code:
FBSDKShareLinkContent *content1 = [[FBSDKShareLinkContent alloc] init];
content1.contentURL = [NSURL URLWithString:#"http://en.wikipedia.org/wiki/Facebook"];
content1.contentTitle=#"Share";
[FBSDKShareDialog showFromViewController:self withContent:content1 delegate:nil];
I'm trying to share a link object to a Facebook group using the share dialog. No one seems to have answered this question satisfactorily yet.
The SDK documentation clearly states that you can use the share dialog to share to your own timeline or groups, yet I can't figure out how to do it. I also don't see any other apps that do it. Using the web share dialogue on a desktop you can see the option, but on a mobile website you don't! This screenshot of the iOS Facebook app shows what I'm talking about:
I'm trying to get the functionality in where it says 'tap to change' at the top.
It appears you have to use an instance of FBSDKShareDialog, and set the mode to FBSDKShareDialogModeNative.
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = viewController;
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://www.test.com"];
content.contentTitle = productItem.productTitle;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeWeb;
}
dialog.delegate = self;
[dialog show];
I'm following the Facebook SDK documentation at https://developers.facebook.com/docs/ios/getting-started/share-button and the people I tag via peopleIDs are not tagged in the post that I share.
NSURL *imageURL = [NSURL URLWithString:#"http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg"];
NSURL *contentURL = [[NSURL alloc] initWithString:#"http://en.wikipedia.org/wiki/Facebook"];
FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentURL = contentURL;
content.contentTitle = #"My Share Title";
content.contentDescription = #"Lorem ipsum dolor sit amet.";
content.imageURL = imageURL;
content.peopleIDs = #[#"10206439771816757"];
content.placeID = #"166793820034304";
content.ref = #"myRefId";
I modified the sample code to use an ID for a person who is a friend and they are not getting tagged. How do I tag friends?
There's some weirdness going on with this API call, as revealed in this other SO post, FBSDKShareLinkContent is not setting the contentDescription and contentTitle, so I'm wondering if there is some trick to getting people tagged.
Update:
It turns out the tagging works if you use the FBSDKShareButton to share the url. However, I want to share and tag people using a FBSDKShareDialog. I can't seem to find a way to do this.
I ran into the same problem, and it appeared to me that tagging people is only supported when using the native app to display the share dialog.
My solution was to try FBSDKShareDialogModeNative first, and otherwise fall back to the default FBSDKShareDialogModeAutomatic:
- (void)shareLinkContent:(FBSDKShareLinkContent *)linkContent fromViewController:(UIViewController *)viewController
{
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = viewController;
dialog.shareContent = linkContent;
// Try the native mode first. If it isn't supported,
// fall back on automatic mode.
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeAutomatic;
}
[dialog show];
}
I am using FBSDK sharebutton in my application using latest fbSDK for iOS & xcode 7,i want to share some information on friend's timeline from my app but when using FBSDK SHARE button only normal share dialog is opening with no option for sharing on friends timeline...i am using following code as per ios9 fbSDK documentation
-(void)shareOnFriendsTimeline
{
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"https://www.example.com"];
FBSDKShareButton *shareButton = [[FBSDKShareButton alloc] init];
shareButton.shareContent = content;
shareButton.center = self.view.center;
[self.view addSubview:shareButton];
}
please tell me where i am doing wrong...thanks in advance
I'm creating the FBSDKShareLinkContent object and feeding it into the FBSDKShareDialog. I'm trying to set up the dialog's default message to something like "my highscore is %d !". sharing itself is working and has an empty message by default. can anyone help please?
thank you!
EDIT: here is my piece of code:
FBSDKShareLinkContent* content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString: #"https://itunes.apple.com/us/app/cylinder-game"];
content.contentTitle = #"Cylinder Game";
content.contentDescription = #"Cylinder Game is endless, rhythm based game with super addictive gameplay";
FBSDKShareDialog* dialog = [[FBSDKShareDialog alloc] init];
[dialog setMode:FBSDKShareDialogModeAutomatic];
[dialog setShareContent:content];
[dialog setDelegate:self];
[dialog setFromViewController:UnityGetGLViewController()];
There's no way to set the default message using the share dialog offered by the SDK. It's also considered prefilling, and is against the Facebook Platform Policy, see section 2.3 https://developers.facebook.com/policy
I found that the title and description is related to url object anyway. That means the text of message above the object, which user see in share dialog cannot be affected it seems.
And the title and descripton of URL object only works if you set the dialog mode to Native or FBSDKShareDialogModeFeedBrowser.
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeFeedBrowser;
}
Another thing is, there is some property of FBSDKShareLinkContent called "quote", which displays some text above URL object and under message itself, but it is not displayed in all modes. For example not in Native, but yes in FBSDKShareDialogModeFeedBrowser.
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://www.x.com"];
content.contentDescription = #"desc";
content.contentTitle = #"title";
content.quote = #"quote";