简体   繁体   中英

Save Password Alert does not appear in Swift

I want this alert to appear when the user logs in to my application.

在此处输入图像描述

I made this tutorial for this. iOS 12 Password Tools: Improving User Security and Experience

Also I have look this topic. And using this code in my LoginViewController.swift in viewDidDisappear or viewWillDisappear. But This alert does not appear at all.

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    if user.id != 0 {
        usernameTextField.text = nil
        passwordTextField.text = nil
    }

}

My entitlements file like this (Suppose that twitter.com is the website of my application):

<key>com.apple.developer.associated-domains</key>
<array>
    <string>applinks:twitter.com</string>
    <string>webcredentials:twitter.com</string>
</array>
<key>com.apple.developer.authentication-services.autofill-credential-provider</key>
<true/>

And off course my usernameTextField content type is username and passwordTextField content type is password .

So I want to ask why this alert didn't come off.

When creating a new account or changing the password, use the.newPassword text content type for the password TextField:

newPasswordTextField.textContentType = .newPassword
confirmPasswordTextField.textContentType = .newPassword

Enabling Password AutoFill on a Text Input View


You can also manage iCloud Keychain Credentials using the Security.SecSharedCredentials API. It will still require a domain association (entitlements):

SecAddSharedWebCredential("your_domain.com" as CFString,
                           usernameTextField.text as CFString,
                           newPasswordTextField?.text as CFString, {(error) in })

SecAddSharedWebCredential


Next, you should add the Apple App Site Association file to your website.

Create a file named apple-app-site-association (without an extension). Update the file to contain the JSON representation of a dictionary listing the app identifiers associated with your domain for the webcredentials service.

{
   "webcredentials": {
       "apps": [    "D3KQX62K1A.com.example.DemoApp",
                    "D3KQX62K1A.com.example.DemoAdminApp" ]
    }
}

Use the following format for the app identifiers:

<Team Identifier>.<Bundle Identifier>

Place this file either in your site's.well-known directory, or directly in its root directory. If you use the.well-known directory, the file's URL should match the following format:

https://<fully qualified domain>/.well-known/apple-app-site-association

You must host the file using https:// with a valid certificate and without using any redirects.

Setting Up an App's Associated Domains

After the autofill password feature is implemented, the save password alert will show on you push or present (full screen) to next ViewController.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM