-2

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

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102

2 Answers2

1

Try adding

#import "Reachability.h"

(and make sure you have Reachability.m and Reachability.h in your project!)

deanWombourne
  • 38,189
  • 13
  • 98
  • 110
0

Downloaded Reachability and add drag them into your project, and select the targets you want to include them in.

Reachability Sample Code

bandejapaisa
  • 26,576
  • 13
  • 94
  • 112