How to check if wifi option is enabled on the iPhone or not (but maybe iPhone not connected to one of the wifi net).
For this you need to import reachability classes in your project.
After then:-
#import "Reachability.h"
In you view DidLoad write:-
- (void)viewDidLoad {
Reachability *internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifer];
Reachability *wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
[wifiReach startNotifer];
NetworkStatus netStatus1 = [internetReach currentReachabilityStatus];
NetworkStatus netStatus2 = [wifiReach currentReachabilityStatus];
if(netStatus1 == NotReachable && netStatus2 == NotReachable)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"This feature requires an internet connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
else
{//wifi connection available;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With