1

I'm doing a simple mobile application which embeds a WkWebView to display my website using Ionic 6 + Angular.

I have tested my website with Chrome and Safari on Macbook, everything was fine until I opened it on my WKWebView control.

At first, my webview displayed successfully (as the below image)

enter image description here

When I clicked Submit button, my Ionic 6 website would call an API Endpoint & continued download some chunks and go to the next page.

However, this is what I got after Submit button has been clicked:

enter image description here

The error message was:

[Error] ERROR
Object

info: {meta: null, lastValue: null, seen: 0}

message: "Timeout has occurred"

name: "TimeoutError"

stack: "@http://****/main.02dd4c6bece51f6f.js:1:175858↵@http://****/main.02dd4c6bece51f6f.js:1:43982…"


This is how I setup my webview:

 func setupWebView() {
        let url = URL(string: "http://<my-end-point>/")!
        let request: URLRequest = URLRequest(url: url, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 180)
        webView.load(request)
    
        webView.allowsBackForwardNavigationGestures = true
        webView.configuration.userContentController.add(self, name: listenerName)
    }

My question is:

  • Can I increase the timeout of WKWebView to by pass this issue ?
  • I haven't deployed my app onto physical device, is it an issue of simulator only ? or it is physical device issue also ?
Redplane
  • 2,971
  • 4
  • 30
  • 59
  • This might be unrelated to WKWebView entirely. Did you check if your website works correctly in the simulator's Safari browser? – Eugen Timm Apr 19 '22 at 09:22
  • You should be using `https` for your requests. `http` is not secure and by default iOS blocks insecure network requests. You may want to look into your App Transport Security settings. You may find this link helpful https://stackoverflow.com/a/31254874/5508175 – Andrew Apr 19 '22 at 09:25
  • @EugenTimm, I have checked with safari, it worked, even with http or https :( – Redplane Apr 19 '22 at 15:35
  • @Andrew, I tried with https also. My website has been deployed to netlify.com. I use ngrok to use its https. Everything was https, the problem still persisted :( – Redplane Apr 19 '22 at 16:21
  • have you tried using a different url for a website that you know works? – Andrew Apr 19 '22 at 16:25

0 Answers0