I would like check the device WiFi connection availability while my application starts.
So I have added SystemConfiguration.framework
.
Code:
#import <CoreLocation/CoreLocation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <SystemConfiguration/SCNetworkReachability.h>
- (BOOL)networkCheck{
Reachability *wifiReach = [Reachability reachabilityForInternetConnection];
NetworkStatus netStatus = [wifiReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{
NSLog(@"NETWORKCHECK: Not Connected");
return false;
break;
}
case ReachableViaWWAN:
{
NSLog(@"NETWORKCHECK: Connected Via WWAN");
return false;
break;
}
case ReachableViaWiFi:
{
NSLog(@"NETWORKCHECK: Connected Via WiFi");
return true;
break;
}
}
return false;
}
Errors:
Reachability was not declared in this scope
NetworkStatus was not declared in this scope
netStatus was not declared in this scope \ NotReachable was not declared in this scope
ReachableViaWWAN was not declared in this scope