3
votes

It seems Facebook has recently broken (or intentionally removed?) the ability to share images and links in one post via their share extension, trying to share an image with a link now results in only the image posting. Sharing only the link works and generates a post with an image preview of the linked page.

Previously you could share images and links in one post, is there a way to restore this functionality with the after Facebook app v29?

Here's a brief sample that illustrates what previously worked, but now only shares the image.

NSArray *activityItems = @[
                           [NSURL URLWithString:@"http://stackoverflow.com/"], 
                           [UIImage imageNamed:@"shareImage"]
                          ];

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];

Update - Facebook has acknowledged this as a bug

1

1 Answers

4
votes

As per Facebook latest SDK v4.0.1. we can surely share image and link but not both at same time.


Sharing URL Link and image URL (not Image):-

FBSDKShareLinkContent model includes attributes that show up in the post:

contentURL - the link to be shared

contentTitle - represents the title of the content in the link

imageURL - the URL of thumbnail image that appears on the post

contentDescription - of the content, usually 2-4 sentences

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"http://google.com"];
content.imageURL=[NSURL URLWithString:@"http://nasa.org/a.jpg"];
content.contentTitle=@"Facebook Share";
content.contentDescription=@"Lets see, How my share works guyz..";
[FBSDKShareDialog shareFromViewController:self
                              withContent:content
                                 delegate:nil];

Sharing Only Image:-

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
  photo.image = self.imgView.image;// you can edit it by your choice
  photo.userGenerated = YES;
  FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
  content.photos = @[photo];