密码自动填充
Version - - iOS 11.0
- 简化登陆流程
- 保存密码,用户不用记住密码
一、实现原理
- 将用户的登陆凭证保存在 iOS 设备上
- iOS 通过 iCould 钥匙串在用户设备上同步这些凭证到相关的域名(与应用程序绑定)
- App 推荐相关域名对应的凭证,在访问凭证之前,用户必须使用 Face ID 和 Touch ID 进行验证
二、实现步骤
-
设置 textfield 的 contentType (iOS 11 新增了 .username 和 .password)
userTextField.textContentType = .username
passwordTextField.textContentType = .password
- 当 username tf 和 password tf 处于不同屏幕或者视图时,依旧可以使用该特性
- contentType 和 keyboardType 可联合使用 : UITextContentType.password 和 UIKeyboardType.emailAddress
• Make the QuickType bar appear, 确保有 password 保存在凭证中才会显示 🔑

在 Setting -> Accounts & Passwords 中可查看已保存的密码,记得打开自动填充密码开关

三、Support Third-Party Web Services
在 Safari view controller 中添加 Password AutoFill,使用 ASWebAuthenticationSession
网友评论