Reputation: 886
I have a requirement to identify, which connection is active (WiFi or Ethernet) in Iphone programmatically. If, user is using WiFi then I have to display different view controllers in my app.
Please help.
Upvotes: 1
Views: 946
Reputation: 49720
you can use apple provided Reachability class hear bellow example please check this sample code who provide by apple.
http://developer.apple.com/iphone/library/samplecode/Reachability/index.html
you can use it in your Project like bellow steps:-
included Apple's Reachability.h & .m from their Reachability example.
add the SystemConfiguration framework.
when u use it you just called Bellow method:-
Reachability* wifiReach = [[Reachability reachabilityWithHostName: @"www.apple.com"] retain];
NetworkStatus remoteHostStatus = [wifiReach currentReachabilityStatus];
switch (remoteHostStatus)
{
case NotReachable:
{
NSLog(@"Access Not Available");
break;
}
case ReachableViaWWAN:
{
NSLog(@"Reachable WWAN");
break;
}
case ReachableViaWiFi:
{
NSLog(@"Reachable WiFi");
break;
}
}
Upvotes: 4