Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I check programmatically app store region/country?

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.

like image 702
kayla08 Avatar asked Feb 20 '23 22:02

kayla08


2 Answers

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

like image 81
Şafak Gezer Avatar answered Mar 03 '23 01:03

Şafak Gezer


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.

like image 25
Christian Avatar answered Mar 03 '23 02:03

Christian