Automatic OTP verification in iOS?

Rinshad Kammath picture Rinshad Kammath · Sep 22, 2016 · Viewed 54.7k times · Source

Is there any way to access data from iPhone inbox(SMS) to ios application to do automatic OTP verification like the one in Android? I shall be grateful for your help.

Answer

iVarun picture iVarun · Jun 11, 2018

In iOS 12 Apple has introduced feature called Security Code AutoFill.

To use this in your app all you need to do is set UITextField's input view’s textContentType property oneTimeCode.

otpTextField.textContentType = .oneTimeCode

NOTE: Security Code AutoFill will only works with System Keyboard it will not work with custom keyboard.

WWDC video

When you get OTP it will look something like this:

enter image description here