如何以编程方式检查应用商店地区/国家?

kay*_*a08 4 country objective-c region app-store ios

有没有办法检查它?我有一个应用程序 URL,如果用户有英国应用商店,我不想打开它。不幸的是,此应用程序在许多国家/地区都可用,因此当我在链接上添加“gb”时,它会被重定向到用户的本地区域。

Şaf*_*zer 5

对于 iOS 13+,检查SKStoreFront类。它有一个countryCode返回属于用户当前 App Store 区域的国家/地区代码。

迅速

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

对象C

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

您应该能够SKStoreFront通过将 StoreKit 框架添加到您的项目来访问该实例,即使您的应用程序不提供任何购买。

有关更多信息,请查看:https : //developer.apple.com/documentation/storekit/skstorefront


小智 4

您可以使用应用内购买商店套件来实现此目的。

使用SKProductsRequest请求产品列表,然后检查返回的SKProduct的priceLocale以查看用户的AppStore是否是英国的。

  • 如果应用程序中没有应用内购买怎么办? (8认同)