1

Hi i need to find out whether iPhone internet connected 3G or 2G or WIFI network any suggestions

Thanks

Sravan

Vizllx
  • 9,135
  • 1
  • 41
  • 79
Sravan Goud
  • 197
  • 1
  • 3
  • 10
  • 1
    why vote down my question plz clarify my doubt...? – Sravan Goud Apr 22 '14 at 12:33
  • plz provide any sample code or any link it will be helpful for me... – Sravan Goud Apr 22 '14 at 12:52
  • Please refer Ben Groot's answer for this question http://stackoverflow.com/questions/11049660/detect-carrier-connection-type-3g-edge-gprs. And its **Core Telephony** framework not CFNetworking – Yogi Apr 22 '14 at 12:57

3 Answers3

8

Download Reachability Class for iOS from this link:- https://github.com/tonymillion/Reachability

1)Add Reachability.h &.m in your Project, make sure you make it ARC compatible by adding flag -fno-objc-arc

2)Now, check the connection type in your view controller

  Reachability *reachability = [Reachability reachabilityForInternetConnection];
    [reachability startNotifier];

    NetworkStatus status = [reachability currentReachabilityStatus];

    if(status == NotReachable) 
    {
        //No internet
    }
    else if (status == ReachableViaWiFi)
    {
        //WiFi
    }
    else if (status == ReachableViaWWAN) 
    {
        //3G
    }
Vizllx
  • 9,135
  • 1
  • 41
  • 79
  • thanks but i need to show alert when user login to my app ur connected via 3G or Wifi network and if internet connectivity not avalible then it's show alert please check ur network connection – Sravan Goud Apr 22 '14 at 12:50
2

You can use the Reachability library written by tonymillion. If you don't wan to use ARC, there is also the Apple Reachability library.

Sunder
  • 503
  • 1
  • 5
  • 17
1

Also take a look inside of < CoreTelephony/CTTelephonyNetworkInfo.h >

You will see that there is a currentRadioAccessTechnology property exposed on CTTelephonyNetworkInfo.

CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
NSLog(@"Radio access technology:\n%@",
       netInfo.currentRadioAccessTechnology);

You can subscribe to changes via:

[NSNotificationCenter.defaultCenter
    addObserverForName:CTRadioAccessTechnologyDidChangeNotification
                object:nil
                 queue:nil
            usingBlock:^(NSNotification __unused *notification) {
                CTTelephonyNetworkInfo *current =
                    [[CTTelephonyNetworkInfo alloc] init];
                NSLog(@"Updated Radio access technology:\n%@",
                       current.currentRadioAccessTechnology);
            }];
HughV
  • 86
  • 6