Get In-App-Item Price In USD - Instead of User's Local Coin
Asked Answered
P

3

9

For Analysis and collecting data I want to get The price of SKProduct in dollars.

The base code I use to show the user the price is :

   _priceFormatter = [[NSNumberFormatter alloc] init];
   [_priceFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
   [_priceFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];

   [_priceFormatter setLocale:inAppProduct.priceLocale];
   inAppItemString = [_priceFormatter stringFromNumber:inAppProduct.price];

This code give me the real price the user should pay with his local coin

I tried to set the local as en_US, but I got the same price as before , with the $ :) This what I changed for trying this:

   NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
   [_priceFormatter setLocale:usLocale];

Any idea how to get the price in USD ?

Plateau answered 2/6, 2014 at 8:28 Comment(12)
Do you want the price the user pays, converted to US dollars, or the price that a US user would pay? The first is difficult, you'd need to get the right conversion factor from somewhere. For the second you need to convince the store to give you the US price.Recollect
@Recollect , Both options should give me the same... So how can I convince the store to do so ? :)Plateau
What you're trying to do doesn't make sense. The user will pay in whatever form of currency is used for their country's app store. End of story. If you want to convert to USD and display that amount to the user you could do that (as the first commenter said--you'd have to get the current exchange rate and do the conversion yourself). But this would be a pointless and misleading exercise since the user will pay in their form of currency and Apple will handle the currency conversion when they pay you.Wrinkly
@NicholasHart as I said in my question, I want it for Analysis and collecting data. Thanks for your answerPlateau
@Plateau were you able to figure this out and come to a solution?Trautman
@Trautman I gave up on this and used hard-code solution. You are more then welcome to find the real solution..Plateau
@Plateau what is the hard code solution?Trautman
@Trautman You can save the value of each IAP item in a plist or any other way (NSUserDefaults, etc..) and according to the IAP identifier to use the correct price in USD when needed.Plateau
@Plateau But what if there are fluctuations in exchange rate?Trautman
@Trautman You are right. I have no real solution for it. But anyway I needed it only for statistics, not for real actions.Plateau
You have a list of the product identifiers for purchases available, stored somewhere in your application, so you could just add the US prices to the list - the US prices are set by you, not by Apple. And then report the US price, possibly together with the currency.Recollect
@gnasher729, just read the previous comments, it's exactly what I did :)Plateau
T
1

You can send an http get request to an online conversion service, e.g.:

http://api.fixer.io/latest?base=GBP&symbols=USD

returning

{"base":"GBP","date":"2016-09-01","rates":{"USD":1.3261}}

to get the rate, which hopefully should not be too far from the rate used by Apple, and then calculate the value in USD.

Thorsten answered 1/9, 2016 at 21:44 Comment(3)
Apple doesn't just use an exchange rate. They adjust for local taxes, the round to a nice number, they only change the prices when the exchange rate changes a lot, so once set the price stays constant as long as the exchange rate doesn't change too much.Recollect
I agree that this is not at all perfect and that local taxes will not be accounted for, but still maybe better than hard coding price in USD?Nemhauser
@BjørnEgil , I think gnasher729 is right, it's not the answer i was looking for. The real answer is that there is no solution but using hard coding price in USD. I asked the question ages ago, and if i remember correctly, this is what i actually did.Plateau
S
0

You may want to try following:

NSLocale *priceLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];

Reference: Is there a simple way to format currency into string in iOS?

Sunda answered 12/2, 2016 at 13:14 Comment(0)
E
0

If you want to know how much a user has spent (for instance to segment for Support Level or Offer Category), hard-coding is a good option. If you have a price-dynamic app with lots of price points, setting up a lightweight Mongo server or uploading a config JSON or PLIST is also an option.

These are also good options if you want a fast and responsive way to keep track of an estimate of your earnings, real-time.

Logging which IAPs a user has bought in the cloud will get you there as well, btw. You'll need a script to convert between IAP id and "USD" (or whichever currency you prefer) and as a bonus, you'll see which IAPs are most popular.

For going more in-depth (segment by country, device, os, trends...) there are other services. Keep in mind these have more latency (~1h for some 24h) than a simple logger server. But you won't have to account for a sudden popularity explosion of your app as well :-)

Eldredge answered 24/1, 2020 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.