When using the old UIWebView you could catch the requests by implementing a custom NSURLProtocol. I us this to handle requests that requires authentication.
I tried the same code and it doesn't work with the new WKWebView but my protocol class isn't called at all. Is someone experiencing the same problem or is there a better way of doing authentication with the WKWebView?
Without any modifications I get a 401 response in the decidePolicyForNavigationResponse delegate function. I've also tried connection to the server with a NSURLConnection and handling the authentication with a NSURLConnectionDataDelegate. That works but the stored credentials isn't picked up by the WKWebView.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…