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

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

问题描述

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

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.

我错过了什么吗?

推荐答案

完整指南位于文章 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应用程序"Web服务器"中添加apple-app-site-association 支持 应用中的关联域

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

4-启用关联域

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

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

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

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