Best Approach for finishing transactions with long content downloads

Hello,


We have an app which sells extra content as individual IAP items. The content packs may be quite large, and for some players these take a long time to download. Some of our players are in remote Scottish Isles or far off the beaten track in Australia, and for these people a simple download can take 20 mins. For this reason, we've implemented background downloads. So a typical example is a download will complete when the player has closed the app, and gone on to something else. My question is, what is the best way to finish the SKPaymentTransaction in this situation?


On purchase, we get the callback with 'SKPaymentTransactionStatePurchased' and we start the download.

Much later, when the download has been completed, we need to tell StoreKit's SKPaymentQueue to finishTransaction.

But if the app has been terminated we no longer have a reference to the SKPaymentTransaction.


So whould we maintain our own dictionary of SKPaymentTransactions that are in progress, and preserve this across app launches, so we have a copy of the SKPaymentTransaction so that we can finish it much later?


Or should we rely on another StoreKit callback when the app is re-launched (perhaps the SKPaymentTransactionStatePurchasing) and compare that to recently completed downloads, and finish the transaction that way?


What is the best approach in this scenario?


Thank you.

Replies

I believe things are different for an 'SKDownload' situation.


If you are not using SKDownload then you can finish the transaction whenever you want and monitor how the download is going yourself.


But if you are using SKDownload you cannot finish the transaction until the download is complete. If something happens to interrupt the SKDownload you can restart the process simply by adding a transaction observer. Once added, the transaction will cause a call to updatedTransactions with state 'purchased' just like before and you can restart the download process as you wish with the new transaction object.

>Best Approach for finishing transactions


Speaking of.... 'Technical Note TN2387 In-App Purchase Best Practices / Finish the transaction' ...?