SomeGuy
SomeGuy

Reputation: 9700

StoreKit change stores notification?

Is there a way to know when the user has changed stores with the StoreKit framework?

This is for if I have already pulled in a list of products and the user changes stores, so I can refresh the prices for the new store's locale.

Upvotes: 0

Views: 226

Answers (1)

SomeGuy
SomeGuy

Reputation: 9700

I found a solution, a bit of a 'trick', not as obvious as an explicit 'store did change notification'.

You can listen to the errors of each transaction in - paymentQueue:updatedTransactions:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for(SKPaymentTransaction* transaction in transactions)
    {
        NSError* transactionError = transaction.error;

        if(transactionError != nil && transactionError.code == SKErrorUnknown)
        {
            NSLog(@"User potentially switched stores");
            [self refreshAllProductInfo];
        }
    }
}

This may trigger during other errors, but so far I've only seen it to trigger when you change stores.

With this, when the user sees for example, $USD prices and then logs in with a $GBP account, the prices will refresh to their GBP versions.

Upvotes: 1

Related Questions