I know that if we want to auto fetch the OTP(if we use single textfield) we need to use
otpTextField.textContentType = .oneTimeCode
But, If
What I do is similar to @Natarajan's answer, but I use UITextFieldDelegate
method. On viewDidAppear
your first text field should become first responder and be of type oneTimeCode
.
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
// Fill your textfields here
return true
}