问题
Apple states that all apps using in-app purchases have to put this
[[SKPaymentQueue defaultQueue] addTransactionObserver:self.observer];
at the beginning of the app to handle for any successful sale that for some reason the device has not received the confirmation to release the content.
I am trying to test this, trying to call the phone when it is about to finish the transaction, quitting the application or stopping Xcode before the transaction finish, but for some reason, even when I quit Xcode, iOS appears to continue handle the transaction and the app never receives the SKPaymentTransactionStateRestored. The app always receive the SKPaymentTransactionStatePurchased and appears to be fail proof (perhaps the new iOS 4 handles that better than the 3.2 when StoreKit was released).
My question is: do you guys know any situation I can create here to generate the failure and receive the SKPaymentTransactionStateRestored when the app starts? I need to test if the app is working well for this kind of situation.
thanks
回答1:
SKPaymentTransactionStateRestored
is only for when you call restoreCompletedTransactions
(so a user can restore their in-app purchases on a new device). If you quit the app without calling finishTransaction:
, the transaction stays in the queue and you will get SKPaymentTransactionStatePurchased
again.
来源:https://stackoverflow.com/questions/6720616/iphone-in-app-purchase-testing-for-failure