有办法检查吗? 我有一个应用程序 URL,除非用户有英国应用商店,否则我不想打开该 URL。不幸的是,这个应用程序在许多国家/地区都可用,因此当我在链接上添加“gb”时,它会被重定向到用户的本地区域。
最佳答案
对于 iOS 13+,请检查 SKStoreFront
类。它有一个 countryCode
,用于返回属于用户当前 App Store 区域的国家/地区代码。
swift
if let storefront = SKPaymentQueue.default().storefront {
print(storefront.countryCode) // Returns an Alpha-3 country code (USA, GBR etc.)
}
对象C
[SKPaymentQueue defaultQueue].storefront.countryCode; // Returns an Alpha-3 country code (USA, GBR etc.)
即使您的应用不提供任何购买功能,您也应该能够通过将 StoreKit 框架添加到您的项目来访问 SKStoreFront
实例。
欲了解更多信息,请查看:https://developer.apple.com/documentation/storekit/skstorefront
关于ios - 如何以编程方式检查应用程序商店区域/国家?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11401853/