我将MKStoreKit用于IAP。我可以轻松完成所有任务(简单易用),但必须坚持按productid获取本地价格

是否可以在mkstorekit中获得本地价格?

如果我将显示产品的本地价格,是否会在审查中产生任何问题?

最佳答案

//...
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

    }
}

关于ios - 使用MKStoreKit获取IAP的本地价格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36786818/

10-08 21:05