Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect at runtime which country's App Store my iPhone app was downloaded from?

I have a feature in my iPhone application that, for business reasons, should only be shown/available to customers in the US. If I want to release this app to App Stores outside the US, what's the best way to figure out which country I'm in without relying on user-defined settings such as language and locale?

In my mind, the ideal solution is that there's some runtime property that can tell me which App Store country the app was downloaded from, and I can take action accordingly. Looking through the docs and searching the web, I'm not coming up with anything in this department.

I don't expect the solution to be 100% foolproof as far as users not being in the country they say they're from, but as close as possible would be nice.

I suppose one solution would be to make a separate build for a new product on the App Store and have two versions, one for the US and one for the others, but that doesn't seem ideal. I'm hoping it can be the same product on the App Store to prevent things like fragmentation of user reviews.

Thanks in advance!

like image 824
Mike McMaster Avatar asked Jul 10 '09 21:07

Mike McMaster


2 Answers

It's either Locale, or different versions for different stores.

To me the Locale option seems like the least amount of work and will probably be correct 95% of the time...

like image 105
Kendall Helmstetter Gelner Avatar answered Sep 17 '22 01:09

Kendall Helmstetter Gelner


I also think using NSLocale would be the best possible solution for determining the user's country.

Here's how it would be done:

// Get user's country code based on currentLocale
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

if ([countryCode isEqualToString:@"US"]){
    // US Only
}

However, since there's no guarantee that the user won't change their international settings, you might have no choice but to release separate apps, one for a US audience and another for an international one.

like image 28
Dan Sandland Avatar answered Sep 21 '22 01:09

Dan Sandland