Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS in-app purchase subscription shows incorrect currency for locale

I'm using SwiftyStoreKit to handle IAP in my app. The issue is prices for IAP products will always show in USD currency like this: $9.99. No matter in what country people test the app.

I'm trying to change locale in Simulator like this (in scheme edit window). Using custom location won't give me another currency as well while Locale.current shows changed locale.

Trying both:

  1. SwiftyStoreKit's product.localizedPrice
  2. And directly from product object (which localizedPrice is actually is as extension to SKProduct)

    let numberFormatter = NumberFormatter()
    numberFormatter.numberStyle = .currency
    numberFormatter.locale = product.priceLocale
    let price = numberFormatter.string(from: product.price)
    

    price still $9.99 here in Denmark or Japan

Am I missing some magic locale setting in the project properties?

  • sandbox or production, won't make a difference
  • when IAP popup appears, currency is correct there but not in the app itself
  • using a bunch of other Pods in the project like Sentry and Beacon
like image 426
Maks Shevchenko Avatar asked Mar 19 '19 21:03

Maks Shevchenko


2 Answers

The price and the price locale is determined by the store association of the purchasing account, not the device locale.

i.e. Someone with an account linked to the US store will always see $US since that is how they will be charged, regardless of where they are physically in the world or the locale of their device.

To test internationalisation of the price you will need to use a sandbox tester with an appropriate App Store territory.

If you run the app before you have logged in with a Sandbox tester then you will see the $US price by default. Also, note that you can't really test IAP in the simulator; You need to use a real device.

like image 100
Paulw11 Avatar answered Sep 27 '22 23:09

Paulw11


Sandbox accounts got handled differently since iOS 12. When you're running a development build from Xcode, the app will prompt for a fake sandbox AppleID as soon you initiate a purchase. After that first login, the app will know the right locale and therefore can display the appropriate prices for your in-app purchases. Before that, it will always display the prices in USD.

Source: https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox

like image 32
Adriano Brandão Avatar answered Sep 27 '22 21:09

Adriano Brandão