Skip to content

Instantly share code, notes, and snippets.

@shakked
Created July 19, 2016 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shakked/718da9f2c9aef943b3bd0783dbf36335 to your computer and use it in GitHub Desktop.
Save shakked/718da9f2c9aef943b3bd0783dbf36335 to your computer and use it in GitHub Desktop.
func verifyButtonPressed() {
let rawNumber = mobileNumberTextField.text ?? ""
do {
let phoneNumber = try PhoneNumber(rawNumber: rawNumber, region: "US")
let formattedPhoneNumber = phoneNumber.toInternational()
self.mobileNumberTextField.text = formattedPhoneNumber
let verification = SMSVerification(applicationKey: C.APIs.SinchKey(), phoneNumber: formattedPhoneNumber)
self.verification = verification
startActivityIndicator()
self.verification?.initiate { (succeeded, error) in
guard succeeded else {
self.stopActivityIndicator()
print(error)
CrewError.PhoneNumberVerificationFailed.showAlert(self)
return
}
dispatch_async(dispatch_get_main_queue(), {
self.showVerifyCodeAlert()
})
}
} catch {
Analytics.log(Events.Phone_Verification_Attempted, parameters: Events.Params.action("Invalid Phone Number"))
CrewError.InvalidPhoneNumber.showAlert(self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment