NicolasMiari NicolasMiari - 1 year ago 88
iOS Question

"Restore Transactions" Button behavior when there is nothing to restore

As discussed in this question and everywhere else, Apple now requires apps to include a means for the user to restore completed transactions for In App Purchases.

I'm all for this. The first version of my app somehow made it past review without it (I wasn't aware of this rule at the time, and/or it wasn't being enforced yet), but then I started receiving lots of e-mails from users asking about missing content (there is the Data Storage Guidelines too, and the heavy-downloadable contents aren't backed up).

So let's say I include a 'restore' button somewhere in my UI, that when tapped calls:

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

So far, so good. The user is prompted his AppleID and/or password, and the restoring process begins.

The problem I have is: If there is no transactions to restore, after the AppleID prompt essentially nothing happens in my app, and that may be confusing to the user or make the app look unresponsive or broken.

I would like to be able to display an alert view along the lines of "All purchases are up to date" or something.

Is there anything I can do in my Transaction Observer code to detect this case?

Does anybody think it would be a bad design, UX-wise?

Answer Source

You could also implement the following delegate functions:

-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error

Then you would know when the restore process was finished or if it failed. You can mix in the usage of queue.transactions.count in paymentQueueRestoreCompletedTransactionsFinished to see if any transactions was restored.

Remember to handle SKPaymentTransactionStateRestored in

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions

You might also want to handle the restored transaction(s) the way same as you did with SKPaymentTransactionStatePurchased the transaction(s).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download