App中如何使得用戶注册登錄更加方便,除了支持第三方登錄外,還可以適配自动填充(iOS11以上)功能,使得賬號_密碼_驗證碼直接現在鍵盤QuickType bar上面,用戶點擊后直接填充在應用的賬號、密碼、验证码輸入框,免去了思考和手動輸入的阻碍。

Requirement

  • iOS 11+
  • 設置—密碼與賬戶—打開自動填充密碼

    textContentType

  • 使用原生控件UITextFieldUITextView,或者遵循UITextInput的控件,并且设置其textContentType为指定类别
1
2
3
4
self.accountTextField.textContentType = UITextContentTypeUsername;
self.passwordTextField.textContentType = UITextContentTypePassword;
self.onecodeTextField.textContentType = UITextContentTypeOneTimeCode;
self.newpasswordField.textContentType = UITextContentTypeNewPassword;//for Automatic Strong Passwords

Associated Domains

  • 开发者后台设置Associated Domains Enable
  • 记录Prefix和app的BundleID,生成名为apple-app-site-association的文件,放到关联域网站服务器的.well-known目录下面或者根目录下
1
2
3
4
5
{
"webcredentials":{
"apps":["Prefix.BundleID"]
}
}
  • 项目中设置 Target—Capabilities—Associated Domains 开启,且添加Domains: webcredentials:example.com —支持https的关联域网站域名

thanks for your reading~