SLServiceTypeFacebook' was deprecated in iOS 11.0

六眼飞鱼酱① 提交于 2019-12-30 18:00:14

问题


I'm working on a project in xcode 9 and one of my previous codes giving a warning saying the code is been deprecated, where it does not trigger the action. The code as bellow. How can i overcome this ?

@IBAction func shareOnFacebookButtonPressed(_ sender: Any) {

    let shareToFacebook : SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
    shareToFacebook.add(UIImage(named:"pureLightSocial"))
    self.present(shareToFacebook, animated: true, completion: nil)
}

回答1:


The Facebook, Twitter, and Other apps options have been removed in the Settings app.

That apps will now be treated like other apps, using the iOS sharing extensions

let share = [image, text, url]
let activityViewController = UIActivityViewController(activityItems: share, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)

You can also use third party SDK for individual sharing

Facebook Sharing Doc

Twitter Sharing Doc



来源:https://stackoverflow.com/questions/47053446/slservicetypefacebook-was-deprecated-in-ios-11-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!