简体   繁体   English

从iPhone设备UDID获取国家/地区代码?

[英]Get the country code from iPhone device UDID?

I am trying to get the country code from iPhone device UDID. 我想从iPhone设备UDID获取国家/地区代码。 I found this 我找到了这个

NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
NSString *countryName = [locale displayNameForKey:NSLocaleCountryCode value:countryCode];

It is working fine in local settings but I want to get the country code from device UDID. 它在本地设置中工作正常,但我想从设备UDID获取国家/地区代码。 Is it passable? 它可以通过吗?

Thanks... 谢谢...

UDID不包含有关国家/地区代码的信息。

You can do like this 你可以这样做

#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>

// Setup the Network Info and create a CTCarrier object
CTTelephonyNetworkInfo *networkInfo = [[[CTTelephonyNetworkInfo alloc] init] autorelease];
CTCarrier *carrier = [networkInfo subscriberCellularProvider];

// Get carrier name
NSString *carrierName = [carrier carrierName];
if (carrierName != nil)
  NSLog(@"Carrier: %@", carrierName);

// Get mobile country code
NSString *mcc = [carrier mobileCountryCode];
if (mcc != nil)
  NSLog(@"Mobile Country Code (MCC): %@", mcc);

// Get mobile network code
NSString *mnc = [carrier mobileNetworkCode];
if (mnc != nil)
  NSLog(@"Mobile Network Code (MNC): %@", mnc);

For reference check this. 供参考检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM