2016-11-19 5 views
0

Ich habe meinen Code swift 3. Umwandlung Ich habe ein Problem mit seit Überprüfung:Sinch Verification Swift 3

Dies ist der Code, den ich habe:

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 wird die folgende Fehler zurückgegeben:

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

Irgendwelche Ideen, wie Sie das beheben können? Ich habe auf die neueste Version des SDK aktualisiert.

Antwort

1

Der Fehler sagt Ihnen ziemlich genau, was das Problem ist. Der Abschluss Block vom Typ zu tun

(InitiationResult, Error?) -> Void 

statt

(Bool, Error?) -> Void 

So sollten Sie in der Lage sein, sein:

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

und überprüfen Sie den Erfolg mit

if result.success { ... } 
+0

Danke. Ich war mir einfach nicht sicher, wie ich Erfolg und Fehler überprüfen konnte –