Reputation: 388
I'm working on an iOS app using UIWebViews, and I'm running in to some interesting behavior.
I'm trying to load content from my website into an iOS app via a UIWebView, but I want to block certain calls made by the website (such as some of my analytics) to speed up the load within the WebView. If I connect the device to a proxy (I've been using Charles Proxy) I can see these requests going out, just as I would expect them to. However, for whatever reason,
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
Is not capturing the requests I'm looking for. In fact, webView:(UIWebView *)... is only firing on about a third of the calls that I see going out over the proxy.
Does anyone know why that might be? Or have any idea what I can do to intercept all of the calls made by a UIWebView?
Thank you
Upvotes: 0
Views: 163
Reputation: 57040
You will not get delegate calls for all requests from the web view (for example, resource requests, such as JavaScript and images).
To have a precise control over all requests, you will need to implement a NSURLProtocol
in which you can decide what request to allow and what to block.
Upvotes: 1