ios - Flutter share facebook:“init()”已在此处明确标记为不可用(FBSDKShareKit.ShareDialog)
问题描述
我想将我的 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 时也遇到了类似的问题。
解决方案
我已经更新了 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 的某些功能已被其版本升级弃用。
推荐阅读
- python - python中的zxing.net.mobile?
- excel - 如果条件满足,Excel VBA 宏将复制数据
- image - 如何从图像文件夹创建预取数据集?
- google-app-engine - 我如何将 Celery Task 转换为 Google Cloud Task GCP (Django)
- google-sheets - 根据两行可能的单元格值在 ARRAYFORMULA 中求和,然后根据两个不同列中的两个不同日期值减去另一个总和
- cmake - Clion STM32 设置和闪存
- javascript - Jquery 克隆未按预期运行
- next.js - 如何在没有任何错误通知的情况下修复 Vercel Deploy Next jS?
- r - 如何使用 R 以编程方式将一列中的数据替换为另一列中的数据?
- java - java: double 不能被取消引用