How to show verification code suggestion on keyboard from Message How to show verification code suggestion on keyboard from Message ios ios

How to show verification code suggestion on keyboard from Message


Review WWDC 2018 Session 204 - Automatic Strong Passwords and Security Code AutoFill.

You will need to use a UITextField for entry and the system keyboard (no custom controls) and set the textContentType on it to .oneTimeCode (new in iOS 12).

let securityCodeTextField = UITextField()securityCodeTextField.textContentType = .oneTimeCode

The operating system will detect verification codes from Messages automatically (messages that contain the word "code" or "passcode") with this UITextContentType set.


For those who's searching how to do that in HTML: need to add autocomplete="one-time-code" for your input field.

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

(from Apple Docs)


Storyboard

Select UITextField > Show the Attributes inspector > Text Input Traits > Content Type > One Time Code

enter image description here