How to get Password AutoFill to work with ASWebAuthenticationSession?


I have a sample HTML form that follows the password auto-fill requirements. When navigating to the web page without the app, using the built-in Safari app, the native Password AutoFill dialogs for the login and signup forms correctly show:

enter image description here

However, when viewed within the app, the same flow does not trigger the dialog in neither the login or signup submission. It simply dismisses the login/signup screen without any error.

This is how my view controller looks like:

class ViewController: UIViewController {

    @IBAction func didTapLoginButton() {
        let session = ASWebAuthenticationSession(
            url: URL(string: "")!,
            callbackURLScheme: "customscheme") {
                print($0, $1)

        session.prefersEphemeralWebBrowserSession = true
        session.presentationContextProvider = self

extension ViewController: ASWebAuthenticationPresentationContextProviding {

    func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {

Is there a way to make the Password AutoFill to work with the mobile app via ASWebAuthenticationSession? I also tried SFSafariViewController but same issue. I have a sample iOS app here. Any help or experience is greatly appreciated!

Source: Ios

Categorized as aswebauthenticationsession, autofill, ios, swift


did you manage to solve the problem ?


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

Make sure the app is associated with your domain ( in your code). This will allow iCloud Keychain to identify the login form and suggest any stored credentials for that domain.

  1. Associate your app with the domain, as described here.
  2. Add the html tags to your login form, as described here.
  3. Make sure the user is properly authenticated on the iOS device before launching the ASWebAuthenticationSession.

Prof. Lina Hahn

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us