我正在使用MKStoreKit进行IAP。我可以很容易地完成所有任务(它简单易用)但仍然坚持通过productid获得当地价格
是否可以在mkstorekit中获取本地价格?
如果我会显示产品的本地价格会在审核中产生任何问题吗?
答案 0 :(得分:2)
//...
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:_productIdentifiers];
self.productsRequest.delegate = self;
[self.productsRequest start];
//...
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSLog(@"Loaded list of products...");
NSArray * skProducts = response.products;
for (SKProduct *product in skProducts) {
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
NSString *formattedPrice = [numberFormatter stringFromNumber:product.price];
//Use formattedPrice
}
}
编辑
如果您使用的是:https://github.com/MugunthKumar/MKStoreKit
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSKProductsAvailableNotification:) name:kMKStoreKitProductsAvailableNotification object:nil];
[[MKStoreKit sharedKit] startProductRequest];
//...
- (void)handleSKProductsAvailableNotification:(NSNotification *)note
{
NSArray * skProducts = [MKStoreKit sharedKit].availableProducts;
for (SKProduct *product in skProducts) {
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:product.priceLocale];
NSString *formattedPrice = [numberFormatter stringFromNumber:product.price];
//Use formattedPrice
}
}
答案 1 :(得分:0)
MKStoreKit具有显示产品标题及其本地化价格的能力。
它具有使用本地化名称,描述和货币格式化产品名称的功能。
- (NSMutableArray*) purchasableObjectsDescription;
有关详细信息,请参阅:MKStoreKit