[英]Share on Facebook IOS 11 Swift
In versions below 11 ShareButton to facebook works successfull, but in 11 version this function doesn't work.在低于 11 ShareButton 到 facebook 的版本中成功运行,但在 11 版本中此功能不起作用。 What can u advice?
你有什么建议?
if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeFacebook) {
var vc: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
vc.setInitialText("My text")
self.present(vc, animated: true, completion: nil)
}
You can use the facebook sdk to share content Like您可以使用 facebook sdk 来分享内容 Like
Step 1:
第 1 步:
install pod :- pod 'FacebookShare'
安装 pod :-
pod 'FacebookShare'
Step 2:
第 2 步:
import FBSDKShareKit导入 FBSDKShareKit
Step 3:
第 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")
}
Step 4: Must add this in
Info.plist
第 4 步:必须在
Info.plist
添加它
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
</array>
All of social constants (facebook, twitter, LinkedIn and others) have been deprecated on iOS 11 .所有社交常量(facebook、twitter、LinkedIn 等)都已在 iOS 11 上弃用。
See here: https://developer.apple.com/documentation/social/social_constants请参阅此处: https : //developer.apple.com/documentation/social/social_constants
You can use the FBSDKShareKit for the sharing function on facebook.您可以使用 FBSDKShareKit 来实现 facebook 上的分享功能。
https://developers.facebook.com/docs/sharing/ios/ https://developers.facebook.com/docs/sharing/ios/
Now it's more easy and more reliable to share media in facebook using FBSDKShareKit.现在,使用 FBSDKShareKit 在 facebook 中共享媒体更容易、更可靠。 You can follow the link below for details tutorial.
您可以按照以下链接获取详细教程。
Facebook, Messenger - Photo, Video, Link sharing in iOS Swift. Facebook, Messenger - iOS Swift 中的照片、视频、链接共享。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.