For the new Facebook SDK 4.x (4.1) for iOS
had new changes with the frameworks . It includes 3 different framework as like
To share any image I used FBSDKSharePhoto
Class. But it has method
[FBSDKSharePhoto photoWithImage:(*UIImage) userGenerated:(BOOL)]
I want to add caption with the image as string and text. can Anyone help me for this so I can post caption with the image using FB's new sdk.
Thanks in Advance.
As @NANNAV posted it will work, but if you want to share silently with out any FB Dialog screen then use "shareWithContent" as below, but you need to submit your Facebook app for review.
Code in Obj-c
FBSDKSharePhoto *sharePhoto = [[FBSDKSharePhoto alloc] init];
sharePhoto.caption = @"Test Caption";
sharePhoto.image = [UIImage imageNamed:@"BGI.jpg"];
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[sharePhoto];
[FBSDKShareAPI shareWithContent:content delegate:self];
Code in Swift
var sharePhoto = FBSDKSharePhoto()
sharePhoto.caption = "Test"
sharePhoto.image = UIImage(named: "BGI.jpg")
var content = FBSDKSharePhotoContent()
content.photos = [sharePhoto]
FBSDKShareAPI.shareWithContent(content, delegate: self)
Assign your Caption String to caption Key value
@property (nonatomic, copy) NSString *caption;
Try This :
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
photo.caption = @"Add Your caption";
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With