导入系统库 CoreTelephony.framework,并在相关.h文件中导入,代码如下
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import<CoreTelephony/CTCarrier.h>
- (void)check
{
CTTelephonyNetworkInfo*info = [[CTTelephonyNetworkInfoalloc]init];
CTCarrier*carrier = info.subscriberCellularProvider;
NSString*carrierName = carrier.carrierName;
NSString*mobileCountryCode = carrier.mobileCountryCode;
NSString*mobileNetworkCode = carrier.mobileNetworkCode;
NSLog(@"carrier=%@ /n carrierName=%@ /n mobileCountryCode=%@ /n networkCode = %@",carrier,carrierName,mobileCountryCode,mobileNetworkCode);
}