Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS iTunes store country

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?

like image 754
Emi2k4 Avatar asked Jul 26 '12 13:07

Emi2k4


2 Answers

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);
like image 125
Neal Ehardt Avatar answered Oct 15 '22 20:10

Neal Ehardt


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.

like image 36
Stavash Avatar answered Oct 15 '22 21:10

Stavash