Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IAP iOS UIAlertView cancel button

I'm using StoreKit for implement purchacing in my app. My question is how can I hendle UIAlertView when IAP dialog appear. I need to process Cancel button. I need to know when I press cancel and notify my system about this. I need to process cancel button that on alert view that request my user and password data.

For example if user tap on cancel button it should invoke some callback method.

like image 302
Matrosov Oleksandr Avatar asked Jul 22 '12 17:07

Matrosov Oleksandr


1 Answers

You can handle it in SKPaymentTransactionObserver

Something like this

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                break;
            case SKPaymentTransactionStateFailed:
            {
               if (transaction.error.code == SKErrorPaymentCancelled)
               {
                   //user cancelled purchase
                }
             }  
                break;
            case SKPaymentTransactionStateRestored:
                break;
            default:
                break;
        }
    }
}
like image 122
msk Avatar answered Oct 14 '22 05:10

msk