iOS iTunes商店国家/地区 [英] iOS iTunes store country

查看:241
本文介绍了iOS iTunes商店国家/地区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有解决方案可以找出用户下载应用程序的国家/地区。

i am wondering if there is a solution to find out, in which country the user downloaded an application.

例如:app x已在美国下载用户打开应用程序,应用程序将检查下载的国家/地区。在这个例子中,回报将是USA

For example: app x has been downloaded in USA when the user opens up the app, the app will check in which country it was downloaded. In this example the the return would be "USA"

是否有人想知道如何解决这个问题?

Does any one hase an idea on how to solve this?

推荐答案

如果您有任何应用内购买,您可以从SKProduct中读取区域设置。作为后备,请使用设备的区域设置。

If you have any In-App Purchases available, you can read the locale from the SKProduct. As a fallback, use the device's locale.

NSLocale *locale;
SKProduct *baseProduct = nil; // replace as applicable
if (baseProduct) {
    locale = baseProduct.priceLocale; // from the user's credit card on iTunes
} else {
    locale = [NSLocale currentLocale]; // from user preferences
}
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
NSLog(@"Two-letter country code: %@", countryCode);

这篇关于iOS iTunes商店国家/地区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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