Get local price for IAP using MKStoreKit

352 Views Asked by At

I am using MKStoreKit for IAP. I can get all the task done easily (it's simple and easy to use) but m stuck to get the local price by productid

Is it possible to get the local price in mkstorekit ?

And if i will display local price for product will it create any problem in review ?

2

There are 2 best solutions below

2
arturdev On BEST ANSWER
//...
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

    }
}

EDIT

If you are using: 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

    }
}
2
Priyanka Wadher Mistry On

MKStoreKit has built in ability to display product titles along with their localized price.

It has function to format the product name with their localized name, description and currency.

- (NSMutableArray*) purchasableObjectsDescription;

For more details you can refer: MKStoreKit