Search code examples
objective-cios3greachability

Reachability airplane mode (3G) vs. Wifi


I know the Reachability code will provide if the phone has access to Wifi or 3G network.

However, if the phone has 3G on and Wifi, the Reachability code defaults to saying the phone has Wifi on and I can't detect if 3G network is enabled or not (airplane mode on or off).

I need to find out specifically if 3G mode is on or off when Wifi is also on.

Here is the code:

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

NetworkStatus status = [reachability currentReachabilityStatus];

NSLog(@"status: %u", status);

if(status == NotReachable)  //status = 0
{
    //No internet
    NSLog(@"nothing is reachable");
}
if (status == ReachableViaWiFi) //status = 1
{
    //WiFi
    NSLog(@"Wifi is available");
}
if (status == ReachableViaWWAN) //status = 2
{
    //3G
    NSLog(@"3G is available");
}
NSLog(@"%@", s);

Basically status is returning 1 even if the 3G is on as well as Wifi.

Is this possible?


Solution

  • Currently there is no way to do this on the iPhone following Apple guidelines and without using their private API.