Moin Shirazi
Moin Shirazi

Reputation: 4425

Get local price for IAP using MKStoreKit

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 ?

Upvotes: 0

Views: 359

Answers (2)

arturdev
arturdev

Reputation: 11039

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

    }
}

Upvotes: 2

Priyanka Wadher Mistry
Priyanka Wadher Mistry

Reputation: 464

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

Upvotes: 0

Related Questions