1. download from Here: https://drive.google.com/open?id=0BwU5Y4Xqfa42VTgxZURtQ1FyUlk
2. import systemContifiguration framework
2. import systemContifiguration framework
INTERNET REACHABILITY CHECK IN IOS OBJECTIVE C
Open Xcode and Create a single View Application, save it and named it Like “Reachability Demo”.
IMPORT SYSTEM CONFIGURATION FRAMEWORK AND REACHABILITY CLASS.
The Reachability class depends on the System Configuration framework for some of its functionality. With your project selected in the Project Navigator, open the Build Phases tab, and expand the Link Binary with Libraries drawer. Click the plus button and search for SystemConfiguration.framework and add it to your project.
To get the Reachability classes, Visit the project’s GitHub page, download the latest version, and drag Reachability.h/.m into your Xcode project (figure 3). If you take this path, make sure to copy the class files into your Xcode project (figure 4). You can also use CocoaPods to to add Reachability to your project.
IMPORT FRAMEWORK IN YOUR CONTROLLER
In your view controller.m class import the system framework and Reachability.h class.
1
2
|
#import <SystemConfiguration/CaptiveNetwork.h>
#import "Reachability.h"
|
CHECK INTERNET REACHABILITY
In your Viewdidload method add the following code to first check whether there is any internet connection available or not and also the type of connection your device is connected with.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];
if (networkStatus == NotReachable)
{
NSLog(@"Please check your network connection");
}
else
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];
NetworkStatus status = [reachability currentReachabilityStatus];
if(status == NotReachable)
{
//No internet
}
else if (status == ReachableViaWiFi)
{
//Connected to WiFi
}
else if (status == ReachableViaWWAN)
{
//Connected to 3G
}
}
|
Above code checks for the internet connection and if connection found then it shows wether the device is connected to wifi network or WWAN.
GET WIFI NETWORK NAME
To get wifi network name add the below given code in the part where it shows that device is connected to wifi. Please refer the below mentioned code and screenshot given.
1
2
3
4
5
6
|
CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
// NSLog(@"SSID: %@",CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID));
NSString *networkName = CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID);
NSLog(@"%@ show network name",networkName);
|
RUN APPLICATION
Run your application on device and in application console check what network name your device is connected with.
Sign up here with your email
ConversionConversion EmoticonEmoticon