How to monitor and block ajax requests in WKWebView?

Viewed 1223

From my understanding and trying out some code, we can only monitor page navigation requests using

func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void)
{
    if // some condition
    {
        decisionHandler(.allow) // to allow the page navigation.
    }
    else
    {
        decisionHandler(.cancel) // to cancel the page navigation.
    }
}

But is there any way to monitor and block some ajax requests in WKWebView?

And also to capture the ajax response.

0 Answers
Related