我一直在将代码转换为swift 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。
答案 0 :(得分:1)
错误几乎告诉你问题是什么。完成块必须是
类型(InitiationResult, Error?) -> Void
而不是
(Bool, Error?) -> Void
所以你应该能够做到:
verification.initiate { (result:InitiationResult, error:Error?) -> Void in
然后用
检查成功if result.success { ... }