正如标题所示,我需要获得层内的应用内商品价格,但对于美国应用商店,完全忽略用户当前的区域设置和设置。
换句话说,
获取产品的美元价格即使本地用户设置为俄罗斯/法国/无论如何。
由于
答案 0 :(得分:2)
您需要的产品将在SKProductsRequest中提供。如果使用SKRequestDelegate协议实现对象,则可以获取价格。如果您愿意,可以选择将语言环境硬编码为美国。
设置请求:
NSSet* identifiers = [NSSet setWithObjects:inAppIdentiferOne, inAppIdentifierTwo, nil];
SKProductsRequest* productRequest= [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers];
productRequest.delegate = self;
[productRequest start];
处理回复:
-(void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
for(int i=0; i<response.products.count; i++)
{
SKProduct* instance = [response.products objectAtIndex:i];
NSLog(@"IAP Desc: %@. Title: %@.", instance.localizedDescription, instance.localizedTitle);
// This is where you can hardcode the US locale by setting a NSLocale type
// I'm not 100% sure on how to set the NSLocale correctly, so currently this line sets localization
NSLocale* locale = instance.priceLocale;
NSNumberFormatter* fmtr = [[NSNumberFormatter alloc] init];
[fmtr setNumberStyle:NSNumberFormatterCurrencyStyle];
[fmtr setLocale:locale];
if([instance.productIdentifier isEqualToString:inAppIdentiferOne])
{
NSString* localizedCostString = [fmtr stringFromNumber:(instance.price)];
NSString* productIdentifier = instance.productIdentifier;
}
else if([instance.productIdentifier isEqualToString:inAppIdentiferTwo])
{
NSString* localizedCostString = [fmtr stringFromNumber:(instance.price)];
NSString* productIdentifier = instance.productIdentifier;
}
}
}
还有一个可选功能来处理检索您可能想要处理的这些标识符的失败。