blog

Autofill SMS token

<input id="single-factor-code-text-field" autocomplete="one-time-code" />

This is one of Apple-only features (for now). During OTP (one-time password) flow in the web or native app, when the user receives SMS with one-time code, if you have autocomplete="one-time-code" attribute on token input, it should autofill.

But just so it’s not so easy, at Hugo we learned that if “the system can parse a security code from an SMS message, the QuickType bar shows the code for up to three minutes after receiving it. If a security code arrives while the text input view is selected, the system pushes the incoming code to the QuickType bar.“

Note that iOS keyboard (with QuickType bar) won’t show if input is focused programatically.

And finally, I noticed that SMS containing the code needs to be in a specific format - with code being either the first or last thing in the message.