iOS iTunes store country

て烟熏妆下的殇ゞ 提交于 2019-12-10 00:45:49

问题


i am wondering if there is a solution to find out, in which country the user downloaded an application.

For example: app x has been downloaded in USA when the user opens up the app, the app will check in which country it was downloaded. In this example the the return would be "USA"

Does any one hase an idea on how to solve this?


回答1:


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);



回答2:


There might be a good enough correlation between the iTunes store country and the locale a user sets. This depends on your needs - if this does not suffice, I don't think there is a way to know which actual store an app was downloaded from.

To retrieve that locale, you could use:

NSString *localeIdentifier = [[NSLocale currentLocale] localeIdentifier];

Hope this is sufficient for your needs.




回答3:


It's not possible to check "which" App Store an app was downloaded.

If you need to do anything location-based, you should look at CLLocation to obtain a user's current location, however it may seem intrusive for the app to ask a user for their location if it's not apparent why it would need the location.

You could also check for the language on a users device, such as en_gb for Britain, dk for Denmark, en_ca for Canada, etc. While this doesn't completely cover when people in some countries have set the language to something else than the countries native language, it's better than nothing.



来源:https://stackoverflow.com/questions/11670302/ios-itunes-store-country

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!