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.
Asked
Active
Viewed 7,443 times
6
-
1Why do you want the link to only work if they are in the UK store? – woz Jul 09 '12 at 19:35
-
You could do a CoreLocation check – Dustin Jul 09 '12 at 19:40
-
@DustinRowland : the problem is that the app store region/country don't depend on the location . – kayla08 Jul 11 '12 at 12:14
-
@Dusting: You should not use CoreLocation because the user may have an account in a different country (e.g. when traveling). – Yoav Nov 13 '12 at 22:07
2 Answers
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

Şafak Gezer
- 3,928
- 3
- 47
- 49