Sinch Sms验证2.0.3 SDK Swift 3 [英] Sinch Sms Verification 2.0.3 SDK Swift 3

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

问题描述

您好,我使用Sinch短信验证在我的应用中注册用户,但将代码更新为swift 3(并且当前为Sinch sdk 2.0.3)后,我收到以下错误

Hi Im using Sinch sms verification to sign up users in my app but after updating my code to swift 3 (and sinch sdk currently 2.0.3), Im getting the following error

使用未解析的标识符'SINPhoneNumberUtil'

Use of unresolved identifier 'SINPhoneNumberUtil'

使用未解析的标识符'SINPhoneNumberFormat'

Use of unresolved identifier 'SINPhoneNumberFormat'

使用未声明的类型"SINPhoneNumber"

Use of undeclared type 'SINPhoneNumber'

使用以前的SDK和Swift 2的代码

That the code who was working with previous SDK and Swift 2

if (result.success){

                    let phoneUtil = SINPhoneNumberUtil() 

                    do {
                        let defaultRegion = DeviceRegion.currentCountryCode()
                        let phoneNum: SINPhoneNumber = try phoneUtil.parse(self.phoneNumber.text!, defaultRegion: defaultRegion)
                        let formattedString: String = try phoneUtil.formatNumber(phoneNum, format: SINPhoneNumberFormat.E164)//format(phoneNumber, numberFormat: .E164)
                        self.formattedNumToPass = formattedString
                        print(formattedString)
                    }
                    catch let error as NSError {
                        print(error.localizedDescription)
                    }
                    self.performSegue(withIdentifier: "enterPin", sender: sender);
}

我看到SinchVerification参考文档中有一些更改: http://download.sinch.com/docs/verification/ios/latest/reference-swift/html/index.html
但是到目前为止,我没有成功做出正确的更改..

I saw there were some changes in the SinchVerification reference docs : http://download.sinch.com/docs/verification/ios/latest/reference-swift/html/index.html
but so far I didnt succeed to make the right changes..

感谢您的帮助!

推荐答案

我在问题中附加的链接中读到

As I read in the link you attached in your question

SIN前缀是为了解决您面临的错误,只需将其从代码中删除即可.

SIN prefix was dropped so to fix the errors that you're facing just remove it from your code like this.

if (result.success) {

    let phoneUtil = SharedPhoneNumberUtil()

    do {
        let defaultRegion = DeviceRegion.currentCountryCode()
        let phoneNum: PhoneNumber =
            try phoneUtil.parse(self.phoneNumber.text!, defaultRegion: defaultRegion)
        let formattedString: String =
            try phoneUtil.formatNumber(phoneNum, format: PhoneNumberFormat.e164) //format(phoneNumber, numberFormat: .E164)
        self.formattedNumToPass = formattedString
        print(formattedString)
    } catch
    let error as NSError {
        print(error.localizedDescription)
    }
    self.performSegue(withIdentifier: "enterPin", sender: sender);
}

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

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