Social framework is deprecated in iOS11

917 views Asked by At

i am making a sample facebook share app to share some string value using share button , but i am confued since social is deperacted in ios 11

what codes should i use now , i have installed facebook sdk for swift

i want the codes in siwft language i have already searched on google i found not codes which is usefull for my case

here is the codes i am using under onclikbutton action

@IBAction func shareButton(_ sender: Any) {


let alert = UIAlertController(title: "Share", message: "Poem Of the day", preferredStyle: .actionSheet)

    let actionOne = UIAlertAction(title: "Share on Facebook", style: .default) { (action) in
        print("Success")



    }

    alert.addAction(actionOne)
    self.present(alert, animated: true, completion: nil)

}

Edit :- found a better way to share post on facebook using below code

@IBAction func shareButton(_ sender: Any) {



    let content = FBSDKShareLinkContent()
    content.contentURL =  URL(string: "https://github.com/EndLess728")


    let dialog : FBSDKShareDialog = FBSDKShareDialog()
    dialog.fromViewController = self
    dialog.shareContent = content
    dialog.mode = FBSDKShareDialogMode.feedWeb
    dialog.show()

}
1

There are 1 answers

0
Ashley Mills On

Use UIActivityViewController to share content…

@IBAction func share(_ sender: Any) {

    let sharingItems: [Any] = [URL(string: "https://github.com/EndLess728")]

    let activityController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)

    present(activityController, animated: true)
}