Username, Password and OTP autofill for iOS Apps for faster login 🤨🤪

Last month I went for an iOS dev meetup at Apple App Accelerator Bengaluru, India. There they discussed about many iOS 11 features and best practices which we need to implement in our apps. Password autofill was one such feature. Here , I will explain what it is and how to do it.

Image for post
Image for post

How to enable autofill?

UITextFiled or UITextView confirms to UITextInput protocol as mentioned earlier. UITextInput confirms to UIKeyInput and UIKeyInput confirms to UITextInputTraits protocol. UITextInputTraits has an optional var called textContentType which will provide the keyboard with extra information about the semantic intent of the text document.

Image for post
Image for post
usernameTF.textContentType = .usernamepasswordTF.textContentType = .password
Image for post
Image for post
Image for post
Image for post

Can the app predict the password accurately instead of making the user select the password from the list?

YES!. If you are an iOS user, you might have seen this:

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
source: wwdc 2017 session 206
Image for post
Image for post

How to add/delete/modify passwords?

Well, in iOS 11, this feature is added to the device settings .

Image for post
Image for post
click on Accounts & passwords and authenticate
Image for post
Image for post
Add/delete/modify the passowrd here.

How to AutoFill One Time Security Code or OTP (iOS 12+ )?

Image for post
Image for post
myOTPTextField.textContentType = .oneTimeCode

If you enjoyed reading this post, please share and give some clapps so others can find it 👏👏👏👏👏 !!!!

You can follow me on Medium for fresh articles. Also, connect with me on LinkedIn.

iOS and tvOS developer, dreamer, photographer 🤨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store