Why am I able to fill OTP with Autofill without using .oneTimeCode in Swift?

131 Views Asked by At

I am using iOS 17, and in my app, I am able to autofill OTP's without using textfield content type as .oneTimeCode. Considering that, I was wondering what's the use of using this content type in my textfield? Thanks

1

There are 1 best solutions below

1
Paulw11 On

If you don't specify your content type as OTP, iOS may offer the code anyway based on its own heuristics; for example, if the user just entered a username and password and they move to a new screen with a single text field then an OTP message arrives. These behaviours are not documented, so you shouldn't rely on them.

Setting the content type provides more information to iOS to help it. If your field is for an OTP, why wouldn't you specify the content type?