This article is a short version of this WWDC video.
Please do read my article on password autofill before proceeding 🔥🔥🔥🔥.
From iOS 12, you might have seen iOS suggesting strong password while signing up for an app. This is a new feature in iOS introduced in WWDC 2018. I will explain how it works in iOS.
How to enable strong password autofill in iOS?
newPasswordTextField.contentType = .newPassword
By default, the generated passwords are 20 characters long. They contain uppercase, digits, hyphen, and lowercase characters. This gives you a strong password with more than 71 bits of entropy. Apple designed this to be a strong, yet compatible with most services. It is, of course, possible for your apps to define their own custom password rules. As mentioned before, in most cases, you don’t need to do this because the default format of Automatic Strong Passwords should be compatible.
A sample default password generated if we do not provide any strong password rules is given below.
They contain uppercase, digits, hyphen, and lowercase characters.
However, if your app’s backend requires a separate set of rules that are not compatible with the default format of Automatic Strong Passwords, you could define your own rules. To do so, use the new password rules language in iOS 12. Apple does not have access to the credentials stored in Keychain, so users’ privacy is preserved, as well.
How to customize Password AutoFill Rules?
Say you want to require a password with at least eight characters consisting of a mix of uppercase and lowercase letters, at least one number, and at most two consecutive characters. You would add this markup:
let newPasswordTextField = UITextField()
newPasswordTextField.passwordRules = UITextInputPasswordRules(descriptor: "required: upper; required: lower; required: digit; max-consecutive: 2; minlength: 8;")
Refer to this article for more ways to customize the password rule.
You can use the Password Rules Validation Tool to create , validate and download example passwords for testing purpose etc.
That’s it. !!
If you enjoyed reading this post, please share and give some clapps so others can find it 👏👏👏👏👏 !!!!
If you have any comment, question, or recommendation, feel free to post them in the comment section below!