【问题标题】:Facebook Swift SDK - MessageDialogFacebook Swift SDK - 消息对话框
【发布时间】:2016-10-12 18:11:37
【问题描述】:

我正在尝试使用 Facebook Swift SDK 实现 MessageDialog。

MessageDialog 是这样呈现的:

    let content = LinkShareContent(url: URL(string: "www.google.com")!)        
    let shareDialog = MessageDialog(content: content)
    shareDialog.completion = { result in

        print(result)

        switch result {
        case .success:
            print("A")
        case .failed:
            print("B")
        case .cancelled:
            print("C")
        }

    }

    do {
        try shareDialog.show()
    } catch {
        print(error)
    }

什么都没有发生,我还在完成处理程序中收到一个错误,说“保留”。

文档https://github.com/facebook/facebook-sdk-swift/blob/master/Sources/Share/ShareError.swift 没有指定“保留”的含义。

【问题讨论】:

  • 你用的是哪个sdk?
  • 版本 4.16.0,使用 cocoapods 安装
  • @Marco,你找到reserved 错误的根本原因了吗?我遇到了同样的问题,我在网上找不到任何解决方案。
  • 我也是,你解决了吗?

标签: ios swift facebook-sdk-4.0 facebook-sharer facebook-share


【解决方案1】:

我想需要像下面这样实现它,它对我有用。

import FBSDKCoreKit
import FBSDKShareKit

//=========================

let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = URL(string: "http://google.com")!

let shareDialog = FBSDKShareDialog()
shareDialog.shareContent = content
shareDialog.mode = .native
shareDialog.delegate = self
shareDialog.show()

//MARK: FBSDKSharingDelegate
    func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {
        print(results)
    }
    
    func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {
        print(error)
    }
    
    func sharerDidCancel(_ sharer: FBSDKSharing!) {
        print("cancel..")
    }

【讨论】:

  • 如果您使用的是 use_frameworks!标志,您还必须在 FBSDKCoreKit 依赖项之前添加 pod 'Bolts'。
  • 不能分配给自己。
【解决方案2】:

当您在没有 Facebook 应用的模拟器上尝试分享功能时,会出现“已保留”错误消息。

如果你在设备上运行你的代码,它应该是单词。

最大

【讨论】:

  • 这不是真的,在我使用 Facebook 应用程序的真实设备上,它给出了保留错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-03
  • 2015-06-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多