Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS programming - how to discover from which (country's) app store the app was downloaded

As you iOS devs know, you can only set one price tier for your app and in-app products in the app store. However, you can (theoretically) publish it as separate apps in different countries with different prices. I would like to do the same with in-app products of the same app - define alternative in-app products, and control their visibility in the app depending on user's country. I don't want to use NSLocale or NSTimeZone because they can be changed in settings. I want to know the country that the app store / user is connected to.

For example, I want to offer an auto-renewing subscription for most users, but I know that auto-renewing subscriptions are not available in the Israeli app store, so I want to show a non-renewing subscription exclusively to Israeli users, and not show them the auto-renewing one. Is there a reliable way of achieving this?

Thanks, Avi

like image 391
Avi Avatar asked Jul 08 '13 09:07

Avi


1 Answers

After investigating further, I discovered that when querying products in store-kit, SKProduct returns with a property named priceLocale, which consists of the country code and currency code. The country code of priceLocale seems to be consistent with the user's app store.

To sum up, doing these steps will get the result, however in a slow and not straightforward way:

  1. Define an in-app item;
  2. Query that item in your app;
  3. Determine user's country according to [product.priceLocale objectForKey:NSLocaleCountryCode];
  4. Show the user the relevant products your app supports in their country.
like image 179
Avi Avatar answered Nov 01 '22 18:11

Avi