I\'m implementing In-App purchase feature with Restore button.
I have a brand new test user set up, without any payments made.
When you restore a transactions, there're two delegated methods:
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
The first one (paymentQueueRestoreCompletedTransactionsFinished) is called when all the transactions are restored. If you don't have any previous purchase it also calls this method because the restored worked fine but there's nothing to restore.
The other method (restoreCompletedTransactionsFailedWithError) is called when there's an error restoring the transaction.
If you need to show a message to the user telling him he doesn't have any transaction to restore you can use:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
Here you have a small snippet for this delegate:
//
// called when the transaction status is updated
//
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
restoredTransaction++;
break;
default:
break;
}
}
}
Then you can use the restoredTransaction variable to know if any transaction has been restored on paymentQueueRestoreCompletedTransactionsFinished