在以下版本11 Share Button 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)
}
你可以使用facebook sdk分享内容
步骤1:
安装pod: - pod 'FacebookShare'
第2步:
进口的
第3步:
func faceBookShare()
{
let content:LinkShareContent = LinkShareContent.init(url: URL.init(string: "https://developers.facebook.com") ?? URL.init(fileURLWithPath: "https://developers.facebook.com"), quote: "Share This Content")
let shareDialog = ShareDialog(content: content)
shareDialog.mode = .native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
// Handle share results
}
do
{
try shareDialog.show()
}
catch
{
print("Exception")
}
}
第4步:必须在
Info.plist
中添加此内容
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth2</string>
</array>
所有社交常量(facebook,twitter,LinkedIn和其他)都已在iOS 11上弃用。
见这里:https://developer.apple.com/documentation/social/social_constants
您可以在Facebook上使用FBSDKShareKit进行共享功能。