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

React Native - Text Input

In this chapter, we will show you how to work with  TextInput  elements in React Native. The Home component will import and render inputs. App.js import React from 'react' ; import Inputs from './inputs.js' const App = () => { return ( < Inputs /> ) } export default App Inputs We will define the initial state. After defining the initial state, we will create the  handleEmail  and the  handlePassword  functions. These functions are used for updating state. The  login()  function will just alert the current value of the state. We will also add some other properties to text inputs to disable auto capitalisation, remove the bottom border on Android devices and set a placeholder. inputs.js import React , { Component } from 'react' import { View , Text , TouchableOpacity , TextInput , StyleSheet } from 'react-native' class Inputs extends Component { state = { ...

An introduction to Size Classes for Xcode 8

Introduction to Size Classes for Xcode In iOS 8, Apple introduced  size classes , a way to describe any device in any orientation. Size classes rely heavily on auto layout. Until iOS 8, you could escape auto layout. IN iOS8, Apple changed several UIKit classes to depend on size classes. Modal views, popovers, split views, and image assets directly use size classes to determine how to display an image. Identical code to present a popover on an iPad  causes a iPhone to present a modal view. Different Size Classes There are two sizes for size classes:  compact , and  regular . Sometime you’ll hear about any.  Any  is the generic size that works with anything. The default Xcode layout, is  width:any height:any . This layout is for all cases. The Horizontal and vertical dimensions are called  traits , and can be accessed in code from an instance of  UITraitCollection . The  compact  size descr...

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