I implemented StoreKit into my application. What I noticed is that for some of my test accounts, there are multiple SKPaymentTransaction
's in the paymentQueue. This is causing the SKPaymentTransactionObserver
to be called multiple times with a SKPaymentTransactionStatePurchased
This problem seems to manifest more when I stop the app mid upgrade, or put the application in the background.
I am not sure what is causing the multiple payments, or is this expected behavior? Also, am making sure to finish all purchased transactions after they are validated.
When a transaction is completed, cancelled, or failed, you need to remove it from the queue, or you will have multiple transactions still active in the payment queue. This is what is causing your problem. To fix this, whenever a transaction is completed, cancelled, or failed, call the following.
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
You need to do [[SKPaymentQueue defaultQueue] finishTransaction:transaction]
on each transaction to remove it from the queue.
来源:https://stackoverflow.com/questions/14740512/multiple-skpaymenttransaction