1

I am developing an application where I have to share photo and text to Facebook and FBMessenger, for this I am using FBSDKShareKit Framework. It is not possible to share text and photo at a time, so I copied text to UIPasteboard and want to paste it in Facebook application or FBMessenger Application. But the text is not copied when I share Photo, But for link sharing UIPasteboard is working.

Is there any workaround to solve this problem.

Thanks in advance....

Ramesh
  • 102
  • 11
  • If you are trying to pre-fill text then it won't work as it is against policy which may be the reason why it is getting removed. Check this: http://stackoverflow.com/questions/29881531/ios-8-3-and-later-facebook-share-text-not-inserted – bangdel Jul 06 '15 at 18:11
  • @Bangdel the same thing is working on Android. In Android first they are showing photo in facebook and pasting text in share comment box which is copied with pasteboard. Same thing i want to implement. – Ramesh Jul 09 '15 at 05:38

1 Answers1

1

I'm not sure if I understand you correctly but if you want to share text and photo at the same time with the Facebook SDK, you can try this:

NSURL *imageURL = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/en/d/d3/Nasa_mer_marvin.jpg"];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]]; // taking image from Wikipedia for example purposes
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image; // your photo
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
if ([[FBSDKAccessToken currentAccessToken].permissions containsObject:@"publish_actions"]) {
    FBSDKShareAPI * shareApi = [[FBSDKShareAPI alloc]init];
    shareApi.message = @"Lorem Ipsum Dolor Sit Amet"; // your text
    shareApi.shareContent = content;
    [shareApi share];
}
bangdel
  • 2,523
  • 5
  • 28
  • 42
  • "publish_actions" is deprecated, so it does NOT work now. Thank you all the same. – DawnSong Sep 24 '19 at 05:18
  • Error message from facebook api, "This endpoint is deprecated since the required permission publish_actions is deprecated". – DawnSong Sep 24 '19 at 05:28