This demo is of iOS based OTP Authentication, used to verify your mobile number with OTP (One Time Password).
This demo is of iOS based OTP Authentication, used to verify your mobile number with OTP (One Time Password).
Version - iOS 13.x or later
We have tested our program in above versions, however you can use it in other versions as well
Download this sample project and import swift utility resource files in your project.
Process setup is described below to integrate in sample project.
Configure your required property of countriesPickerVcObj
Also set delegate and implement method for call back selected country details
e.g.
extension ViewController: CountriesViewControllerDelegate {
func countriesViewController(_ countriesViewController: CountriesViewController, didSelectCountry country: Country) {
//Return last selected country details
}}
var selectedCountry:CountryModel?
var config:PinConfig! = PinConfig()
// Length of OTP
config.otpLength = .six
// Secure text mask color
config.dotColor = .black
config.lineColor = #colorLiteral(red: 0.8265652657, green: 0.8502194881, blue: 0.9000532627, alpha: 1)
//Space beetween two text field
config.spacing = 30
//set secure text
config.isSecureTextEntry = true
//show place hodder
config.showPlaceHolder = true
like Enter only specify values in textfield
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
///- For Phone number validation
if textField == txtPhoneNumberField {
let aSet = NSCharacterSet(charactersIn:"0123456789").inverted
let compSepByCharInSet = string.components(separatedBy: aSet)
let numberFiltered = compSepByCharInSet.joined(separator: "")
return string == numberFiltered
}
else{
return true
}
}
- setUpOTPView: this method provide setup of OTP text field like below
validate number with server use of below method
callback response
self.countriesPickerVcObj.verifyOTP(otpCode: "123456", onSuccess:(authDataResult,bool) , onFailure:(error,isError)
call back validate details information
self.countriesPickerVcObj.validateContryAndPhoneNumber(contryCode: "+1", phoneNumber: "9XXXXXXXXX", isValidDetails:(isValid,strMsg)
Param
Param
Param
Create Project setup in firebase console using below URL
https://console.firebase.google.com/
Please Enable Phone Number sign-in for your Firebase project in console
https://firebase.google.com/docs/auth/ios/phone-auth
Download GoogleService-Info.Plist file and add into project
install firebase pod and run project
The OTPAuthentication
demo use in you app then same option as the <OTPAuthentication>
install firebase pod
show country picker use of below method help of CountriesViewController class object
CountriesViewController.show(countriesViewController: self.countriesPickerVcObj, toVar: self)
select country and Phone number
Press send button to validate entered details and send OTP help of below mehods
FirebaseAuthenticate.firSharedInstance.sendOtpAfterValidatePhonenumber
Verify OTP with below method
FirebaseAuthenticate.firSharedInstance.verifyOTP
We also provide a free, basic support for all users who want to use this OTP verification demo in project. In case you want to customize this OTP demo input to suit your development needs, then feel free to contact our iOS
developers.
We have built many other components and free resources for software development in various programming languages. Kindly click here to view our Free Resources for Software Development.
Detailed changes for each release are documented in CHANGELOG.md.
OTP, Firebase Authentication, One Time Password, OTP For iOS, OTP Authentication, Mobile Number Verficiation,
OTP Verification, Firebase OTP Authentication, weblineindia