国际移动用户识别码:IMSI
- - 标点符国际移动用户识别码,即IMSI(International Mobile Subscriber Identity),它是在公众陆地移动电话网(PLMN)中用于唯一识别移动用户的一个号码. 在GSM网络,这个号码通常被存放在SIM卡中. IMSI共有15位,其结构如下:. MCC:Mobile Country Code,移动国家码,MCC的资源由国际电联(ITU)统一分配和管理,唯一识别移动用户所属的国家,共3位,中国为460;.
国际移动用户识别码,即IMSI(International Mobile Subscriber Identity),它是在公众陆地移动电话网(PLMN)中用于唯一识别移动用户的一个号码。在GSM网络,这个号码通常被存放在SIM卡中。
IMSI共有15位,其结构如下:
MCC+MNC+MSIN (MNC+MSIN=NMSI)
以下为国内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
} 参考资料:
Related posts: