Created
July 19, 2016 23:01
-
-
Save shakked/718da9f2c9aef943b3bd0783dbf36335 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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