Sinch验证Swift 3 [英] Sinch Verification Swift 3

查看:117
本文介绍了Sinch验证Swift 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在将代码转换为swift3.自验证以来,我遇到了一个问题:

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

这是我的代码:

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返回以下错误:

Xcode is returning the following error:

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

关于如何解决此问题的任何想法?我已更新到最新版本的sdk.

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

推荐答案

该错误几乎可以告诉您问题出在哪里.完成块必须为类型

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

(InitiationResult, Error?) -> Void

代替

(Bool, Error?) -> Void

因此您应该可以:

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

,然后使用

if result.success { ... }

这篇关于Sinch验证Swift 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆