Reputation: 616
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
Use of unresolved identifier 'SINPhoneNumberUtil'
Use of unresolved identifier 'SINPhoneNumberFormat'
Use of undeclared type 'SINPhoneNumber'
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);
}
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..
Thanks for your help!
Upvotes: 1
Views: 275
Reputation: 5269
As I read in the link you attached in your question
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);
}
Upvotes: 1