更新时间: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);