ios - 如何使用 SLComposeViewController 检测用户成功分享到 Facebook

标签 ios swift facebook slcomposeviewcontroller

我在应用程序中创建了一个按钮,用于在 Facebook 上与 SLComposeViewController 共享状态。 如何判断用户是否真的点击分享状态?

我的代码如下:

@IBAction func fbBtn(_ sender: Any) {

    if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeFacebook) {
        let fbShare:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)

        self.present(fbShare, animated: true, completion: nil)

    } else {
        let alert = UIAlertController(title: "Accounts", message: "Please login to a Facebook account to share.", preferredStyle: UIAlertControllerStyle.alert)

        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }
} 

最佳答案

问题解决了TQ

fbShare.completionHandler = { (result:SLComposeViewControllerResult) -> Void in
            switch result {
            case SLComposeViewControllerResult.cancelled:
                print("Cancelled") 
                break

            case SLComposeViewControllerResult.done:
                print("Done")
                break
            }
        }

关于ios - 如何使用 SLComposeViewController 检测用户成功分享到 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40481697/

相关文章:

java - 谷歌云消息 : don't receive alerts when iOS App is in background

ios - 在模态视图 Controller 之间切换

html - 从 iOS Swift 中的摄像头扫描仪 SDK 返回时,WKwebview 是空白屏幕吗?

ios - Pod 版本导致 CFBundleShortVersionString 错误

ios - 今天扩展与 NSNotificationCenter 崩溃

ios - SwiftUI 的 minimumFontScale 等价物是多少?

android - Facebook 登录按钮阻止整个 Android Activity

iphone - iOS:不正确/重复的 Facebook 请求消息

iphone - 从 Iphone native 客户端使用 Google App Engine 进行身份验证

ios - Swift 3 URLSession 发送空请求