0

This is my code for getting the local price and currency symbol.

private func getLocalCurrencyAndPrice(from product: SKProduct) -> (currency: String, price: Double) {
    //Get the currency
    let numberFormatter = NumberFormatter()
    numberFormatter.numberStyle = .currency
    numberFormatter.locale = product.priceLocale
    let priceString = numberFormatter.string(from: 0)
    let currencyString = ((priceString?.replacingOccurrences(of: "0", with: ""))?.replacingOccurrences(of: ".", with: ""))?.replacingOccurrences(of: ",", with: "")
    let trimmedCurrency = currencyString?.trimmingCharacters(in: .whitespacesAndNewlines)
    
    //Get the price
    let price = (product.price.doubleValue).roundToDecimal(2)
    return (currency: trimmedCurrency ?? "", price: price)
}

And this is how I am getting separate values:

let currency = getLocalCurrencyAndPrice(from: product).currency
let price = getLocalCurrencyAndPrice(from: product).price

I have created sandbox users for different App Store regions from the App Store Connect. It shows almost all regional prices and currency symbols perfectly except for Indonesia, Taiwan & Korea.

For Indonesia, on the "App Store Connect" It is showing Rp as their currency symbol: (Please ignore the differences in currency amount for now for all 3 countries)

enter image description here

But on the application, it is showing IDR:

enter image description here

For Taiwan, on the "App Store Connect" & on the application, It is showing $ as their currency symbol:

enter image description here

But on the "Settings > App Store > Sandbox User > Manage" & "Purchase Pop-Up view", it is showing NT$ as their currency symbol:

enter image description here

For Korea, on the "App Store Connect", "Settings > App Store > Sandbox User > Manage" & "Purchase Pop-Up view", It is showing as their currency symbol:

enter image description here

But on the application, it is showing with a double line:

enter image description here

Why these mismatches are showing while I am getting the value from the same source? What have I done wrongly?

3
  • 1
    Because one is a web site with a particular localisation and the other is your app with iOS number formatters localisation
    – Paulw11
    Jul 14 at 8:55
  • @Paulw11 Is there any way that exists to mitigate it? There's nothing I found besides using numberFormatter.locale = product.priceLocale to get the local symbol. Thanks for commenting :)
    – Tulon
    Jul 14 at 9:00
  • 1
    I don't see that there is really anything to mitigate. The localisation on the two platforms is different that is all. I am sure people in those countries will understand the pricing
    – Paulw11
    Jul 14 at 9:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.