在检测哪个国家的App Store我的iPhone应用程序,从下载运行? [英] Detect at runtime which country's App Store my iPhone app was downloaded from?

查看:355
本文介绍了在检测哪个国家的App Store我的iPhone应用程序,从下载运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的iPhone应用程序这一特点,由于业务原因,只应显示/提供给客户,在美国。如果我想这个应用程序发布到美国以外的应用程序商店,有什么要弄清楚我在哪个国家,而不依赖于用户定义的设置,如语言和区域设置的最佳方式?

I have a feature in my iPhone application that, for business reasons, should only be shown/available to customers in the US. If I want to release this app to App Stores outside the US, what's the best way to figure out which country I'm in without relying on user-defined settings such as language and locale?

在我看来,理想的解决方案是,有一些运行时属性,可以告诉我哪个App Store的国家应用从下载的,我可以采取相应的行动。翻翻文档和Web搜索,我不来了在这个部门什么。

In my mind, the ideal solution is that there's some runtime property that can tell me which App Store country the app was downloaded from, and I can take action accordingly. Looking through the docs and searching the web, I'm not coming up with anything in this department.

我不希望该解决方案是100%万无一失尽可能用户不要在国内,他们说他们来自哪个国家,但尽可能接近将是很好之中。

I don't expect the solution to be 100% foolproof as far as users not being in the country they say they're from, but as close as possible would be nice.

我想一个解决办法是让一个单独构建在App Store的新产品,并有两个版本,一个是美国,一个是别人,但似乎并不理想。我希望它可以为prevent的东西同样的产品在App Store类似的用户评论碎片。

I suppose one solution would be to make a separate build for a new product on the App Store and have two versions, one for the US and one for the others, but that doesn't seem ideal. I'm hoping it can be the same product on the App Store to prevent things like fragmentation of user reviews.

在此先感谢!

推荐答案

我也想用NSLocale将是确定用户所在的国家的最佳解决方案。

I also think using NSLocale would be the best possible solution for determining the user's country.

下面是它会怎么做:

// Get user's country code based on currentLocale
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

if ([countryCode isEqualToString:@"US"]){
    // US Only
}

不过,由于没有保证用户不会改变自己的国际设置,你可能没有选择,只能释放单独的应用程序,一个是美国的观众,另一个为一个国际问题。

However, since there's no guarantee that the user won't change their international settings, you might have no choice but to release separate apps, one for a US audience and another for an international one.

这篇关于在检测哪个国家的App Store我的iPhone应用程序,从下载运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆