1

My requirement is to redirecting the HTTPS request to HTTP from WKWebView.

But the request initiated inside the webview(Ajax call) are not being captured.

After that, the requests being made from that webpage are not captured.

Please share your ideas. Much appreciated.

jailani
  • 2,260
  • 2
  • 21
  • 45
  • 1
    For the one who marked as close: I don't know y can't you understand my question...If you can't please let the others answer. – jailani Jan 15 '18 at 14:50

2 Answers2

0

You would need to implement a WebPolicyDelegate with a decidePolicyForNavigationAction and then load the page yourself without https. This should work, but I haven't tested it.

Have a look at this post for some insides, on UIWebView it would have worked with shouldStartLoadWithRequest:

Migrating from UIWebView to WKWebView

user2782993
  • 183
  • 11
  • Those methods and all being called. My question is different. – jailani Jan 15 '18 at 14:48
  • Did not know that the call is from within a javascript ajax call... mmhh. This could be tricky, if not impossible without parsing the executed javascript, if those request are not reported using the 'decidePolicyForNavigationAction' callback... – user2782993 Jan 15 '18 at 18:07
0

Use the following steps for UIWevView to load a remote address

  1. Load the url address

let urlString = "http://www.example.com" webView.loadRequest(NSURLRequest(url: NSURL(string:"url) as! URL) as URLRequest)

  1. Conform UIWebViewDelegate in ViewController
  2. After conforming UIWebViewDelegate, use the following delegates

    /* Delegates for WebView */ fun webViewDidStartLoad(_ webView: UIWebView){ // Control loading the url } func webViewDidFinishLoad(_ webView: UIWebView){ // statements when loading finishes } fun webView(_ webView: UIWebView, didFailLoadWithError error: Error){ // Handle error here }

  3. If still does not work, add a row for "App Transport Security Settings" in your project Info.plist. Here is screenshot for it settings.

enter image description here

KGen
  • 50
  • 3