简体   繁体   中英

Facebook SDK Share Image with Text

Prior to using Facebook SDK we used to share via UIActivityViewController since Facebook does not allow for us to pre-fill information on the user sharing, our solution was to use information the user description of the Image being share UIPasteboard.general.string . So the app would switch to the messenger and the user could paste. This worked just fine until we started using the Facebook SDK.

Now it seems that the UIPasteboard.general.string is reset when it opens up messenger and we no longer can get the image description copied to the clipboard.

This is how I'm sharing to messenger:

let sharePhoto = FBSDKSharePhoto()
sharePhoto.image = image

let content = FBSDKSharePhotoContent()
content.photos = [sharePhoto]

FBSDKMessageDialog.show(with: content, delegate: delegate)

Yes, I'm stacked on that staff too after FB lib update. As for me - I figured out with web link on image like it shown below. As a result - you do not need ask user to paste something. You can do it by yourself and paste it to title or description.

let content = LinkShareContent(url: url,
                                       title: title,
                                       description: description,
                                       quote: nil,
                                       imageURL: imageURL)

        let dialog = ShareDialog(content: content)
        dialog.presentingViewController = parentVC
        dialog.mode = .automatic
        dialog.completion = { result in
             ...
        }

        try? dialog.show()

Facebook is not support UI share both image and text. If you want to share an image and a text together, you can create a custom story from your app's settings, and share it as an open graph story. Here's the documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM