我正在制作一个示例Facebook共享应用程序以使用共享按钮共享一些字符串值,但是由于iOS 11中已取消社交功能,因此我感到困惑
我现在应该使用什么代码,我已经安装了 Facebook SDK for Swift
我想要我已经在谷歌上搜索过的 SIWFT 语言的代码,我发现没有对我的情况有用的代码
这是我在Onclikbutton操作下使用的代码
@IBAction func shareButton(_ sender: Any) {
let alert = UIAlertController(title: "Share", message: "Poem Of the day", preferredStyle: .actionSheet)
let actionOne = UIAlertAction(title: "Share on Facebook", style: .default) { (action) in
print("Success")
}
alert.addAction(actionOne)
self.present(alert, animated: true, completion: nil)
}
编辑 :- 使用以下代码找到了在 Facebook 上分享帖子的更好方法
@IBAction func shareButton(_ sender: Any) {
let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "https://github.com/EndLess728")
let dialog : FBSDKShareDialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = content
dialog.mode = FBSDKShareDialogMode.feedWeb
dialog.show()
}
使用UIActivityViewController
共享内容...
@IBAction func share(_ sender: Any) {
let sharingItems: [Any] = [URL(string: "https://github.com/EndLess728")]
let activityController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
present(activityController, animated: true)
}