将用户名和密码保存在钥匙串中,并用作自动填充

问题描述 投票:0回答:1

我正在尝试实现类似,当用户已经拥有其帐户时。当他们尝试输入用户名和密码时,我需要显示底部弹出窗口来保存您的密码,例如网站在登录野生动物园时要求保存我们的凭据。因此,如果用户点击保存,则将其保存在钥匙串中。

下一次当用户点击用户名或密码时,将自动为用户提供凭据并选择其凭据。

我的代码:

   let server = "www.workBro.com"
    let userName = userNameTF.text
    let passWrd = passwordTF.text

    let password = passWrd?.data(using: String.Encoding.utf8)
    var query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
                                kSecAttrAccount as String: userName,
                                kSecAttrServer as String: self.server,
                                kSecValueData as String: password]
    let status = SecItemAdd(query as CFDictionary, nil)
    if status == errSecSuccess {
        print("success")
    } else {
        print("fail")
    }

我的凭据得到保存,我获得了成功。但是它会要求我保存您的密码提示警报,就像我们在其他网站上使用移动Safari登录时得到的提示一样。

我想念什么吗?

ios swift iphone xcode autofill
1个回答
0
投票

完整的指南在文章iOS 12 Password Tools: Improving User Security and Experience中:

1-从Apple开发人员门户网站获取您的应用程序的标识符

2-在您的应用程序和Apple开发人员门户上,您必须启用自动填充兼容性

在Web应用程序“ Web服务器” Supporting Associated Domains in Your App 中的3-Add apple-app-site-association

通过应用程序功能的4-启用关联域

5文本字段内容类型在属性检查器中必须是用户名和密码

© www.soinside.com 2019 - 2024. All rights reserved.