简体   繁体   中英

Detect whether iPad supports sim card programmatically

Currently, I have an app that shows the 3G data / Wifi used by the user since the last reboot. What I want to do is, if the app is running on an iPad which doesn't support SIM card, I want to hide certain statistics shown to the user.

Is it somehow possible to detect whether the current iOS device supports a sim card or not?

As far as I know, you cannot detect if the SIM card is installed. You can only determine if a WWAN connection is available using Reachability or you can use CTCarrier

@import CoreTelephony;

-(BOOL)hasCellularCoverage
{
    CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new];
    CTCarrier *carrier = [networkInfo subscriberCellularProvider];


    if (!carrier.isoCountryCode) {
        NSLog(@"No sim present Or No cellular coverage or phone is on airplane mode.");
        return NO;
    }
    return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM