iphone 获取手机运营商信息

来源:互联网 发布:安徽11选五任3遗漏数据 编辑:程序博客网 时间:2024/04/30 12:09

获取手机运营商信息是通过获取imsi来判断的,它是有一个自己的标准和规则的,下面先介绍一下imsi:

IMSI:

      国际移动用户识别码(IMSI:International Mobile Subscriber Identification Number)是区别移动用户的标志,储存在SIM卡中,可用于区别移动用户的有效信息。其总长度不超过15位,同样使用0~9的数字。其中MCC是移动用户所属国家代号,占3位数字,中国的MCC规定为460;MNC是移动网号码,由两位或者三位数字组成,中国移动的移动网络编码(MNC)为00;用于识别移动用户所归属的移动通信网;MSIN是移动用户识别码,用以识别某一移动通信网中的移动用户。

IMSI结构组成

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

      MCC+MNC+MSIN

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

      MNC:Mobile Network Code,移动网络码,2~3位,中国移动系统使用00、02、07,中国联通GSM系统使用01、06,中国电信CDMA系统使用03、05,中国铁通系统使用20,一个典型的IMSI号码为460030912121001;

      MSIN:Mobile Subscriber Identification Number, 移动用户识别号码,共有10位,其结构如下:

      EF+M0M1M2M3+ABCD

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

      可以看出IMSI在NMSI号码前加了MCC,可以区别出每个用户的来自的国家,因此可以实现国际漫游。在同一个国家内,如果有多个移动网络运营商,可以通过MNC来进行区别.

      IMSI与手机号码绑定关系,在网络侧网元HLR(Home Location Register)内定义。


================================

     代码如下:

/* 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

{

    CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfoalloc] init];

    CTCarrier *carrier = [infosubscriberCellularProvider];

   NSString * mcc = [carrier mobileCountryCode];

   NSString * mnc = [carrier mobileNetworkCode];

   if (mnc == nil || mnc.length <1 || [mnc isEqualToString:@"SIM Not Inserted"] ) {

       return @"Unknown";

    }else {

       if ([mcc isEqualToString:@"460"]) {

           NSInteger MNC = [mnc 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
原创粉丝点击