Reputation: 53
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()
}
Upvotes: 4
Views: 869
Reputation: 1451
I have the same issue on iOS 8.3 and only with Facebook service type. Seems like Apple's bug in the Social framework.
Upvotes: 2