在Facebook上分享IOS 11 Swift

问题描述 投票:2回答:2

在以下版本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)
    }
ios swift facebook share ios11
2个回答
2
投票

你可以使用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>

2
投票

所有社交常量(facebook,twitter,LinkedIn和其他)都已在iOS 11上弃用。

见这里:https://developer.apple.com/documentation/social/social_constants

您可以在Facebook上使用FBSDKShareKit进行共享功能。

https://developers.facebook.com/docs/sharing/ios/

© www.soinside.com 2019 - 2024. All rights reserved.