How Can I check programmatically app store region/country?
Asked Answered
T

2

6

Is there a way to check it? I have an application URL, which I don't want to be opened expect if the user have a uk appstore. unfortunately, this application is available in many country, so when I put 'gb' on the link, it be redirected to the local region of the user.

Tailpipe answered 9/7, 2012 at 19:33 Comment(4)
Why do you want the link to only work if they are in the UK store?Saladin
You could do a CoreLocation checkAutogiro
@DustinRowland : the problem is that the app store region/country don't depend on the location .Tailpipe
@Dusting: You should not use CoreLocation because the user may have an account in a different country (e.g. when traveling).Behest
R
4

You could use the in-app purchase Store Kit to achieve this.

Request the product list using SKProductsRequest then check the returned SKProduct's priceLocale to see if the user's AppStore is the UK one.

Redpencil answered 10/7, 2012 at 7:4 Comment(1)
What if there are no In-App Purchases in the app?Contend
F
9

For iOS 13+, check the SKStoreFront class. It has a countryCode that returns the country code belonging to the user's current App Store region.

Swift

if let storefront = SKPaymentQueue.default().storefront {
    print(storefront.countryCode) // Returns an Alpha-3 country code (USA, GBR etc.)
}

Obj C

[SKPaymentQueue defaultQueue].storefront.countryCode; // Returns an Alpha-3 country code (USA, GBR etc.)

You should be able to access the SKStoreFront instance by adding the StoreKit framework to your project, even if your app does not offer any purchases.

For more information, check out: https://developer.apple.com/documentation/storekit/skstorefront

Fourposter answered 28/8, 2020 at 9:7 Comment(0)
R
4

You could use the in-app purchase Store Kit to achieve this.

Request the product list using SKProductsRequest then check the returned SKProduct's priceLocale to see if the user's AppStore is the UK one.

Redpencil answered 10/7, 2012 at 7:4 Comment(1)
What if there are no In-App Purchases in the app?Contend

© 2022 - 2024 — McMap. All rights reserved.