Knowing when user has pressed cancel buttons during In-App purchase

一个人想着一个人 提交于 2019-12-03 16:58:32

Assuming everything is setup correctly you should have an object implementing SKPaymentTransactionObserver which will receive callbacks for transaction success/failure/cancel.

In my example it's the purchaseManager object mentioned in this call

  [[SKPaymentQueue defaultQueue] addTransactionObserver:purchaseManager];

When the user cancels a payment you should receive a callback with a transaction state of cancelled:

- (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 dismiss your view etc...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!