robotmedia / RMStore

A lightweight iOS library for In-App Purchases
Apache License 2.0
2.43k stars 450 forks source link

Fix to ensure restoreTransactions completion callback is called #150

Open SeanBlahovici opened 9 years ago

SeanBlahovici commented 9 years ago

Inside RMStore, when the paymentQueue:updatedTransactions is called after a restore, a pendingRestoredTransactions counter was incremented/decremented as transactions were processed. However, in our case updateTransactions callback was called twice, so 2x the amount of transactions were added to the pendingRestoredTransactions counter. The problem was the counter was incremented twice but only decremented once for each transaction. WHen the code reached notifyRestoreTransactionFinishedIfApplicableAfterTransaction, the counter was checked but was not equal to zero, so the callback wasn't called, even though all the transactions were processed.

The fix was to use a MutableSet to store transaction identifiers that were pending restore, which prevents duplicate transactions to be handled. The callback is now always called after transactions are restored.

aplourde commented 9 years ago

I came up with the same solution ! :+1:

fulldecent commented 8 years ago

I have been using this version locally and confirm works.

hpique commented 8 years ago

Thanks for fixing this @SeanTB. Sorry it took so long to review. Would you mind taking out the style/code formatting changes out of the PR?

DonaldLawton commented 8 years ago

hpique, when do you expect to pull Sean's change into the main line?

hpique commented 8 years ago

@dlawton @SeanTB If I could merge the request from GitHub it'd been in already. I get "This branch has conflicts that must be resolved" though.

Can try to do this manually later this month as I'm abroad right now.

DonaldLawton commented 8 years ago

Some of my customers are reporting that although they attempt to restore purchases from my Mac app, the app doesn't actually recognize their prior purchases. Should this change address that issue?

Sent from my iPhone

On Jan 16, 2016, at 10:11 AM, Hermes Pique notifications@github.com wrote:

@dlawton @SeanTB If I could merge the request from GitHub it'd been in already. I get "This branch has conflicts that must be resolved" though.

Can try to do this manually later this month as I'm abroad right now.

— Reply to this email directly or view it on GitHub.

SeanBlahovici commented 8 years ago

Sorry for the delay. I fixed the conflicts. Please lemme know if I need to do anything else to allow this pull request to be merged.