【问题标题】:Identify iPhone users iTunes Store region?识别 iPhone 用户 iTunes Store 区域?
【发布时间】:2011-04-12 22:17:06
【问题描述】:

我希望将 iTunes 搜索 API 添加到我的一个应用中以返回媒体。

我想将用户引导到他们的本地商店,而不是默认的美国商店,例如

http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=some+media&country=UK

有没有办法在代码中检测用户的默认存储区域?

非常感谢 尼克

【问题讨论】:

  • 反向地理定位可能是唯一的选择——好奇是否还有其他方法。

标签: iphone objective-c itunes


【解决方案1】:

根据iTunes Link Maker 看来,他们只是在国家代码中子代码以生成国家特定链接。

例子:

http://itunes.apple.com/mx/app/foursquare/id306934924?mt=8&uo=4

如果你把“mx”换成我们”

http://itunes.apple.com/us/app/foursquare/id306934924?mt=8&uo=4

您会得到适当的指导,因此您应该能够使用以下代码获取国家代码并将其加入。

NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
NSString *foursquareAppStoreLink = [NSString stringWithFormat:@"http://itunes.apple.com/%@/app/foursquare/id306934924?mt=8&uo=4", countryCode];

因此,假设您的链接结构与您可以将国家/地区代码交换为 country= 的方式相同

NSString *mySearchStringLink = [NSString stringWithFormat:@"http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=some+media&country=%@", countryCode];

【讨论】:

  • 谢谢!没有意识到 NSLocale 也有国家代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-02
  • 1970-01-01
  • 1970-01-01
  • 2012-04-29
  • 1970-01-01
  • 2018-06-19
相关资源
最近更新 更多