Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get locale currency price for in-app purchases in iOS?

I want to find out user's App Store location. It means they are in US, Australia(AUD) store. Following code used.

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {     Books = response.products;     if ([SKPaymentQueue canMakePayments] && [response.products count]>0) {      }      for (SKProduct *book in Books) {         NSLocale *locat=[NSLocale currentLocale];         NSString *strlocate=[locat objectForKey:NSLocaleCountryCode];          NSLog(@"\n\n\n Device country== %@ \n\n\n",strlocate);          NSLocale* storeLocale = book.priceLocale;         NSString *storeCountry = (NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);         NSLog(@"\n\n\n store country== %@ \n\n\n",storeCountry);     } } 

I want like wise if book tier is one means US $ 0.99 AUD 0.99 JPY 85 based on the app store price matrix table.

I tested in the simulator. I changed country name in iTunes, appstore and safari application in the system. but I get only US country code.

Edit: Settings-> General-> International->Region Format-> country

I tested in the device: Device country only changed. store country show US country code and price. I want to store country code before start inapp purchase time.

how many days once change the price for based on currency fluctuation? is it provide any api/ query for fluctuated price to known/update?

my inapp operation made one class. Before inapp operation made i want to display the local price to user same price effect reflect in the inapp operation.

i display the list of book free and paid books thats is list get from my server. in that i display the price for each item. those item price while processing the appstore it will show the dollar price. if appstore shown the price as also i want to shown. so that i want to send country code to my server from that my server respond that country related price list and currency symbol..

like image 614
Senthilkumar Avatar asked Jan 22 '13 07:01

Senthilkumar


People also ask

How can I set country specific pricing for in-app purchase products?

Open Play Console and go to the App pricing page (Products > App pricing). Click Set price. Review the table in the "Local prices" section. In the "Price" column, review the local prices for each country.

How do you find out the cost of in-app purchases?

Locate “In-App Purchases” heading and tap it. (If In-App Purchases are available, it will say “Yes” and have a downward-pointing carat beside it.) After tapping the entry, a list will be revealed showing all of the app's In-App Purchases and the price of each one.

Does in-app purchases cost money?

An in-app purchase is any fee an app may ask for. Many in-app purchases are optional or give users additional features. Others serve as subscriptions and require users to sign up and pay a fee to use the app – often after an initial free trial.


2 Answers

productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:prodcutIdentifier];     productsRequest.delegate = self;          // This will trigger the SKProductsRequestDelegate callbacks     [productsRequest start]; 

This will call your delegate function. Once the above is done, it will automatically call the below mentioned function finally. This is where the app store request sent will be finalized.

(void)requestDidFinish:(SKRequest *)request {              SKProduct *book = [Books objectAtIndex:0];              NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];     [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];     [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];     [numberFormatter setLocale:book.priceLocale];          NSLocale* storeLocale = book.priceLocale;     NSString *storeCountry = (NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);      } 

provide the Locale and country details as per your interest.

like image 200
Andro Selva Avatar answered Sep 28 '22 00:09

Andro Selva


Here book is the SKProduct:

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; [numberFormatter setLocale:book.priceLocale]; NSString *formattedPrice = [numberFormatter stringFromNumber:book.price];  NSLog(@"%@", formattedPrice); 

simply ask if anything unclear!

Regards,

like image 42
Asif Mujteba Avatar answered Sep 28 '22 00:09

Asif Mujteba