如何让密码自动填充与 ASWebAuthenticationSession 一起使用?

How to get Password AutoFill to work with ASWebAuthenticationSession?

我在 password auto-fill requirements 之后有一个示例 HTML 表格。在没有应用程序的情况下导航到网页时,使用内置的 Safari 应用程序,登录和注册表单的本机密码自动填充对话框正确显示:

但是,当在应用程序中查看时,相同的流程不会在登录或注册提交中触发对话框。它只是简单地关闭 login/signup 屏幕,没有任何错误。

这是我的视图控制器的样子:

class ViewController: UIViewController {

    @IBAction func didTapLoginButton() {
        let session = ASWebAuthenticationSession(
            url: URL(string: "https://example.com/login.html")!,
            callbackURLScheme: "customscheme") {
                print([=10=], )
        }

        session.prefersEphemeralWebBrowserSession = true
        session.presentationContextProvider = self
        session.start()
    }
}

extension ViewController: ASWebAuthenticationPresentationContextProviding {

    func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
        view.window!
    }
}

有没有办法通过 ASWebAuthenticationSession 使密码自动填充与移动应用程序一起使用?我也试过 SFSafariViewController 但同样的问题。我有一个sample iOS app here。非常感谢任何帮助或经验!

来自docs

Password AutoFill recommends credentials only for your app’s associated domain, and the user must authenticate using Face ID or Touch ID before accessing these credentials.

确保该应用与您的域相关联(代码中的example.com)。这将允许 iCloud Keychain 识别登录表单并建议为该域存储的任何凭据。

  1. 将您的应用与域相关联,如所述here
  2. html 标签添加到您的登录表单,如 here 所述。
  3. 确保用户在启动 ASWebAuthenticationSession 之前在 iOS 设备上正确验证。

经过长时间的研究,我找到的唯一有效且干净的解决方案是 按照建议 here 添加 post 登录页面。这样就不会关闭保存凭据提示。

不幸的是,我没有从 iOS 方面找到任何解决方案,非常感谢,因为在我的情况下,由于项目限制,我无法更改服务器端。