I'm using the latest version of the Facebook SDK.
Sharing a photo with a caption is easy:
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
FBSDKSharePhoto *photo = [FBSDKSharePhoto photoWithImage:image userGenerated:YES];
photo.caption = txt_desc.text;
content.photos = #[photo];
[FBSDKShareAPI shareWithContent:content delegate:nil];
But the .caption property is not found on FBSDKShareVideo or FBSDKShareVideoContent. I have gone down the list for all the properties available to FBSDKShareVideo and FBSDKShareVideoContent but there's nothing that seems like it would hold the caption. The FB SDK documentation doesn't give any answers either.
I know it's possible to share a video with a caption on iOS because the Instagram iOS app does it. I just don't know how. Any one have any idea?
As you can read in the documentation for FBSDKShareVideo, it does not support providing a description/caption.
Related
In my app, I am using SLComposeViewController to post images on Facebook app, which works fine. Requirement is, if the Facebook app is not installed, I would like to open the web page and allow user to post the image though web. Please anyone can advise how to post the image on Facebook web? I have iOS 9 and above with Xcode 8.1.
Use Facebook SDK for post image to facebook. You can find code and documentation here:
https://developers.facebook.com/docs/sharing/ios
Facebook SDK will handle all types of exception and scenario.
If Facebook app is not installed. but you FB accounts synced with setting app in your iPhone.
you can use below code to share the photo. But it will not open web browser.
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = img; // your image
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
To share via web browser, you can use below code.
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.imageURL = [NSURL URLWithString:img]; // image url
[FBSDKShareDialog showFromViewController:self.viewController
withContent:content
delegate:self];
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 am building an iOS app that let user created some type of images and when user finished doing that they can choose to publish it on their facebook timeline automatically.
I am able to post to user's timeline automatically because user allow publish_permission to our app. And I let my app post an image created by users to their facebook timeline. It went out smoothly. The image appear on Facebook and it displayed that this image is created by my app. But I am not able to provide the link when users click on the name of app to my content page. How can I do that ? I saw Instagram having this feature and it should drive more engagement to our app. This is the screenshot of how Instagram does this
This is how my app display it
This is the code how I posted image to user's timeline in my iOS app
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = [UIImage imageWithData:,myImage];
photo.userGenerated = YES;
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:#"http://www.myWebsite.com/profile/%#/item/xxxx]];
photo.caption = [NSString stringWithFormat:#"%#%# Created by xxx"];
photo.userGenerated = YES;
photo.imageURL = URL;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
[FBSDKShareAPI shareWithContent:content delegate:self];
Do I need to use opengraph or anything else ? Please help.
Thanks in advance
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"];
I am using Facebook SDK 4.0,https://developers.facebook.com/docs/sharing/ios#share_dialog
I am using FBSDKShareDialog to share Photo.It does share Photo if user has installed Facebook app,
But it fails when user hasn't installed FB App. but they say "If someone doesn't have Facebook app installed it will automatically falls back to a web-based dialog."
Idk whats wrong please help me in sharing photo using FBSDK 4.0.
My code is
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.capturedImageView.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
This is error report
error:"com.facebook.sdk:FBSDKErrorArgumentNameKey=shareContent,
com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Feed share dialogs
support FBSDKShareLinkContent."
FBSDKShareDialog only supports FBSDKShareLinkContent to post image or URL.So to use share Dialog you have to use FBSDKShareLinkContent.
You could use it as follows :
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.imageURL = [NSURL URLWithString:#"http://upload.wikimedia.org/wikipedia/commons/3/36/Hopetoun_falls.jpg"];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];
If you want to share a link then just use content.contentURL.
Refer to : https://developers.facebook.com/docs/sharing/ios#share_dialog
If you are using FBSDKSharePhoto then you need the native Facebook for iOS app installed.
Refer to :https://developers.facebook.com/docs/sharing/ios#photos
I also had the same issue as the documentation is also saying that they provide fallback mechanisms, which seems not true for this case:
Built-In Share Fallbacks
In past versions of the SDK for iOS, your app had to check for a
native, installed Facebook app before it could open the Share Dialog.
If the person didn't have the app installed, you had to provide your
own code to call a fallback dialog.
Now the SDK automatically checks for the native Facebook app. If it
isn't installed, the SDK switches people to their default browser and
opens the Feed Dialog. If someone wants to share an Open Graph story,
the SDK opens the Web Share Dialog.
First configure Facebook account of iOS device before and then use following code it will work:
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.capturedImageView.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:self];