Detect ios wkwebview resource load failure

Viewed 250

I have a url which loads an html file, which in turn loads one more resource (a javascript file) via its script tag. I am loading this url in WKWebView on iOS.

If internet is good, then webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) is called after html and javascript file both are downloaded. Then i show a popup to user that url loaded successfully.

If internet gets interrupted before javascript file gets downloaded completely, then also webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) is called immediately. Now how should i detect that url hasn't loaded completely, so that i can show to user in a popup that he is having bad internet.

I tried to use didFailProvisionalNavigation and didFail navigation , but they don't get called, rather didFinish navigation is called.

0 Answers
Related