gpt4 book ai didi

ios - 使用MKStoreKit获取IAP的本地价格

转载 作者:行者123 更新时间:2023-12-01 20:15:20 27 4
gpt4 key购买 nike

我将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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com