How to show verification code suggestion on keyboard from Message

lee picture lee · Jun 9, 2018 · Viewed 16.6k times · Source

I watched this video What's New in Cocoa Touch at WWDC 2018 and seen:

What's New in Cocoa Touch

How to show this information?

Answer

JAL picture JAL · Jun 9, 2018

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.