I'm trying to figure out how best to determine if a page is available in iOS. I've got a WKWebView that can see URL Request codes, which works fine for 404, 500, etc. However I'm not sure how to handle requests to a URL when the intended URL's server may be down. My WKWebView start navigation delegate method fires, and then nothing. My web request just seems to disappear.
Chrome for example returns a message saying "This site can’t be reached chess.math.science.google.com’s server IP address could not be found."
I've included the iOS Reachability class in my didStartProvisionalNavigation
delegate method and that is saying the URL should be reachable via WIFI, which while not incorrect, does not check if the URL has anything to return.
App Log:
2018-03-23 16:28:54.142105-0400 MyApp[1245:774884] INTERNET REACHABLE
2018-03-23 16:28:54.272582-0400 MyApp[1245:774884] WKWEBVIEW DID START NAVIGATION
2018-03-23 16:28:54.274085-0400 MyApp[1245:774884] NETWORK STATUS FOR URL chess.math.science.google.com: 2
(lldb) po netStatus
ReachableViaWiFi
Code:
-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
NSLog(@"WKWEBVIEW DID START NAVIGATION");
Reachability* tinyReach = [Reachability reachabilityWithHostname:webView.URL.absoluteString];
NetworkStatus netStatus = [tinyReach currentReachabilityStatus];
NSLog(@"NETWORK STATUS FOR URL %@: %li", webView.URL.absoluteString, netStatus);
if(netStatus == NotReachable) {
NSLog(@"NOT REACHABLE");