This is the function i use to share to facebook:
@IBAction func shareFacebookButton(sender: AnyObject) {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
let fbShare:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
fbShare.addURL(NSURL(string: "http://www.url-goes-here.com/"))
self.presentViewController(fbShare, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "Account Error", message: "You have to be logged in to use this function.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
When the user press the shareFacebookButtonit opens up a prompt where the user has to press "Post". Is there any ways that the users dont have to see the "Post" prompt? So when the user press shareFacebookButton it share to Facebook in background?