gpt4 book ai didi

ios - 现在无法以编程方式在 Facebook 上共享文本 IOS

转载 作者:行者123 更新时间:2023-11-28 09:36:59 25 4
gpt4 key购买 nike

我无法快速以编程方式在 Facebook 上共享文本。请看我的代码。在这里,

     let facebookPostAction = UIAlertAction(title: "Share on Facebook", style:              UIAlertActionStyle.Default) 

{ (action) -> Void in

if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
let facebookComposeVC = SLComposeViewController(forServiceType: SLServiceTypeFacebook)

facebookComposeVC.setInitialText("\(self.noteTextview.text)")

self.presentViewController(facebookComposeVC, animated: true, completion: nil)
}
else {
self.showAlertMessage("You are not connected to your Facebook account.")
}

}

最后这个函数在运行时对我说

facebook share is invalidated

我该怎么办?

最佳答案

Facebook改变了分享政策,所以你需要使用他们的SDK分享。现在开发人员需要安装 FBSDKShareKit.framework,并简单地添加带有上下文信息的按钮。

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

简单地说,您需要添加 FBSDKShareButton,通过它从 UIButton 扩展的方式,并为其设置上下文数据:

_fbButton = FBSDKShareButton()
...
// setup visual part
// don't need to add target, facebook's sdk decides action
...
// set context data to shareContent button's property
let fbContent = FBSDKShareLinkContent()
fbContent.contentURL = value.contentURL
fbContent.contentTitle = value.contentTitle
fbContent.contentDescription = value.contentDescription
fbContent.imageURL = value.imageURL
_fbButton.shareContent = fbContent

就是这样,Facebook 的分享面板将在点击此按钮后显示包含的数据。

关于ios - 现在无法以编程方式在 Facebook 上共享文本 IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35915528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com