16

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!

Mike McMaster
  • 7,573
  • 8
  • 37
  • 42
  • Hi, did you ever find an elegant solution? We are in the same situation but we have a different Branch in the code for each country which doesn't scale very well. – Oli Aug 13 '10 at 18:07
  • No, but we ended up not needing to worry about this. Not sure if anything has changed in the last year. – Mike McMaster Aug 14 '10 at 00:47
  • 1
    User reviews, ratings and rankings are already fragmented by store (country). So just release 2 apps, one with U.S. features, and one without for the other stores. – hotpaw2 Apr 17 '12 at 07:28
  • 3
    This was asked in '09, but do we have any solutions 7 years later in '16? – Van Du Tran Nov 15 '16 at 04:48
  • 1
    it is 2018 and still we don't have any solution? – Moaz Saeed Oct 30 '18 at 12:38
  • Apple might protect the user's Apple ID's region info as some kind of privacy. So I don't think Apple will let us know the info about from which App Store it was downloaded. – DawnSong Aug 31 '20 at 08:04

3 Answers3

4

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...

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
  • Some countries or regions might disallow something, so the AppleID's region and the locale of the user's setting both are very important. – DawnSong Aug 31 '20 at 08:01
4

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.

Dan Sandland
  • 7,095
  • 2
  • 29
  • 29
1

The question is very old, but since others may have the same querying, i'm chipping in :) Given that it's not 'sensibly' possible other than through local retrieval, one mechanism would be through customer registration. In the registration form, you can then ask the country where they are registering from and take it from there...

AshesToAshes
  • 937
  • 3
  • 14
  • 31