views:

58

answers:

1

I am using this code...

Reachability *r = [Reachability reachabilityWithHostName:@"www.maxqdata.com"];

NetworkStatus internetStatus = [r currentReachabilityStatus];

if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
{
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"You require an internet connection via WiFi or cellular network for location finding to work." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[myAlert show];
[myAlert release];
} 

from this thread

http://www.iphonedevsdk.com/forum/iphone-sdk-development/19546-no-wifi-connection-best-practice-2.html#post118631

to check for internet connections. Whilst this is working in principle I am getting a false positive in the situation when a cellular network is available but can't be activated, does anyone have any ideas on how to detect for this scenario?

Alternatively this is likely to happen so rarely I can always just ignore it and give an error when the NSURLConnection method can't connect - my worry here is that it may not get past the vetting process, does anyone have any experience with this?

Thanks

A: 

The only "reachability" code I've included in some of my apps is to display an error if connections time out - as long as you handle intermittent or no connectivity gracefully it will get past vetting. Crashing out, or hanging waiting for a response forever will get you rejected. As a rule of thumb, I'd say anything the user will find acceptable, I've found Apple do too *.

(* your mileage may vary)

Andiih
Thanks for the response. How would I simulate a connection timeout? I want to test that I get an error in this instance...
Either set up a URL that returns no response (real timeout), change your URL to something with no DNS (instant no response), or run in the simulator and do a well timed yank of the network cable. I've also been seen with my phone in a biscuit tin before now...
Andiih
He he thanks, I'm off to eat some biscuits....