Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.newPassword for SecureField to choose Strong Password not working using SwiftUI and iOS14

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.

like image 765
alionthego Avatar asked Nov 06 '22 02:11

alionthego


2 Answers

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.

like image 173
pd95 Avatar answered Nov 15 '22 11:11

pd95


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.

like image 23
Paulw11 Avatar answered Nov 15 '22 12:11

Paulw11