IPHONE: Storekit – aborting transactions restoring (in-app purchase)

iphone

As "suggested" by Apple, I have put a button on my application, to restore old successful transactions, in my in-app purchase application.

The problem is this. The user clicks the button and the application starts restoring the transactions. If the application is closed for some reason during this process, the process will continue the next time the application runs.

In my case, restoring all transactions can take some time, specially if the user has many transactions. So, when the application starts again, I see a black screen and the application do not loads until the last transaction is restored.

Apparently the process of restoring the transactions hangs the application that do not loads until it finishes.

As Apple recommends, I have this, on the beginning of my app…

CustomStoreObserver *observer = [[CustomStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

This is useful for restoring interrupted sales but in my case is causing a pain when the question is restoring old transactions already bought.

I would like to be able to abort any restoration of old transactions that could run, when the program starts and just allow them while toe app is running.

Any way to do that?

Best Answer

Can you not create the store observer in a different thread/run loop so that it doesn't block the UI thread?

Failing that, only add the transaction observer after you have made a splash screen visible?

Related Topic