Sinch Verification Swift 3

浪子不回头ぞ 提交于 2019-12-12 03:06:34

问题


I have been converting my code to swift 3. I have an issue with since verification:

This is the code I have:

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 is returning the following error:

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

Any ideas on how to fix this? I have updated to the latest version of the sdk.


回答1:


The error pretty much tells you what the problem is. The completion block has to be of type

(InitiationResult, Error?) -> Void

instead of

(Bool, Error?) -> Void

So you should be able to do:

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

and then check the success with

if result.success { ... }


来源:https://stackoverflow.com/questions/40696776/sinch-verification-swift-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!