如何拦截 ios WKWebView 上的所有 http(s) 请求?

How to intercept all http(s) requests on ios WKWebView?

我有一个 Android 应用程序,它严重依赖 WebView 上的 shouldIntercept 移植到 iOS,最好使用 WKWebView。有没有办法为所有 http 和 https 调用实现类似于 shouldIntercept 的东西?

编辑:android webview 将允许我拦截所有资源、图像、视频、html、Javascript 等。在 [=23 上有什么方法可以做到这一点吗? =]?

看看 this github repository 称为 WKWebViewWithURLProtocol Casolorz。该库使您能够使用 NSURLProtocol 通过方法调配来拦截您的网络请求。