MugunthKumar/MKStoreKit — Issue #28: Empty the saved onComplete and onCancel handlers as soon as either happens!
Author: davidgrimes
Created: 2011-10-08 20:39:11+00:00
State: open

Hi,

Just figured out that MKStorekit ends up calling the last, previously registered onComplete block with the buyFeature call, when transactions are restored.

Let me explain:

We have a nonconsumable feature called Paging expansion. This gets triggered with buyFeature when the user wants to get more results. When this buyFeature is called, the block passed for onComplete gets assigned and stored. Suppose the user:

1. cancels the purchase,
2. and then goes and presses a Restore transactions button (which we've placed in our Settings screen),
3. and they have pending transactions that are restorable, then they are restored and "remembered".

The problem is that due to the earlier buyFeature call, the onComplete block gets triggered even with the restoreTransaction call.

The onComplete block (at least the way we've coded it) is expected to have the context that it was called in alive, but since the user navigated out, and went into the settings screen, the self object in our case has been deallocated, and the onComplete crashes the app!

Perhaps the better approach would be to nil the onComplete and onTransactionCanceled when either event happens, so that they cannot get called beyond the scope of success/failure that the buyFeature modals into.