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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With