Here’s a simple way to test if your iPhone application is connected using Wifi, 3G or Edge.
First go to the Developer documentation and search for “Reachability” (or here: Online Apple Doc: Reachability ): Apple provided this class to simplify the way to monitor the network of an iPhone or iPod Touch.
Open the project and copy these files to your project: Reachability.m and Reachability.h.
This class relies on the “SystemConfiguration” Framwork, so you need to add it to your project:
Now you can use the Reachability class somewhere in your code like that:
if([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == NotReachable) { UIAlertView *error = [[UIAlertView alloc] initWithTitle: @"No Internets??" message: @"Check your Wifi settings" delegate: self cancelButtonTitle: @"Ok, i'll do it" otherButtonTitles: nil]; [error show];
}
Of Course you can change the test to something else:
Simple!
[...] http://adylitica.com/2009/12/15/test-if-your-iphone-app-is-connected-to-internet/ [...]