I want to share posts from my flutter app to social media platforms like facebook.
I've used flutter_share_me package ( version 1.2.0 ), my Android project is working well for Facebook sharing.
But when I build my iOS project, the building is failed due to the following errors
in sharefacebook function of SwiftFlutterShareMePlugin.swift file.
'init()' has been explicitly marked unavailable here (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")
}
Please help me with how to solve this issue.
I found other Flutter developers are also meet similar issues when they try to share their posts to Facebook using other packages like share_plus package.
I've update SwiftFlutterShareMePlugin.swift of flutter_share_me package(version 1.2.0) file as following, and the iOS project is working for facebook sharing.
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")
}
I think the problem is because some functions of FBSDKShareKit are deprecated by its version up.