Search code examples
htmliosswifthrefwkwebview

is there no way to catch "Received an unexpected URL from the web process:"


I'm attempting to rewrite an objective-c app using a UIWebViewsin Swift using a WKWebView. The application displays a lot of local content. While I can display the initial webpage in WKWebView with no problem. When I click on a link that points to more local content I get the following error:

Received an unexpected URL from the web process: "..."

The content uses a nonstandard href to identify the local content. Using the UIWebView shouldStartLoadWithRequest api I was able to intercept this clicked linked and rewrite the href in a way that I could load the appropriate local content.

So far I haven't been able to identify anything in WKWebView that would allow me to accomplish the same thing. I'm consuming this content, not creating it so I don't have the option of changing the format of the href.

I've tried:

decidePolicyFor navigationResponse decidePolicyFor navigationAction didFail navigation didFailProvisionalNavigation navigation didStartProvisionalNavigation navigation

I tried adding a custom URLSchemeHandler... nothing allowed me to intercept the link.

Instead in the console I get errors:

Received an unexpected URL from the web process: Received an invalid message "WebPageProxy.DecidePolicyForNavigationAction" from the web process. Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

It DO get decideActionPolicyFor:

Am I missing something? Any help would be greatly appreciated!

Morgan Jones


Solution

  • Yes there is way,use this function

    func webViewWebContentProcessDidTerminate(WKWebView){}
    

    for catching the error and you can either navigate back or reload the webview.