Internet Reachability Check in iOS Objective C

How to check Internet Reachability and name of Wifi network.

It has always been a required feature to  check weather the device is connected to internet or not. Everyone of us look for internet connection first whenever we find delay in getting response in an application. In this blog we will learn how to check for Internet Connection and also get the name of WIFI network to which your IOS device is currently Connected.

Lets Start

Open Xcode and Create a single View Application, save it and named it Like “Reachability Demo”.

Screen Shot 2016-03-15 at 12.12.23 PM

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.

Screen Shot 2016-03-15 at 12.42.17 PM

Import framework in your controller

In your view controller.m class import the system framework and Reachability.h class.

Screen Shot 2016-03-15 at 2.57.27 PM

 

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.

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.

Run application

Run your application on device and in application console check what network name your device is connected with.

 

Hope it was an easy post on Internet Reachability Check in iOS Objective C and to get WIFI network name. I’l be back in my next blog with something very interesting, till then happy coding ;).

 

 

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.