且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS iTunes商店国家/地区

更新时间:2023-12-04 15:24:55

如果您有任何应用内购买,您可以从SKProduct中读取区域设置。作为后备,请使用设备的区域设置。

If you have any In-App Purchases available, you can read the locale from the SKProduct. As a fallback, use the device's locale.

NSLocale *locale;
SKProduct *baseProduct = nil; // replace as applicable
if (baseProduct) {
    locale = baseProduct.priceLocale; // from the user's credit card on iTunes
} else {
    locale = [NSLocale currentLocale]; // from user preferences
}
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
NSLog(@"Two-letter country code: %@", countryCode);