FBSDKSharePhoto not sharing link alongside photo using Swift

1.9k views Asked by At

When I try to share a link along with a picture, at the same time, via FBSDKSharePhoto, only the photo gets shared. No link appears.

Here is the code I use:

let photo : FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = self.scaledImage
photo.userGenerated = true

let content : FBSDKSharePhotoContent = FBSDKSharePhotoContent()
content.contentURL = NSURL(string: self.short_string)
content.photos = [photo]

let button : FBSDKShareButton = FBSDKShareButton()
button.shareContent = content

And a picture of the resulting dialog when I push the button: https://i.stack.imgur.com/eUtyu.jpg (also attached)

You can see the picture gets attached to the post, but there is no link. I know all of the URL/Photo variables work fine because they are used elsewhere.

If I switch the sharing method to FBSDKShareLinkContent then content.contentURL works fine, but I cannot post the picture this way because the picture is not hosted on the web, which is why I am using FBSDKSharePhotoContent. (The picture is taken within the app.)

let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: self.short_string)
content.contentTitle = self.title_text
content.contentDescription = self.desc_text
content.imageURL = NSURL(string: "http://randomimage.jpg/")

let button : FBSDKShareButton = FBSDKShareButton()
button.shareContent = content

So I know my link is structured properly according to the contentURL protocol, and FBSDKSharePhotoContent conforms to the same functions as FBSDKShareLinkContent. No clue why it won't work.

1

There are 1 answers

0
Mykyta Savchuk On

Due to Facebook rules you can`t set non user generated text.