iphone - 如何检测 iPhone/iPod Touch/iPad 上活跃的 iTunes 商店?

标签 iphone objective-c itunes itunes-store

我希望能够确定用户从我的应用程序内部连接到哪个商店,以便我可以将他们定向到适合其设备和商店的一些适当内容。有谁知道如何获取这些信息?

基本上,如果用户在英国并连接到英国商店,我希望我的函数/方法返回 GB,如果在韩国,我想要 KR、澳大利亚 = AU 等。任何帮助将不胜感激。

最佳答案

获取用户区域设置的国家/地区代码的方法将起作用……但前提是用户的 iTunes 商店与其区域设置相同。情况并非总是如此。

如果您创建应用内购买项目,您可以使用 Apple 的 StoreKit API 找出用户的实际 iTunes 国家/地区,即使它与他们的设备区域设置不同。这是一些对我有用的代码:

- (void) requestProductData
{
    SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:
                                 [NSSet setWithObject: PRODUCT_ID]];
    request.delegate = self;
    [request start];
}

- (void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *myProducts = response.products;
    for (SKProduct* product in myProducts) {
        NSLocale* storeLocale = product.priceLocale;
        storeCountry = (NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);
        NSLog(@"Store Country = %@", storeCountry);
    }

    [request release];

    // If product request didn't work, fallback to user's device locale
    if (storeCountry == nil) {
        CFLocaleRef userLocaleRef = CFLocaleCopyCurrent();
        storeCountry = (NSString*)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode);
    }

    // Now we're ready to start creating URLs for the itunes store
    [super start];
}

关于iphone - 如何检测 iPhone/iPod Touch/iPad 上活跃的 iTunes 商店?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2540530/

相关文章:

iphone - (iphone) imageNamed 当有多个同名文件时?

iphone - 将选择器添加到 UIButton

iphone - 如何将我的付费应用程序免费提供给某人

iphone - 排行榜 "No Items"

objective-c - 计算 NSArray 中的相等对象

ios - 如何从 iTunes 中的我的应用程序 "Tell A Friend"功能打开

iphone - 来自 YouTube 的缩略图

app-store - 提交应用程序之前获取整个帐户的iTunes链接

ios - 对 iTunes 应用内购买项目的一些说明

ios - +entityForName : could not locate an entity named 'myModel' in this model in core data - what's missing?