简体   繁体   English

Facebook SDK与文本共享图像

[英]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 . 在使用Facebook SDK之前,我们曾经通过UIActivityViewController共享,因为Facebook不允许我们预先填写用户共享的信息,我们的解决方案是使用信息用户描述的图像共享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. 在我们开始使用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. 现在看来UIPasteboard.general.string在打开信使时被重置,我们再也无法将图像描述复制到剪贴板了。

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. 是的,在FB lib更新之后,我也堆积在那些工作人员身上。 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. Facebook不支持UI共享图像和文本。 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 . 这是文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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