Knowing when a user clicked the cancel button during an In-App purchase

I write the code for purchases in the application and using the "Processing ..." view with an activity indicator to block the "Buy Now" button after the start of the purchase. However, how can you tell when the user clicks the Cancel button because these warnings are displayed in AppStore.app?

Is there a delegate method that is called when these cancel buttons are clicked? Or is it a question of your view, which again becomes firstResponder ? What am I missing here?

If you donโ€™t think itโ€™s possible, look at the "I Am T-Pain" application ... they do something very similar and reject their appearance immediately after clicking the cancel button.

alt text http://i37.tinypic.com/1t4ead.png

+4
source share
1 answer

Assuming everything is set up correctly, you should have an object that implements SKPaymentTransactionObserver, which will receive callbacks for transaction / failure / cancellation success.

In my example, the purchaseManager object mentioned in this call

  [[SKPaymentQueue defaultQueue] addTransactionObserver:purchaseManager]; 

When the user cancels the payment, you should receive a callback with the transaction status canceled:

 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchased: [self completeTransaction:transaction]; break; case SKPaymentTransactionStateFailed: // THIS IS THE STATE YOU SHOULD SEE [self failedTransaction:transaction]; break; ... } 

You can use this callback to reject your view, etc.

+8
source

All Articles