简体   繁体   English

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

[英]save username and password in key chain and use that as autofill

I am trying to achieve like, when user already have their account.当用户已经拥有他们的帐户时,我正在尝试实现类似的目标。 When they try to enter username and password i need to show the bottom popup to save your password like website ask to save our credentials when we logging in safari.当他们尝试输入用户名和密码时,我需要显示底部弹出窗口以保存您的密码,例如当我们登录 safari 时网站要求保存我们的凭据。 So if user tap on save let it save in key chain.所以如果用户点击保存让它保存在钥匙串中。

And next time when user tap of user name or password an autofill credentials will be given to user and select their credentials.下次当用户点击用户名或密码时,自动填充凭据将提供给用户和 select 他们的凭据。

my code:我的代码:

   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")
    }

My credentials got saved i got success.我的凭据被保存了,我成功了。 But it din ask for shall i save your password promt alert like what we get when we use mobile safari login with other sites.但它要求我保存您的密码提示警报,就像我们使用移动 safari 登录其他网站时得到的一样。

Am i missing anything?我错过了什么吗?

the complete guide is in the article iOS 12 Password Tools: Improving User Security and Experience :完整指南在文章iOS 12 密码工具:提高用户安全性和体验中:

1-get your App's Identifiers from Apple developer Portal 1-从 Apple 开发者门户获取您的应用程序标识符

2-on your app and Apple developer portal, you have to enable Autofill compatibility 2-在您的应用程序和 Apple 开发者门户上,您必须启用自动填充兼容性

3-Add apple-app-site-association in the Web App "Web Server" Supporting Associated Domains in Your App 3-在Web App“Web Server”中添加apple-app-site-association, 在您的App中支持关联域

4- on your App's Capabilities enable Associated Domains 4-在您的应用程序功能上启用关联域

5-text field content types must be Username and Password in the attribute inspector 5 文本字段内容类型必须是属性检查器中的用户名和密码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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