Skip to main content

Password Autofill in iOS 11

Password Autofill








9to5mac.com
As a user, we have many applications installed on our devices and most of them have a login feature.
Logging in is the first step that a user has to take when they start with an app that requires an account. This usually takes a couple of seconds if the user remembers their credentials and is able to type them right away. Many users, instead, use the password manager service like iCloud Keychain1PasswordLastPassNortonIDSafe etc. and copy their username and password.
Many of the applications have the same username and password as we use the email address as our login name and to keep it simple to remember the password we usually have a tendency to have the same password for more than one application or we have set of passwords which we use for all the application for example.
Username: santosh@gmail.com
FB Password: P@ssword
Email Password: P@ssword
I know, every account should have unique/different password, security loophole, risky and blah… blah… blah…
It is what it is. 🙄 🙄 🙄

Now the point is what to do now?
Apple has introduced a very basic but important feature at WWDC 2017 that many of us wanted to have.
In iOS 11, Apple has introduced a seamless way to streamline the login process with the new Password AutoFill API.
This is a very easy and faster way for users to login and developers to implement for their applications.
In this blog, we will be going through a step by step to have it in our application.

Preparing your App for AutoFill

There are two scenarios which we can handle to use the AutoFill in our application.
  • QuickType bar just above the keyboard with the key symbol.
  • Link our website and application which will directly show the exact user name and password combination for your application.
Let’s walk through both the scenarios one by one.
# QuickType Bar
Showing the password button is as simple as changing one setting on your text fields.
userNameTextField?.textContentType = .username
passwordTextField?.textContentType = .password
That’s it, and you are done.
Run your application and tap on the userNameTextField or passwordTextField it will show you the keyboard.




Wait, there is simple change when you see the keyboard now compare to the keyboard which you were using previously.
🔑 at right top of the keyboard.
Tap on 🔑.


Asking for your TouchID.. Ya.. safety :)

It will present a list of username & passwords available in the default password manager.



Tap on any one of them and it will auto fill your username and password text field.



NOTE: I kept the password field as a plain text field intentionally.
Feeling great, right? Wait a minute. What if you want to sign up? Only username & password will not suffice your needs.
UITextContentType has many other semantic meanings expected for a text field like from iOS 10.
emailAddress, countryName, creditCardNumber and many more.
Get the entire list here.
UITextContentType like username & password are introduced in IOS 11.

Our applications will get the list of username & password combinations, but from where?
🤔 🤔 🤔 Good question.
iOS and Mac OS have a password manager inbuilt and integrated in Safari.
Whenever user login to any site using Safari it prompts user for saving a password.


Safari Save Password Prompt

I understand, in the above scenario it shows all the username/password combination to fill in.
But, I am very sure that, user has logged into my site and has saved the credentials in the safari password manager?
That means, instead of showing list of username/password can my application show my site/app specific username & password. User just tap on key and we are done.
YES, We can do this.
😊 😊 😊 Thanks to Apple.

# Associating your specific app password

In iOS 11, application & sites can have the association.
Let’s understand how to do the association of application and website.
To establish the association between our application and our website we require a file called apple-app-site-association.
It might be familiar to you, If you have supported the deep-linking or universal linking to iOS users can tap a link to your website and get seamlessly redirected to your installed app without going through Safari. If your app isn’t installed, tapping a link to your website opens your website in Safari.
If not, don’t worry. It’s not required here.
If your app doesn’t have deep-linking, you’ll need to enable Associated Domains in your Xcode project.
Switch to your Xcode project settings, go to the Capabilities tab, and turn on Associated Domains.


Project capabilities

Add your website URL here. Let’s say your website domain name is santoshbotre.com: the listed domain name should be,
webcredentials:santoshbotre.com
webcredentials:[listed_domain_name]
You can have multiple domain association for your application.
On you server, add an apple-app-site-association file, or extend your current one, if present. It should contain a webcredentials section that specifies your app.
Here’s an example:
{
     "webcredentials": {
            "apps": [A6411SB83A.com.santoshbo.PasswordAutoFill]
     }
}
A6411SB83A.com.santoshbo.PasswordAutoFill is application bundle id.
Apple recommends adding this file to the /.well-known directory, but you may also use the root. The full path will look like this:
Your application is ready for AutoFill will association with your site. Isn’t it simple.
Build and run your app on a device running iOS 11 (this functionality is not available in the simulator).
You will able to see the,


Associated Password Autofill

If you want to know more about Password AutoFill, check out Session 206 at WWDC 2017

Comments

Popular Posts

Reloading UITableView while Animating Scroll in iOS 11

Reloading UITableView while Animating Scroll Calling  reloadData  on  UITableView  may not be the most efficient way to update your cells, but sometimes it’s easier to ensure the data you are storing is in sync with what your  UITableView  is showing. In iOS 10  reloadData  could be called at any time and it would not affect the scrolling UI of  UITableView . However, in iOS 11 calling  reloadData  while your  UITableView  is animating scrolling causes the  UITableView  to stop its scroll animation and not complete. We noticed this is only true for scroll animations triggered via one of the  UITableView  methods (such as  scrollToRow(at:at:animated:) ) and not for scroll animations caused by user interaction. This can be an issue when server responses trigger a  reloadData  call since they can happen at any moment, possibly when scroll animation is occurring. Example of s...

What are the Alternatives of device UDID in iOS? - iOS7 / iOS 6 / iOS 5 – Get Device Unique Identifier UDID

Get Device Unique Identifier UDID Following code will help you to get the unique-device-identifier known as UDID. No matter what iOS user is using, you can get the UDID of the current iOS device by following code. - ( NSString *)UDID { NSString *uuidString = nil ; // get os version NSUInteger currentOSVersion = [[[[[UIDevice currentDevice ] systemVersion ] componentsSeparatedByString: @" . " ] objectAtIndex: 0 ] integerValue ]; if (currentOSVersion <= 5 ) { if ([[ NSUserDefaults standardUserDefaults ] valueForKey: @" udid " ]) { uuidString = [[ NSUserDefaults standardDefaults ] valueForKey: @" udid " ]; } else { CFUUIDRef uuidRef = CFUUIDCreate ( kCFAllocatorDefault ); uuidString = ( NSString *) CFBridgingRelease ( CFUUIDCreateString ( NULL ,uuidRef)); CFRelease (uuidRef); [[ NSUserDefaults standardUserDefaults ] setObject: uuidString ForKey: @" udid " ]; [[ NSUserDefaults standardUserDefaults ] synchro...

Xcode & Instruments: Measuring Launch time, CPU Usage, Memory Leaks, Energy Impact and Frame Rate

When you’re developing applications for modern mobile devices, it’s vital that you consider the performance footprint that it has on older devices and in less than ideal network conditions. Fortunately Apple provides several powerful tools that enable Engineers to measure, investigate and understand the different performance characteristics of an application running on an iOS device. Recently I spent some time with these tools working to better understand the performance characteristics of an eCommerce application and finding ways that we can optimise the experience for our users. We realised that applications that are increasingly performance intensive, consume excessive amounts of memory, drain battery life and feel uncomfortably slow are less likely to retain users. With the release of iOS 12.0 it’s easier than ever for users to find applications that are consuming the most of their device’s finite amount of resources. Users can now make informed decisions abou...