0

我希望我的应用程序可以在少数 iTunes 商店中使用。我阅读了NSLocale 类参考,他们正在谈论“当前用户”。那么,谁是“当前用户”?是下载了应用程序的用户吗?

1) 是否可以根据下载我的应用程序的当前 appleID 国家或 iTunes 商店国家/地区获取 NSLocale?

2)是否可以模拟 NSLocale 来测试我的应用程序?

4

2 回答 2

1

在 iOS 中,没有“当前用户”这样的东西。文档中对“当前用户”的引用NSLocale可能是 OS X 文档的保留。

在 iOS 中,运行设置应用程序并转到常规,然后转到国际。“区域格式”和“语言”设置定义了您在 iOS 中返回的[NSLocale currentLocale].

在 iOS 中,第三方应用程序无法获取任何类型的 appleID 或有关特定 iTunes 商店的信息。

直接回答你的两个问题:

1) 不,您无权访问此信息

2) 是的,运行设置应用程序并更改语言和/或区域格式设置。这将影响NSLocale您在应用程序中获得的内容。

于 2013-01-23T18:04:41.263 回答
1

伙计们,我找到了获取用户(Apple ID、iTunes 商店)区域设置的解决方案!您可以从 SKProduct 获取语言环境。

if([SKPaymentQueue canMakePayments])
{
   [self requestProductData];
}

#pragma mark -
#pragma mark In-App Purchase Delegate Methods

- (void)requestProductData
{
    NSLog(@"IN-APP:requestProductData");
    SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:<your in-app identifier>]];
    request.delegate = self;
    [request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *myProduct = [[NSArray alloc]initWithArray:response.products];
    if ([myProduct count]>0)
    {
        SKProduct *product = [myProduct objectAtIndex:0];
        NSLog(@"Price: %.2f",product.price.floatValue);
        NSLog(@"Price Locale: %@",product.priceLocale.localeIdentifier);
        NSLog(@"Product Identifier: %@",product.productIdentifier);
        NSLog(@"IN-APP:array count: %i", [myProduct count]);
        [request autorelease];
    }
    [myProduct release];
    myProduct = nil;
}
于 2013-01-24T09:23:06.630 回答