Multiple SKPaymentTransaction

江枫思渺然 提交于 2019-12-07 21:44:42

问题


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.


回答1:


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];



回答2:


You need to do [[SKPaymentQueue defaultQueue] finishTransaction:transaction] on each transaction to remove it from the queue.



来源:https://stackoverflow.com/questions/14740512/multiple-skpaymenttransaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!