Sinch 短信验证 swift 3

Sms Verification with Sinch swift 3

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

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

我知道如果我将 NSError 更改为 Error ,这个错误就会消失

但我需要从 NSError 中获取错误代码来提醒我的用户发生了什么取决于这个错误

   if (result.success){
          //login user
         } else {
            if error!.code == 6 {
                   let msg = NSLocalizedString("This Phone Number is invalid",
                         comment: "This Phone Number is invalid pop up alert")
                   print(msg)
            }
   } 

来自 Sinch Docs,我想使用这个 NSError:

https://www.sinch.com/docs/verification/ios/#swiftsdk

 let verification = SMSVerification(applicationKey:"<APP KEY>", phoneNumber: phoneNumberInE164)
    verification.initiate { (result: InitiationResult, error: NSError?) -> Void in
        // handle outcome
    }

有没有办法从 error:Error 获取 error.code? 感谢您的帮助

let verification = SMSVerification(applicationKey:"<APP KEY>", phoneNumber: phoneNumberInE164)
    verification.initiate { (result: InitiationResult, error: Error?) -> Void in
        // handle outcome
        if (result.success){
          //login user
         } else if let error = error as? NSError, error.code == 6 {
            let msg = NSLocalizedString("This Phone Number is invalid",
                         comment: "This Phone Number is invalid pop up alert")
            print(msg)
         }
    }