iphone 通过获取IMSI判断运营商

IMSI 共有 15 位,其结构如下:

   MCC+MNC+MSIN ,( MNC+MSIN=NMSI

   MCCMobile Country Code ,移动国家码, MCC 的资源由国际电联( ITU )统一分配和管理,唯一识别移动用户所属的国家,共 3 位,中国为 460;

   MNC:Mobile Network Code ,移动网络码,共 2 位,中国移动 TD 系统使用 00 ,中国联通 GSM 系统使用 01 ,中国移动 GSM 系统使用 02 ,中国电信 CDMA 系统使用 03 ,一个典型的 IMSI 号码为 460030912121001;

   MSIN:Mobile Subscriber Identification Number 共有 10 位,其结构如下:

   09+M0M1M2M3+ABCD

其中的 M0M1M2M3MDN 号码中的 H0H1H2H3 可存在对应关系, ABCD 四位为自由分配。

这样就可以依据 IMSI 中的 MCCMNC 来确定运营商了。当然知道编码规则同时还是需要知道对应编码的的国家和网络了。

实现的代码如下:

/* China - CN
* MCC MNC Brand Operator Status Bands (MHz) References and notes
* 460 00 China Mobile Operational GSM 900/GSM 1800 UMTS (TD-SCDMA) 1880/2010
* 460 01 China Unicom Operational GSM 900/GSM 1800/ UMTS 2100 CDMA network sold to China Telecom, WCDMA commercial trial started in May 2009 and in full commercial operation as of October 2009.
* 460 02 China Mobile Operational GSM 900/GSM 1800/ UMTS (TD-SCDMA) 1880/2010
* 460 03 China Telecom Operational CDMA 800/cdma evdo 2100
* 460 05 China Telecom Operational
* 460 06 China Unicom Operational GSM 900/GSM 1800/UMTS 2100
* 460 07 China Mobile Operational GSM 900/GSM 1800/UMTS (TD-SCDMA) 1880/2010
* 460 20 China Tietong Operational GSM-R
* NA NA China Telecom&China Unicom Operational
*/
+ (NSString*)getCarrier:(NSString*)imsi
{
if (imsi == nil || [imsi isEqualToString:@"SIM Not Inserted"] ) {
return @"Unknown";
}
else {
if ([[imsi substringWithRange:NSMakeRange(0, 3)] isEqualToString:@"460"]) {
NSInteger MNC = [[imsi substringWithRange:NSMakeRange(3, 2)] intValue];
switch (MNC) {
case 00:
case 02:
case 07:
return @"China Mobile";
break;
case 01:
case 06:
return @"China Unicom";
break;
case 03:
case 05:
return @"China Telecom";
break;
case 20:
return @"China Tietong";
break;
default:
break;
}
}
}
return @"Unknown";
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值