I'm using Xcode v7.2 and Obj-c. I'm adding different languages to an existing iOS app. The main problem is that the SKProduct localizedTitle (Display Name on iTC) always comes back in English. I can show the price properly localized and formatted. I have ready many similar issues on SO and have tried their solutions but it doesn't seem to be working for me (for example: this and this).
Desired outcome:
- Show 3 buttons to user; each button has a different title and price.
- Dynamically change the IAP's Display Name & price by updating it in iTC only (so I don't have to update the code each time I want a change).
- Because of #2, I can't hard-code the IAP name or price on the button.
- Pull the localized title (Display Name on iTC) and price from iTC to use as the text label on the buttons.
Here's what I have setup already:
- Created test users on iTC and assigned them different stores:
- Setup the IAP's on iTC and added the languages and Display Names:
Code to grab SKProduct localizedTitle and price from iTC
[[FirstDrawIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) { if (success) { storeProducts = products; SKProduct *product = (SKProduct *)storeProducts; //Format price priceFormatter = [[NSNumberFormatter alloc] init]; [priceFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; [priceFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; //Iterate thru the buttons using tipButton Outlet Collection for (int i = 0; i < [self.tipButton count]; i++) { UIButton *button = [[UIButton alloc] init]; button = self.tipButton[i]; //product = storeProducts[i]; product = products[i]; //Set the price locale [priceFormatter setLocale:product.priceLocale]; //Localize the button title and append the price NSString *btnTxt = [product.localizedTitle stringByAppendingString:@" "]; NSString *price = [priceFormatter stringFromNumber:product.price]; NSString *newBtn = [btnTxt stringByAppendingString:price]; NSLog(@"\nID: %@, Price: %@, Button: %@",[product localizedTitle], price, btnTxt); //Set button title [button setTitle:newBtn forState:UIControlStateNormal]; } }
Create new Xcode scheme so the test device Language, Location and Region are set to the desired country
- Sign out of App Store on Xcode simulator (from Settings). When running tests in the simulator, I'll initially see my app in the correct language but the text on the buttons is in English. This is because I haven't changed the App Store location yet. I tap the IAP purchase button and it prompts me to login.
- I login using my test user for that country. I stop the app then run it again.
Result: I correctly see the IAP price for that country but I don't see the button's title correctly localized. The button's title is still in English. This happens with each language I've setup.
Can anyone spot what I'm doing wrong here? Do I have the wrong assumption that SKProduct.localizedTitle does not return the iTC Display Name for that language (App Store)? Any help would be appreciated, thanks.