首页 > 代码库 > 用来辨别设备所使用网络的运营商

用来辨别设备所使用网络的运营商

- (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 isEqual: @""]) {

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 = @"电信";;

}

NSLog(@"%@",ret);

return ret;

}

用来辨别设备所使用网络的运营商