Autofill Password and Generate Strong Password in swift

Updated 24 April 2019


Password AutoFill simplifies login and account creation tasks for iOS apps and webpages. With just a few taps, your users can create and save new passwords or log in to an existing account. Users don’t even need to know their password, the system handles everything. This convenience increases the likelihood that users will complete your app’s onboarding process and start using your app more quickly. Additionally, by encouraging users to select unique, strong passwords, you increase the security of your app.

Autofill Password:

Apple introduced this new feature in iOS 11. By default, Password AutoFill saves the user’s login credentials on their current iOS device. iOS can sync these credentials securely across the user’s devices using iCloud Keychain. Password AutoFill recommends credentials only for your app’s associated domain, and the user must authenticate using Face ID or Touch ID before accessing these credentials.

To implement autofill firstly you need to On Associated Domains and Autofill Credential Provider in your project settings and enable the same in the project identifier on the developer account.

After that, we need to upload apple-app-site-association file on the most top root of the site and the apple-app-site-association file contains data like:

Now, We can implement autofill via two ways:

1. Autofill Password via Storyboard:

In the storyboard, you need to set the content type of the TextField to Username and Password, Username for email TextField and Password for Password TextField respectively.

2. Autofill via Programmatically:

For programmatically you need to set textContentType of the username and password TextFields.

When you try to login in the App with your login details then it will ask to save login details for future use.

After authentication, the OS will show a list of saved passwords from which you can select the one that you think is the right one for the app. This will automatically fill all the TextFields as per the textContentType given.

Generate Strong Password:

Apple introduced this new feature in iOS 12 during WWDC18. Encouraging users to use unique, strong passwords, increases the security of your app. Enabling this feature is just as easy as enabling Password AutoFill. All you need to do is set the textContentType property to a new password and a passwordRules for password validation.

It will generate a strong on the basis of passwordRules and remember it in the keychain.

That’s it. !


. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home