mike vorisis mike vorisis - 1 year ago 63
Swift Question

Social Framework doesn't work properly Swift

I want to have a share button in my app for sharing to Facebook.
I decided to do it with the social framework as i believed it was easier.
I was wrong...

Here is my code:

@IBAction func facebookButton(sender: AnyObject) {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
let fbSheet = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
fbSheet.setInitialText("Some text")
fbSheet.addImage(UIImage(named: "loading"))
fbSheet.addURL(NSURL(string: "http://www.something.com"))
presentViewController(fbSheet, animated: true, completion: nil)
} else {
self.showAlert("Facebook", msg: "Please login to your Facebook account in Settings")

This code is working, but it returns only the url and if I comment it; it returns only the image.
I have changed the order and I put image third but again it returns only the url.
It's like it has priorities and it returns only one of them.

Answer Source

Since last year Facebook doesn't allow to prefill the text if you want to share something. You can set only hashtags as setInitialText. something like this



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download