13

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)
}
danu
  • 1,079
  • 5
  • 16
  • 48
  • see this https://stackoverflow.com/questions/44879798/about-slcomposeviewcontroller-in-ios-11-beta – Anbu.Karthik Nov 01 '17 at 11:24
  • Possible duplicate of [About "SLComposeViewController" in iOS 11 beta](https://stackoverflow.com/questions/44879798/about-slcomposeviewcontroller-in-ios-11-beta) – Krunal Nov 10 '17 at 12:50

1 Answers1

13

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

Harshal Valanda
  • 5,331
  • 26
  • 63
  • 1
    Sorry didn't understand? – Harshal Valanda Nov 02 '17 at 05:04
  • as in this doesnt allows to share the content (image and a short description) using the browser as SLComposeViewController allows. I need away to share it as SLComposeViewController does it. but now seems its not working since its been deprecated – danu Nov 02 '17 at 05:08
  • Then you have only one option that goes with the sdk and graph api of facebook. – Harshal Valanda Nov 02 '17 at 05:10
  • 1
    Share extensions has own functionality and its built in so you did not change it. Let me check for sdk sharing. – Harshal Valanda Nov 02 '17 at 05:11
  • Sadly, since this answer was written, Twitter have also now discontinued their support of Twitter Kit, which removes yet another option: https://blog.twitter.com/developer/en_us/topics/tools/2018/discontinuing-support-for-twitter-kit-sdk.html – TheNeil May 15 '19 at 14:07
  • It looks like Twitter's API endpoints are the expected alternative now: https://developer.twitter.com/en/docs/tweets/post-and-engage/overview – TheNeil May 15 '19 at 14:16