For this app I have so far implemented the phone verification for CryptoWallet. Currently the app functions by taking in as input a US phone number. Then it parses, formats, and checks the number using the libPhoneNumberiOS library. If the phone number is accurate an alert message is displayed saying that a verification code will be sent. Otherwise an error alert is printed to try again.
- libPhoneNumber-iOS - phone number verification & formatting
- Material Design - UI elements including phone number field and verify button
- XCode 10 & Swift 4
- Action for the Verify Button to check the phone number the user has input
- Has do() catch() for error handling
- Gets phoneField input and validates using: parse(), format(),isValidNumber() from the libPhoneNumber-iOS library
- If the Action is not valid throws an error and alerts the user using: catchError, setGenerateAlert()
- checks the return of isValidNumber()
- if the phone Number is not valid then throws an invalidPhoneNumber error
- Initializes new UIAlertController with the passes in alertTitle and Message
- Then adds an action through .addAction() to generate a UIAlertAction as an OK button to cancel the alert.
- Once the user touches away from phone number field it goes away by using .resignFirstResponder()
- Function in the Extension of the UITextFieldDelegate
- Takes whatever is being input into the text field and formats it continouously using the format() function
- Function to format 10 digit phone numbers continuously
- formats the number by checking the digits and calling replacingOccurrences()