2

How is the default priceLocale for SKProducts set (if user is not logged into iTunes account)? Is it based on the iTunes Connect account where I set up the in-app purchase products? Is there any way to change the default priceLocale for when the user is not logged into an iTunes account on the device? Or is it out of my control?

I am working on an app that uses in-app purchase to display different products to the user based on their location. The way I am doing this is to get an array of all the products using SKProductsRequestDelegate method and passing it to a completion handler block:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray * skProducts = response.products;
    ...
    _completionHandler(YES, skProducts);
    _completionHandler = nil;
}

The completion handler takes a BOOL (success) and the products array. It iterates through the array and shows only the products that match the priceLocale in a tableview:

[[AnnualSubscriptionIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
    if (success)
    {
        NSMutableArray * productsForCountry = [[NSMutableArray alloc] init];
        for (SKProduct * product in products)
        {
            NSLocale * storeLocale = product.priceLocale;
            NSString * storeCountry = (NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode);

            // Country code for the product is the last 2 characters in the productIdentifier string
            // E.g. annual_subscription_au
            NSString * productCountry = [[product.productIdentifier substringFromIndex:product.productIdentifier.length - 2] uppercaseString];

            if ([productCountry isEqualToString:storeCountry])
                [productsForCountry addObject:product];
        }

        _products = productsForCountry;
        [self.tableView reloadData];
    }
    [self.refreshControl endRefreshing];
}];

This works fine when the user is logged into an iTunes account. However, if the user is not logged into iTunes, the default priceLocale for all products is AU. The client requires the default to be US (if not logged into iTunes, or if the user's country is not in a predetermined list).

I tried setting the device locale (Settings > General > International > Region Format) but this has no effect on the default store locale.

Product shown in simulator (before logging into iTunes account):

// NSLog output:
// productIdentifier: annual_subscription_au 
// priceLocale (iTunes Connect): AU 
// currentLocale (Device): US

Try to purchase annual_subscription_au with CN iTunes Connect test account:

  • Purchase fails with error (as expected) and shows alert
  • Hit OK to reload the product list
  • Now the priceLocale for the products is CN, and I can show the correct list of products to the user

Output after logging in with Chinese (CN) test account:

// NSLog output:
// productIdentifier: annual_subscription_cn
// priceLocale (iTunes Connect): CN 
// currentLocale (Device): US

Clearly, device locale has no impact on the default priceLocale. Even if the device locale is set to US, the default priceLocale is still AU.

The only thing I found related to this was a comment on this answer asking how the "home pricing" is set, but no one responded.

Community
  • 1
  • 1
Steph Sharp
  • 11,462
  • 5
  • 44
  • 81
  • Try changing the store your iTunes account is connected to and then logging out (or login with a US account then logout). It may be retained from the last login. – Wain May 27 '13 at 06:30
  • @Wain I think you might be right. When testing on the device it seems to retain the country from the last login. Although when testing in the simulator it always defaults to AU, because you cant log into an iTunes account (in Settings) in the simulator. – Steph Sharp Jun 11 '13 at 01:42
  • AU is set coz may be the testaccount you have set is for AU...the default currency shows in app purchase is the nation currency you have set test account for. – 9to5ios Jul 23 '13 at 20:02

0 Answers0