iOS 判断设备是否安装SIM卡
2016-03-25 本文已影响1110人
devchena
首先,导入头文件:
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
添加方法:
// 判断设备是否安装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