I am trying to use the Strong Password suggestion functionality in a SecureField using SwiftUI but it isn't working. Just wondering if I'm doing something wrong or it's a bug.
@State var password: String = ""
@State var confirmPassword: String = ""
var body: some View {
VStack {
SecureField("Password", text: $password) {
// do something
}
.textContentType(.newPassword)
SecureField("Confirm Password", text: $confirmPassword) {
// do something
}
.textContentType(.newPassword)
}
}
When I select the secureField it doesn't suggest a strong password.
Edit:
After further testing and comments below I have added an associated Domain and uploaded the following web credentials file to my webserver at example.com/.well-known/apple-app-site-association.txt:
{
"webcredentials": {
"apps": [ " TEAMID.com.example.AppName" ]
}
}
My capabilities currently are Associated Domains and Autofill Credential Provider set to YES.
When I try to use Strong Passwords I get the following error message:
Cannot show Automatic Strong Passwords for app bundleID: com.example.AppName due to error: Cannot identify the calling app's process. Check teamID and bundleID in your app's application-identifier entitlement
Not sure where to go from here.
If you have setup the SecureFields with .newPassword
and the "Associated Domains" appropriately, autofill upon sign-in and the suggestion of strong passwords should work on your device.
But be sure to have an iCloud account signed in and iCloud Keychain enabled. If this is not the case, it won't suggest strong passwords as it cannot sync them across devices. It will output some log as below:
[AutoFill] Cannot show Automatic Strong Passwords for app bundleID:
com.example.signin-playground due to error: iCloud Keychain is disabled
This testing can only be done on a real device because you cannot enable iCloud Keychain in the simulator.
If you want a new password to be suggested then you need to use the .newPassword
text content type.
.password
is for entering an existing password.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With