Invalid result SLComposeViewController

I am trying to use SLComposeViewController to post to Facebook in an iOS app. However, if I hit the cancel message, the result is “Done” is returned to the completion handler, and not “Canceled”. When I click on a message, it rejects and just freezes the application without returning any result. This code works great if the Facebook application is not installed on the device.

Here is the code I'm using for the Facebook part:

if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
                    var facebookVC: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
                        facebookVC.completionHandler = {
                            (result: SLComposeViewControllerResult) -> Void in
                            println("result: \(result.rawValue)")
                            switch(result) {
                                case SLComposeViewControllerResult.Cancelled:
                                    println("Facebook CANCELLED")
                                    break;
                                case SLComposeViewControllerResult.Done:
                                    println("Facebook DONE")
                                    self.facebookButton.selected = true
                                    self.facebookButton.userInteractionEnabled = false
                                    break;
                                default:
                                    break;
                            }
                        }
                    self.presentViewController(facebookVC, animated: true, completion: nil)
                } else {
                    var alert: UIAlertView!
                    alert = UIAlertView(title: "No Facebook Account", message: "There are no Facebook account configured. You can add or create a Facebook account in Settings", delegate: self, cancelButtonTitle: "OK")
                    alert.show()
                }
+4
source share
1 answer

I have the same problem on iOS 8.3 and only with the type of service Facebook. Sounds like Apple's mistake in social structure.

+2
source

All Articles