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.