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

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...

16 AWS Gotchas

16 AWS Gotchas In January I launched the MVP for my own startup,  Proximistyle , which helps you find what you’re looking for nearby. On advice from friends and industry contacts I chose AWS as my cloud provider. Having never had to set up my own cloud infrastructure before, the learning curve to get from no experience to a stable VPC system I was happy with was significantly steeper than expected, and had its fair share of surprises. #1 Take advantage of the free resources offered AWS offers a free tier for new accounts. If you have recently bought a domain and set up a company you qualify for the free tier for a year. Additionally, if you are a bootstrapped startup you can apply for  the Startup Builders package  and get $1000 in AWS credits. After doing the above, you’re now ready to get started with setting up the AWS infrastructure for your startup. #2 Set up billing budgets and alerting The very first thing you should do after setting up billing, is enabling a budge...

Ultimate Folder Structure For Your React Native Project

  Ultimate Folder Structure For Your React Native Project React native project structure React Native is a flexible framework, giving developers the freedom to choose their code structure. However, this can be a double-edged sword for beginners. Though it offers ease of coding, it can soon become challenging to manage as your project expands. Thus, a structured folder system can be beneficial in many ways like better organization, simplified module management, adhering to coding practices, and giving a professional touch to your project. This write-up discusses a version of a folder arrangement that I employ in my React Native projects. This structure is based on best practices and can be modified to suit the specific needs of your project. Before we get into the project structure let’s give credit to @sanjay who has the original idea of the structure but I modify his version of the code, to make it better. Base library axios  — For network calling. react-navigation ...