2016-11-19 51 views
0

我一直在我的代碼轉換爲SWIFT 3.我有一個問題,因爲與驗證:Sinch驗證雨燕3

這是我的代碼有:

verification.initiate { (success:Bool, error:Error?) -> Void in 
      //handle outcome 
      if (success){ 
       print("successfully requested phone verification") 
       //segue to next screen 
       self.performSegue(withIdentifier: "xxx", sender: nil) 
      } else { 
       let alert = UIAlertController(title: "Alert", message: error?.localizedDescription, preferredStyle: .alert) 
       alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil)) 
       self.present(alert, animated: true, completion: nil) 
       print(error?.localizedDescription) 
       self.buttonsEnable(true) 
      } 
} 

Xcode是返回以下錯誤:

Cannot convert value of type '(Bool, Error?) -> Void' to expected argument type '(InitiationResult, Error?) -> Void' 

有關如何解決此問題的任何想法?我已更新到最新版本的SDK。

回答

1

這個錯誤幾乎告訴你問題是什麼。完成塊必須是類型

(InitiationResult, Error?) -> Void 

,而不是

(Bool, Error?) -> Void 

所以,你應該能夠做到:

verification.initiate { (result:InitiationResult, error:Error?) -> Void in 

,然後選中與

if result.success { ... } 
成功
+0

謝謝。我只是不確定如何檢查成功與錯誤 –