【问题标题】:How Can I check programmatically app store region/country?如何以编程方式检查应用商店地区/国家/地区?
【发布时间】:2012-07-09 06:04:18
【问题描述】:

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

【问题讨论】:

  • 为什么你希望链接只有在英国商店才有效?
  • 你可以做一个CoreLocation检查
  • @DustinRowland :问题是应用商店地区/国家不依赖于位置。
  • @Dusting:您不应该使用 CoreLocation,因为用户可能在其他国家/地区拥有帐户(例如在旅行时)。

标签: ios objective-c app-store region country


【解决方案1】:

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

斯威夫特

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

【讨论】:

    【解决方案2】:

    您可以使用应用内购买Store Kit 来实现此目的。

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

    【讨论】:

    • 如果应用中没有应用内购买怎么办?
    猜你喜欢
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 2015-02-28
    相关资源
    最近更新 更多