For OTP text field, I have set textContentType as oneTimeCode
if #available(iOS 12.0, *) {
otpTextField.textContentType = .oneTimeCode
}
Your approach with content-type is correct , but there are few things to consider to make it work , Such as
Also , I implemented this by following steps given in below link
Reference Link : https://medium.com/@shankarmadeshvaran/how-to-implement-automatic-otp-verification-in-ios-7813c6116a1d
Hope It Helps