将用户名和密码保存在钥匙串中并将其用作自动填充 [英] save username and password in key chain and use that as autofill

查看:37
本文介绍了将用户名和密码保存在钥匙串中并将其用作自动填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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. 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.

我的代码:

   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 登录时得到的一样.

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.

我错过了什么吗?

推荐答案

完整指南在文章 iOS 12 密码工具:提高用户安全性和体验:

1-从 Apple 开发者门户获取您的应用标识符

1-get your App’s Identifiers from Apple developer Portal

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

2-on your app and Apple developer portal, you have to enable Autofill compatibility

3-在Web AppWeb Server"中添加apple-app-site-association 支持应用程序中的关联域

3-Add apple-app-site-association in the Web App "Web Server" Supporting Associated Domains in Your App

4- 在您的应用程序的功能上启用关联域

4- on your App's Capabilities enable Associated Domains

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

5-text field content types must be Username and Password in the attribute inspector

这篇关于将用户名和密码保存在钥匙串中并将其用作自动填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆