2016-11-08 51 views
1

我創建了一個按鈕,在FacebookSLComposeViewController共享狀態。 如何檢查用戶是否確實點擊分享了狀態?如何檢測用戶與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) 
    } 
} 

回答

1

問題解決了TQ

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

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