WKWebView password autofill

Hi,

We've been using the WKWebView for authentication and authorization purposes inside our app.

Unfortunately, we are not able to enable the password autofill/keychain integration with WKWebView.

The website is working correctly (we can see the suggested passwords and the key for the password list)whenever we are opening it using Safari, but when we are trying to open it inside our app using the WKWebView there is only default toolbar ( with arrows and done button).

Is there a possibility to enable autofill using some javascript scripts or WKWebViewConfiguration in WKWebView or is this behaviour is reserved only for SFSafariViewController and Safari?

Post not yet marked as solved Up vote post of mikoy92 Down vote post of mikoy92
7.8k views
  • Well, I would like to track and see if Apple ever addresses this issue. I'm seeing the same thing where the password can be set and used within my app but the app will never get the save password dialogue to fire off. (This will let me monitor this thread for any updates)

    Doug

  • Also waiting for responses.

Add a Comment

Replies

Having exact same issue. Please help

This is working (partially) for us once Domain Entitlement is set-up. Password autofill/keychain will recognize the domain of the wkWebView that is associated with the App to deliver autofill/keychian/3rdParty password fills to properly attributed input fields (autocomplete="current-password" etc.)

This only seems to work for autofill, and NOT for password saving. For whatever reason, the Save Password dialogue from iOS is not firing to save your credentials from wkWebView as it does in Safari. There seems to be no documentation from Apple on this. So, for a user to leverage saved passwords for an App with wkWebView, a user would have to sign in to the same domain via Safari, save their credentials, then open the App wkWebView and populate the fields. Again, there seems to be no way to save credentials from wkWebView even with domain entitlement enabled. Again, this is only apparent from attempts with POC builds. There still may be a way, and it would be great if Apple could respond to this question.

ArcadianZ or anyone else, any luck on password saving? I also have the same issue too. Would you also recommend other webview types that can handle password saving?

This only seems to work for autofill, and NOT for password saving. For whatever reason, the Save Password dialogue from iOS is not firing to save your credentials from wkWebView as it does in Safari.

We're encountering the exact same issue. Will report back if I find anything

  • Still no updates to date. What is frustrating is that there is no acknowledgement or documentation from apple regarding wkwebview supported features that cover this.

Add a Comment

Having the same issue here. Weird thing is that also, autoComplete is not working. This is our apple-app-site-association:

  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "APP_ID",
        "paths": [
          "*"
        ]
      }
    ]
  },
  "webcredentials": {
    "apps": [
      "APP_ID.BUNDLE_ID"
    ]
  }
}

Password AutoFill is the most frustrating concept/feature I have been working on in my many years as an app developer. It's a black box full of "magic" (or "heuristics" as Apple calls it) and the documentation is "theoretical".

ASWebAuthenticationSession didn't help, so my workaround (hack) is to intercept credentials in webView(_:decidePolicyFor:decisionHandler:) on WKNavigationType.formSubmitted navigation type. I put the username and password in native UITextFields that is "hidden". Sidenote: This is against all security best practices. The textContentType needs to be set accordingly and the order the UITextFields are added to the parent view is super important, constraints does not seem to matter. Currently this works great on local debug builds, but for some reason doesn't on in-house/enterprise builds. The device console does not show anything helpful other that the com.apple.developer.associated-domains -> webcredentials for the domain was approved.

Testing against a local webserver also does not work, which makes the trail'n'error approach needed to make this feature work even harder. You are suppose to add ?mode=developer to your webcredentials:example.com in your Associated Domains Entitlement setup. You also need to build using a dev profile + enable Associated Domains Development under iOS Settings -> Developer -> Universal Links. All to no avail.