Johnny Johnny - 7 months ago 45
iOS Question

Share an image from my app to facebook

I have a movie quiz app, and I want users to share the movie scene image that they are stuck on to Facebook so they can ask their friends for help.

With Facebook's recent changes I am struggling to figure out how to post the image that the user is up to.

All the movie scene images are stored in the app so there is no URL.

I am trying to get the image from my array like this:

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.imageURL = [NSURL fileURLWithPathComponents:[[mainInfoArray objectAtIndex:index] objectForKey:PHONE_IMAGE]];

but it does not work.
Any ideas please to get this to work?
Thank You


First, you create the content, then you create a share-button with that content.

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init]; = @[photo];

FBSDKShareButton *button = [[FBSDKShareButton alloc] init];
button.shareContent = content;  
[self.view addSubview:button];