Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Know if iOS device has cellular data capabilities

People also ask

How do I know if my iPhone has cellular?

If iPhone is connected to the internet using the cellular data network, an icon identifying the cellular network appears in the status bar. 5G, LTE, 4G, and 3G service on GSM cellular networks support simultaneous voice and data communications.

How do I know if my iPad is capable of cellular?

You can quickly tell if your iPad is capable of mobile connectivity by looking for the SIM card slot on the side. If you see one then it's a Wi-Fi + cellular model. If not, then it's Wi-Fi-only.

How do I know if my iPhone is using Wi-Fi or cellular?

Look for the WiFi symbol in the upper left of the screen. Turn off cellular data. If you are able to connect to the Internet then you are using WiFi (unless you are tethered to a hotspot by Bluetooth or USB). Also you will see the WiFi symbol at the top of the screen.


Hi you should be able to check if it has the pdp_ip0 interface

#import <ifaddrs.h>

- (bool) hasCellular {
    struct ifaddrs * addrs;
    const struct ifaddrs * cursor;
    bool found = false;
    if (getifaddrs(&addrs) == 0) {
        cursor = addrs;
        while (cursor != NULL) {
            NSString *name = [NSString stringWithUTF8String:cursor->ifa_name];
            if ([name isEqualToString:@"pdp_ip0"]) {
                found = true;
                break;
            }
            cursor = cursor->ifa_next;
        }
        freeifaddrs(addrs);
    }
    return found;
}

This doesn't use any private APIs.


3G by itself seems tough to find. You can find out whether a device can make calls using [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]. You can check whether a device can get to the internet, period (and by which method that can currently happen) using Reachability code:

NetworkStatus currentStatus = [[Reachability reachabilityForInternetConnection] 
                               currentReachabilityStatus];

if(currentStatus == kReachableViaWWAN) // 3G

else if(currentStatus == kReachableViaWifi) // ...wifi

else if(currentStatus == kNotReachable) // no connection currently possible

..but aside from that, I don't think you can check for the existence of a 3G modem in the device.***** If it can't make a call, and doesn't currently have cell data turned on and wifi turned off, you won't be able to find out if it's 3G-capable.

An alternative way (not forward-compatible though, so you probably don't want to do this) is to compare the device's model with an exhaustive list, knowing which ones have 3G modems in them, as shown here.

***** As per bentech's answer, if you want to go digging around with device names (this may stop working with no advance warning if Apple decide to change the 3g interface name), call getifaddrs and check for the pdp_ip0 interface.


Swift 3.0 (UIDevice+Extension) of @bentech's answer

Add this line to your BridgingHeader.h:

#import <ifaddrs.h>

Somewhere else:

extension UIDevice {
    /// A Boolean value indicating whether the device has cellular data capabilities (true) or not (false).
    var hasCellularCapabilites: Bool {
        var addrs: UnsafeMutablePointer<ifaddrs>?
        var cursor: UnsafeMutablePointer<ifaddrs>?

        defer { freeifaddrs(addrs) }

        guard getifaddrs(&addrs) == 0 else { return false }
        cursor = addrs

        while cursor != nil {
            guard
                let utf8String = cursor?.pointee.ifa_name,
                let name = NSString(utf8String: utf8String),
                name == "pdp_ip0"
                else {
                    cursor = cursor?.pointee.ifa_next
                    continue
            }
            return true
        }
        return false
    }
}

In iOS 6.1, I've been able to use Core Telephony to successfully check for the presence of cellular baseband capabilities. This works on all iPads I tested: Verizon with service activated and without, AT&T with service currently deactivated, SIM card in and out, and a Wi-Fi-only iPad.

The code I used looks like this:

CTTelephonyNetworkInfo* ctInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* carrier = ctInfo.subscriberCellularProvider;
self.hasWWANCapability = carrier != nil;

For all the iPads with cellular baseband hardware, carrier is not nil. For the Wi-Fi-only iPad, carrier is nil.


I'd think you should be able to use the CoreTelephony Framework.

It does call out that it is for carriers to use, so I am not sure if it is against TOS to access it.

Carriers can use this information to write applications that provide services only for their own subscribers


One way of doing it is to ask for the users location. When it is as accurate as possibLe, you will know if the device have GPS. All devices that have GPS will have 3G. And those that don't GPS won't have 3G.