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

时间:2012-12-20 07:25:03

标签: iphone ios push-notification udid

我正在尝试从iPhone设备UDID获取国家/地区代码。我发现了这个

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

它在本地设置中工作正常,但我想从设备UDID获取国家/地区代码。它可以通过吗?

...谢谢

2 个答案:

答案 0 :(得分:5)

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

答案 1 :(得分:2)

你可以这样做

#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.