iphone 通过获取IMSI判断运营商

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

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

  MCC:Mobile 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

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

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

 

 

实现的代码如下:

/* 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
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值