RanLearns RanLearns - 3 months ago 22
iOS Question

Testing localized in-app purchases

Running the app with the Scheme set to another language does not affect the SKProduct received from iTunes in testing. The only way I’ve found to affect change is to create a new Sandbox Tester User in iTunes Connect with an iTunes Store for each... and every... language you might want to test.

Then - you should NOT login with that user on your device through Settings. Run your app and login with the test user when asked.

This successfully got my phone to be defaulting to the App Store for a different country.

But still, when I printed to the console each SKProduct’s .localizedTitle, .localizedDescription, and .price - only the price was translated to the different country’s numbers. The title and description remained in English (I’m developing in the United States). All the languages are set up in iTunes Connect.

When I click to purchase an in-app, the system pop up is in English: "Confirm Your In-App Purchase" and then "Do you want to buy one ____ for ___?" and "Cancel" and "Buy" buttons all in English. The first blank is filled in by Display Name that I set in iTunes Connect. But it is still using the English version. And the second blank is filled in with the price, which IS SHOWING in the language of the Test User's store. [separate issue: Japanese shows the Yen symbol and price. Spain shows the Euro symbol and price. Mexico shows the Dollar sign with the Peso price.]

So only the price translates for my Sandbox Tester account. Anybody know how to get the title in a different country’s language during testing? Not only do I want to make sure that it will look right to people in each country I've localized the app for, I’d like to set the SKProducts' titles as labels on buttons in my app to launch the in-app purchases. I could set these through the Localizable.strings file but would prefer to pull it from the SKProduct since I've already entered that information through iTunes Connect.

Thanks for any help!


Here is what I've been able to figure out, to the best of my ability. This is pretty tricky to test... sometimes needed to run the app 3 or 4 times and load the list of SKProducts over and over again before a localizedDescription would change to the language I was trying to test.

I was trying to figure out if these are controlled by logging in with a Sandbox Test User that was created with an iTunes Store set to another country? Or by the iPhone's language chosen in Settings?

SKProduct's .price, SKProduct's .localizedTitle, SKProduct's .localizedDescription, and the system pop up "Do you want to buy one ____ for ___?" / "Cancel" / "Buy"

It seems to me that to properly get all the values for each language, you need BOTH to have changed the phone's system language AND to log in with a Sandbox Test User created for the country's App Store.

To populate my button text, I did the following:

let formatter = NSNumberFormatter()
formatter.numberStyle = .CurrencyStyle
formatter.locale = productName.priceLocale
let cost = formatter.stringFromNumber(productName.price)!
labelForButton = "\(cost) " + productName.localizedDescription