I am working on restoring purchases, So I have few doubts
1) How to show restore button
I have shown it on top left corner, and on click of it I call this function
- (IBAction)restorePurchases:(id)sender
{
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];
}
But What if the user has not purchased anyItem or what if the user has purchased an item but not deleted and reinstalled the app, Whether I still need to show the restoreButton, and if yes, on click of it what should be its behaviour.
2) Now, If I have made a purchase of an item and delete the app and reinstall the app, and click on restore button, it calls this function
- (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];**
default:
break;
}
}
}
But now, suppose I dont but anyitem and simply click restore button, it asks me for my apple Id, after entering apple Id, nothing happens, It doesnt call the above function, I want to know why this is happening.
Also, I want to display a message to user that there are no items to restore, so how can I do that.
I searched for this and their is one delegate function which will be called,if there are no transactions to retore
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
}
What I have done is that here I have checked if there are no items to restore, I will display as no items to restore, whether I am right in this approach.
Regards Ranjit