Ios 与Swift 3&;Swift SDK(0.2.0)

Ios 与Swift 3&;Swift SDK(0.2.0),ios,swift,facebook,facebook-ios-sdk,Ios,Swift,Facebook,Facebook Ios Sdk,我成功安装了Facebook播客(全部三个),我可以在我的应用程序中登录用户,但我不能分享任何东西 代码非常简单(来自示例项目,而不是真实项目): 在viewDidLoad()中: 我还有: func sharePic() { let url = URL(fileURLWithPath: "https://developers.facebook.com") let content = LinkShareContent(url: url, title: "face

我成功安装了Facebook播客(全部三个),我可以在我的应用程序中登录用户,但我不能分享任何东西

代码非常简单(来自示例项目,而不是真实项目):

在viewDidLoad()中:

我还有:

func sharePic() {

    let url = URL(fileURLWithPath: "https://developers.facebook.com")        
    let content = LinkShareContent(url: url, title: "facebook", description: "facebook developers", quote: "fbd", imageURL: nil)
    try! ShareDialog.show(from: self, content: content)
}
在这方面,我不断收到以下错误信息:

fatal error: 'try!' expression unexpectedly raised an error: FacebookShare.ShareError.reserved: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.58.6/src/swift/stdlib/public/core/ErrorType.swift, line 178
我对“try!”没有任何疑问(我知道这是一种不好的做法),但我不明白我的代码有什么问题,也不知道如何理解这里的错误。

func showShareDialog(u内容:C,模式:ShareDialogMode=.automatic){
func showShareDialog<C: ContentProtocol>(_ content: C, mode: ShareDialogMode = .automatic) {
    let dialog = ShareDialog(content: content)
    dialog.presentingViewController = self
    dialog.mode = mode

    do {
        try dialog.show()
    } catch (let error) {
        Toast(text: "Invalid share content. Failed to present share dialog with error \(error)", duration: Delay.short).show()
    }
}

func fbClick() {
    var content = LinkShareContent(url: URL(string: "http://example.com")!,
                                   title: "Title",
                                   description: "Description",
                                   imageURL: "http://test.com/test.png")

    showShareDialog(self.content!, mode: .native)
}
let dialog=ShareDialog(内容:content) dialog.presentingViewController=self dialog.mode=模式 做{ 试试dialog.show() }捕捉(让错误){ Toast(文本:“无效的共享内容。无法显示共享对话框,错误为\(error)”,持续时间:Delay.short)。show() } } func fbClick(){ var content=LinkShareContent(url:url(字符串):http://example.com")!, 标题:“标题”, description:“description”, 图像URL:“http://test.com/test.png") showShareDialog(self.content!,模式:。本机) }
对于Swift>=5.0,FBSDKShareKit,使用共享对话框和消息对话框在Facebook和Messenger中共享您的媒体

您可以按照下面的链接获取详细教程


你有什么解决办法吗?即使我也有同样的问题不是真的,不是。我用iOS共享来代替(它不是那么闪亮,但它可以工作,并且对视频共享没有限制),我能够解决这个问题。你是否也可以分享登录代码,我有困难。有人对此有答案吗?我也有同样的问题,我不断地得到错误“保留”
fatal error: 'try!' expression unexpectedly raised an error: FacebookShare.ShareError.reserved: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.58.6/src/swift/stdlib/public/core/ErrorType.swift, line 178
func showShareDialog<C: ContentProtocol>(_ content: C, mode: ShareDialogMode = .automatic) {
    let dialog = ShareDialog(content: content)
    dialog.presentingViewController = self
    dialog.mode = mode

    do {
        try dialog.show()
    } catch (let error) {
        Toast(text: "Invalid share content. Failed to present share dialog with error \(error)", duration: Delay.short).show()
    }
}

func fbClick() {
    var content = LinkShareContent(url: URL(string: "http://example.com")!,
                                   title: "Title",
                                   description: "Description",
                                   imageURL: "http://test.com/test.png")

    showShareDialog(self.content!, mode: .native)
}