Since iOS 12, the system can read the one-time password from the received SMS automatically and add it above the keyboard, So users can use the code with only one touch. There are rules and limitations for doing this as I tried to list most of them below:
- The message must contain the Code prase. Some other words like passcode and password are ok too in English.
- The Code phrase (with or without
:
) must be separate with only one space with your numbers.
example:
Code 1111111
Code: 111111
- The OTP number must be English NOT your localized.
- The Code phrase can be localized into your preferred language.
example:
English: Code
Spanish: Codingo
Germany: Kode
Czech: Kod
Persian: رمز
Arabic: رمز
- The code should have more than 4 digits
In code, just set the textField content type to the one-time password.
otptextField.textContentType = .oneTimeCode
The code appears only on top of the standard system keyboard requires user action.