4

I'm trying to use SLComposeViewController to share a post to Facebook in an iOS app. However, if I hit cancel on the post, a result of "Done" is returned to the completion handler instead of "Cancelled". When I hit post, it dismisses and just freezes the app without returning any result. This code works fine if the Facebook app is not installed on the device.

Here is the code that I'm using for the Facebook portion:

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()
                }
  • same problem here since 8.3 - When aborting /cancelling SLServiceTypeFacebook then SLComposeViewControllerResultDone is returned – Philipp May 04 '15 at 14:19
  • It's discussed in this [bug report](https://developers.facebook.com/bugs/962985360399542/). – amudi May 12 '15 at 02:26
  • For the time being, I'm checking to see if the Facebook app is installed on device, and if so, I alert the user in the success dialog that canceled posts will incorrectly report back as posted, even though they didn't. Bug is in Facebook's code I would assume, not Social framework. Based on the above Fb bug report, it doesn't look like they are in any rush to fix it. Surprised Apple let them swap in their own implementation for such a core iOS action if the Fb app is installed. – Chad Podoski Nov 13 '15 at 21:51

1 Answers1

2

I have the same issue on iOS 8.3 and only with Facebook service type. Seems like Apple's bug in the Social framework.

Stanislau Baranouski
  • 1,425
  • 1
  • 18
  • 22