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 thi开发者_运维知识库s 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
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)
精彩评论