【问题标题】:Flutter share facebook : 'init()' has been explicitly marked unavailable here (FBSDKShareKit.ShareDialog)Flutter share facebook:“init()”已在此处明确标记为不可用(FBSDKShareKit.ShareDialog)
【发布时间】:2021-12-18 10:32:15
【问题描述】:

我想将我的 Flutter 应用中的帖子分享到 facebook 等社交媒体平台。

我使用了flutter_share_me 包(版本 1.2.0), 我的 Android 项目在 Facebook 分享上运行良好。

但是当我构建我的iOS项目时,由于以下错误,构建失败

在 SwiftFlutterShareMePlugin.swift 文件的 sharefacebook 函数中。

'init()' 已在此处明确标记为不可用 (FBSDKShareKit.ShareDialog)

func sharefacebook(message:Dictionary<String,Any>, result: @escaping FlutterResult)  {
    let viewController = UIApplication.shared.delegate?.window??.rootViewController
    let shareDialog=ShareDialog() // **this line make the error**
    let shareContent = ShareLinkContent()
    shareContent.contentURL = URL.init(string: message["url"] as! String)!
    shareContent.quote = message["msg"] as? String
    shareDialog.mode = .automatic
    ShareDialog(fromViewController: viewController, content: shareContent, delegate: self).show()
    result("Sucess")

}

请帮我解决这个问题。

我发现其他 Flutter 开发人员在尝试使用 share_plus 包等其他包将帖子分享到 Facebook 时也会遇到 similar issues

https://github.com/fluttercommunity/plus_plugins/issues/579

【问题讨论】:

    标签: ios swift flutter dart fbsdksharekit


    【解决方案1】:

    我已经更新了flutter_share_me包(版本1.2.0)的SwiftFlutterShareMePlugin.swift文件如下,iOS项目正在为facebook分享工作。

    func sharefacebook(message:Dictionary<String,Any>, result: @escaping FlutterResult)  {
        let viewController = UIApplication.shared.delegate?.window??.rootViewController
        
        let shareContent = ShareLinkContent()
        shareContent.contentURL = URL.init(string: message["url"] as! String)!
        shareContent.quote = message["msg"] as? String
        ShareDialog(viewController: viewController, content: shareContent, delegate: self).show()
        result("Sucess")
        
    }
    

    我认为问题在于 FBSDKShareKit 的某些功能已被其版本升级弃用。

    【讨论】:

      猜你喜欢
      • 2015-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-26
      • 2015-11-25
      相关资源
      最近更新 更多