Got a weird bug here. This only manifests when the iOS Device is being used exclusively on 3G/4G networks. i.e. if over WiFi - no bug and it all works fine.
- ( BOOL ) isInternetAccessAvailable
{
CFNetDiagnosticRef diag;
diag = CFNetDiagnosticCreateWithURL ( NULL, ( __bridge CFURLRef )[NSURL URLWithString:@"www.apple.com"] );
CFNetDiagnosticStatus status;
status = CFNetDiagnosticCopyNetworkStatusPassively ( diag, NULL );
CFRelease ( diag );
if ( status == kCFNetDiagnosticConnectionUp )
{
return YES;
}
else
{
NSString * title = @"No Internet Connection";
NSString * message = @"Please ensure you have an Internet Connection.";
[self showAlertWithTitle:title andMessage:message];
return NO;
}
}
Okay, so I have the above method that gets called before I try and load data into a UIWebView.
As I said - over a WiFi network, this works perfectly.
If WiFi is turned off (or unavailable / not connected) and the device is using a SIM for 3G/4G networks.
the line where is calls:
status = CFNetDiagnosticCopyNetworkStatusPassively ( diag, NULL );
returns a long equivalent to:
kCFNetDiagnosticConnectionDown
So therefore my test fails and I display a warning UIAlertView to the user.
But the network is there! If I change the test line to this:
if ( ( status == kCFNetDiagnosticConnectionUp ) || ( status == kCFNetDiagnosticConnectionDown ) )
It works over 3G/4G and downloads the web page - so the device or network isn't at fault.
But the call to CFNetDiagnosticCopyNetworkStatusPassively
is failing only on 3G/4G.
Any ideas?
This has just been found in an app I recently expedited into the App Store to meet advertising and merchandising deadlines and if there is a fault in my code - I need this fixed and resubmitted asap.
Confirmed bug by Apple.
Dupe if you want: Bug ID# 12443370