ADVANCED
How to detect iOS Storefront?
When distributing your app through Apple's App Store, you may need to detect the current storefront to implement region-specific functionality. The storefront represents the App Store region that the user is currently using, identified by a three-letter country code (e.g., "USA" for United States).
This detection is particularly important because several storefronts now permit developers to direct players to external payment pages — the United States (Epic v. Apple), Japan (Mobile Software Competition Act), and Brazil (CADE settlement). You can use the storefront detection to:
- Enable external payment links for the storefronts that permit them
- Implement region-specific payment flows
- Control feature availability based on regional requirements
- Ensure compliance with local regulations
If the app is installed via alternative distribution (for example, an alternative marketplace/web distribution under the DMA), the Storefront country code may be unavailable and returned as an empty string. In that case, use the alternative store installation detection guide to determine whether the app is running in an alternative distribution environment.
To determine the current iOS storefront and control SDK functionality based on the region, use the following code snippets:
- Objective-C
- Swift
[SKPaymentQueue loadCurrentStorefrontCountryCodeWithCompletion:^(NSString* _Nullable countryCode) {
// Storefronts where Apple permits external payments (US, Japan, Brazil)
NSSet<NSString*>* externalPaymentStorefronts = [NSSet setWithObjects:@"USA", @"JPN", @"BRA", nil];
settings.enablePayments = countryCode && [externalPaymentStorefronts containsObject:countryCode];
[[SKPaymentQueue defaultQueue] startWithSettings:settings];
}];
SKPaymentQueue.loadCurrentStorefrontCountryCode { countryCode in
// Storefronts where Apple permits external payments (US, Japan, Brazil)
let externalPaymentStorefronts: Set = ["USA", "JPN", "BRA"]
settings.enablePayments = countryCode.map(externalPaymentStorefronts.contains) ?? false
SKPaymentQueue.default().start(settings)
}
The loadCurrentStorefrontCountryCode method asynchronously retrieves the three-letter country code for the current Storefront. You can use this information to enable or disable SDK functionality for specific regions.
Alternatively, you can use Apple's Storefront ↗ (https://developer.apple.com/documentation/storekit/storefront) class directly, as demonstrated below:
We recommend against using the Objective-C SKStorefront implementation as it performs synchronous loading that blocks the main thread. This can lead to UI freezes and poor user experience, as noted in Apple's official documentation ↗.
let storefront = await Storefront.current
let countryCode = storefront?.countryCode
settings.enablePayments = countryCode == "USA"
SKPaymentQueue.default().start(settings)
For more information, see the implementation in Apple's official documentation ↗ (https://developer.apple.com/documentation/storekit/skpaymentqueue/storefront).