获取iPhone手机SIM卡的运营商

2017-09-11  本文已影响0人  不懂代码的iOS

1.导入头文件

#import<CoreTelephony/CTTelephonyNetworkInfo.h>

#import<CoreTelephony/CTCarrier.h>

2.返回运营商的名称

+ (NSString*)checkCarrier{

NSString *ret = [[NSString alloc] init];

CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];

CTCarrier *carrier = [info subscriberCellularProvider];

if( carrier ==nil)

{

return(@"0");

}

NSString *code = [carrier mobileNetworkCode];

if([code isEqualToString:@""])

{

return(@"0");

}

if( [code isEqualToString:@"00"] || [code isEqualToString:@"02"] || [code isEqualToString:@"07"] )

{

ret =@"移动";

}

if( [code isEqualToString:@"01"] || [code isEqualToString:@"06"] )

{

ret =@"联通";

}

if( [code isEqualToString:@"03"] || [code isEqualToString:@"05"] )

{

ret =@"电信";;

}

return ret;

}

上一篇下一篇

猜你喜欢

热点阅读