在低于11的版本中,ShareButton to facebook运行成功,但在11版本中,此功能不起作用。你有什么建议吗?
if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeFacebook) {
var vc: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
vc.setInitialText("My text")
self.present(vc, animated: true, completion: nil)
}发布于 2018-11-03 20:36:43
您可以使用facebook sdk共享内容,如
第1步:
安装pod :- pod 'FacebookShare'
第2步:
导入FBSDKShareKit
第3步:
func shareTextOnFaceBook() {
let shareContent = ShareLinkContent()
shareContent.contentURL = URL.init(string: "https://developers.facebook.com")! //your link
shareContent.quote = "Text to be shared"
ShareDialog(fromViewController: self, content: shareContent, delegate: self).show()
}
func sharer(_ sharer: Sharing, didCompleteWithResults results: [String : Any]) {
if sharer.shareContent.pageID != nil {
print("Share: Success")
}
}
func sharer(_ sharer: Sharing, didFailWithError error: Error) {
print("Share: Fail")
}
func sharerDidCancel(_ sharer: Sharing) {
print("Share: Cancel")
}第4步:必须在
Info.plist中添加此内容
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
</array>发布于 2017-10-12 23:51:42
所有的社交常量(facebook、twitter、LinkedIn等)在iOS 11上都被弃用了。
查看此处:https://developer.apple.com/documentation/social/social_constants
你可以在facebook上使用FBSDKShareKit的分享功能。
发布于 2021-06-10 01:55:14
现在,使用FBSDKShareKit在facebook上分享媒体变得更容易、更可靠。你可以点击下面的链接获取详细的教程。
Facebook, Messenger - Photo, Video, Link sharing in iOS Swift.
https://stackoverflow.com/questions/46690231
复制相似问题