
CoreTelephony
获取运营商信息,需通过 CoreTelephony.Framework 中的 CTTelephonyNetworkInfo 和 CTCarrier 对象获取,这些都在iOS 4.0后就有了。
现提供源码,支持arc与非arc编译,使用时请引入 CoreTelephony.Framework 框架
MobileCountryCode.h + MobileCountryCode.m
//
// MobileCountryCode.h
//
// http://en.wikipedia.org/wiki/Mobile_Network_Code
//
// Created by YouXian on 14-3-24.
// Copyright (c) 2014年 YouXian. All rights reserved.
// #import <Foundation/Foundation.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h> #warning 使用前请引入 CoreTelephony.framework 框架 @interface MobileCountryCode : NSObject /**
获取当前运营商的标识符 @return 返回运营商标示符(成功返回标示符,失败返回nil) 中国移动 00 02 07
中国联通 01 06
中国电信 03 05
中国铁通 20 */
+ (NSString *)serviceProvider; @end
//
// MobileCountryCode.m
//
// http://en.wikipedia.org/wiki/Mobile_Network_Code
//
// Created by YouXian on 14-3-24.
// Copyright (c) 2014年 YouXian. All rights reserved.
// #import "MobileCountryCode.h" #if __has_feature(objc_arc)
#define YX_release(obj)
#define YX_autorelease(obj)
#else
#define YX_release(obj) [obj release]
#define YX_autorelease(obj) [obj autorelease]
#endif @implementation MobileCountryCode + (NSString *)serviceProvider
{
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init]; // information about the user’s home cellular service provider
CTCarrier *carrier = [info subscriberCellularProvider];
if (carrier == nil)
{
YX_release(carrier);
carrier = nil; return nil;
} // The mobile network code (MNC) for the user’s cellular service provider
NSString *code = [carrier mobileNetworkCode];
if (code == nil)
{
YX_release(carrier);
carrier = nil; return nil;
} return code;
} @end
运营商MNC值请参考以下链接
http://en.wikipedia.org/wiki/Mobile_Network_Code
以下为中国运营商节选
MCC | MNC | Brand | Operator | Status | Bands (MHz) | References and notes |
---|---|---|---|---|---|---|
460 | 00 | China Mobile | China Mobile | Operational | GSM 900 / GSM 1800 / TD-SCDMA 1900 / TD-SCDMA 2000 / TD-LTE 1900 / TD-LTE 2300 / TD-LTE 2600 | |
460 | 01 | China Unicom | China Unicom | Operational | GSM 900 / GSM 1800 / UMTS 2100 / TD-LTE 2300 / TD-LTE 2600 / FDD-LTE 1800 | 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 | China Mobile | Not Operational | GSM 900 / GSM 1800 / TD-SCDMA 1900 / TD-SCDMA 2000 / TD-LTE 1900 / TD-LTE 2300 / TD-LTE 2600 | |
460 | 03 | China Telecom | China Telecom | Operational | CDMA2000 800 / CDMA2000 2100 / FDD-LTE 2100 / TD-LTE 2300 / TD-LTE 2600 | EV-DO |
460 | 05 | China Telecom | China Telecom | Not Operational | CDMA2000 800 / CDMA2000 2100 / FDD-LTE 2100 / TD-LTE 2300 / TD-LTE 2600 | |
460 | 06 | China Unicom | China Unicom | Not Operational | GSM 900 / GSM 1800 / UMTS 2100 | |
460 | 07 | China Mobile | China Mobile | Not Operational | GSM 900 / GSM 1800 / TD-SCDMA 1900 / TD-SCDMA 2000 / TD-LTE 1900 / TD-LTE 2300 / TD-LTE 2600 | |
460 | 20 | China Tietong | China Tietong | Operational | GSM-R |