使用 MKStoreKit 获取 IAP 的本地价格
Get local price for IAP using MKStoreKit
我正在使用 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
}
}
MKStoreKit 内置了显示产品标题及其本地化价格的功能。
它具有使用本地化名称、描述和货币格式化产品名称的功能。
- (NSMutableArray*) purchasableObjectsDescription;
更多详情可以参考:MKStoreKit
我正在使用 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
}
}
MKStoreKit 内置了显示产品标题及其本地化价格的功能。
它具有使用本地化名称、描述和货币格式化产品名称的功能。
- (NSMutableArray*) purchasableObjectsDescription;
更多详情可以参考:MKStoreKit