Clicky

iOS Dev Nugget 274 Password AutoFill

.

Need to run a code review on your codebase? Hire me

In #232 we looked at how we can use Shared Web Credentials to share login information between your iOS app and Safari by reading/writing to the keychain.

There's a new feature in iOS 11 for apps called Password AutoFill. It lets iOS populate your username and password fields with information from the keychain chosen by the user with a single tap. This goes one step further to reduce the friction for users to move from using your website to running your app.

If you have seen this Password AutoFill QuickType bar in an app, it is AutoFill in action:

If you tap the button, it should attempt to authenticate using Touch ID and then show you a list of logins to choose from to fill in to the login form. If the app haven't done anything to enable AutoFill, iOS uses some heuristics to try to make it work.

You might even see some a username appearing in the AutoFill QuickType bar, letting you tap on it to choose it right away.

This is all done automatically by iOS

But if want to be sure AutoFill works correctly and show the correct username to the user in the AutoFill QuickType bar, you can set this up explicitly by:

1) Setting the content type of yoru username and password field:

usernameField.textContentType = .username
passwordField.textContentType = .password

2) Enable the associated domains entitlements in Xcode and set up a site associate file on your website. You would have done this if you have already set up Shared Web Credentials.

If you visit the login screen in your app again, you should notice the AutoFill QuickType bar pop up correctly and the username matching your app should appear.

Here's the WWDC video explaining Password AutoFill if you need more details.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues