iOS 判断设备是否安装SIM卡

首先,导入头文件:

#import 
#import 

添加方法:

// 判断设备是否安装sim卡
+ (BOOL)isSIMInstalled
{
    CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
    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;
}

参考文章:http://stackoverflow.com/questions/10488898/iphone-detecting-sim-card-availability

你可能感兴趣的:(iOS 判断设备是否安装SIM卡)