国际移动用户识别码:IMSI

国际移动用户识别码,即IMSI(International Mobile Subscriber Identity),它是在公众陆地移动电话网(PLMN)中用于唯一识别移动用户的一个号码。在GSM网络,这个号码通常被存放在SIM卡中。

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位。

以下为国内MCC+MNC的相关数据:

Android获取IMSI的方案:

public class SimUtil {

         /**

          * 中国移动

          */

         public static final int SIM_TYPE_CHINA_MOBILE = 1;

         /**

          * 中国联通

          */

         public static final int SIM_TYPE_CHINA_UNICOM = 2;

         /**

          * 中国电信

          */

         public static final int SIM_TYPE_CHINA_TELECOM = 3;


         /** SIM卡是中国移动 */

         public static boolean isChinaMobile() {

                   String imsi = getSimOperator();

                   if (imsi == null) return false;

                   return imsi.startsWith("46000") || imsi.startsWith("46002") || imsi.startsWith("46007");

         }

         /** SIM卡是中国联通 */

         public static boolean isChinaUnicom() {

                   String imsi = getSimOperator();

                   if (imsi == null) return false;

                   return imsi.startsWith("46001");

         } 

         /** SIM卡是中国电信 */

         public static boolean isChinaTelecom() {

                   String imsi = getSimOperator();

                   if (imsi == null) return false;

                   return imsi.startsWith("46003");

         }

         private static String getSimOperator() {

                   TelephonyManager tm = (TelephonyManager)BoyaaApp.getApplication().getSystemService(Context.TELEPHONY_SERVICE);

                   return tm.getSubscriberId();

         }     

         /** 获取手机电话号码 */

         public static String getPhoneNumbers() {

                   TelephonyManager tm = (TelephonyManager)BoyaaApp.getApplication().getSystemService(Context.TELEPHONY_SERVICE);

                   return tm.getLine1Number();

         }      

         //sim卡是否可读

         public static boolean isCanUseSim() {

             try {

                 TelephonyManager mgr = (TelephonyManager) BoyaaApp.getApplication().getSystemService(Context.TELEPHONY_SERVICE);

                 return TelephonyManager.SIM_STATE_READY == mgr

                         .getSimState();

             } catch (Exception e) {

                 e.printStackTrace();

             }

             return false;

         }

}

IOS获取IMSI方案:(会存在审核不通过的风险,7.0以后貌似无法获取,未测试)

使用coreTelephony.framework获取imsi

#define PRIVATE_PATH  "/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony"

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
#if !TARGET_IPHONE_SIMULATOR
    void *kit = dlopen(PRIVATE_PATH,RTLD_LAZY);    
    NSString *imsi = nil;
    int (*CTSIMSupportCopyMobileSubscriberIdentity)() = dlsym(kit, "CTSIMSupportCopyMobileSubscriberIdentity");
    imsi = (NSString*)CTSIMSupportCopyMobileSubscriberIdentity(nil);
    dlclose(kit);    

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"IMSI" 
                                                    message:imsi 
                                                   delegate:self 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
#endif
}

参考资料:

  • http://en.wikipedia.org/wiki/International_mobile_subscriber_identity
  • http://en.wikipedia.org/wiki/Mobile_Country_Code_(MCC)
  • http://en.wikipedia.org/wiki/Mobile_Network_Code
  • http://blog.csdn.net/arthurchenjs/article/details/6261824

Related posts:

  1. Smarty截取中文乱码的解决办法
  2. 搜索引擎来源关键词解析乱码解决方案
  3. Goo.gl的使用方法

你可能感兴趣的:(客户端,网站分析)