What should the app do in response to a deferred SKPaymentTransaction?

前端 未结 2 1095
忘了有多久
忘了有多久 2021-02-04 06:17

I have in-app purchases in my app, and new to iOS 8 are \"deferred\" transactions, partially described in a tech note

I understand what it does and that I need to not bl

相关标签:
2条回答
  • 2021-02-04 06:51

    What I am doing is:

    1. Stopping indicator animation
    2. Activating buy and restore buttons
    3. Showing an alert:

    Waiting For Approval
    Thank you! You can continue to use Altershot while your purchase is pending an approval from your parent.

    I watched WWDC 14 video. Apple says you should't block UI and allow to click on buy button again. I think we need this in case parent miss alert, so child can send one more.

    What I know is that we should not call following method for deferred transactions:

    [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

    0 讨论(0)
  • 2021-02-04 07:06

    The code bellow will allow you to check if the product ID you want to sell is in deferred mode. Use it to update the UI accordingly.

    if ([[SKPaymentQueue defaultQueue].transactions count] > 0) {
        for (SKPaymentTransaction *transaction in [SKPaymentQueue defaultQueue].transactions) {
            if ([@"your.product.id"  isEqualToString:transaction.payment.productIdentifier]) {
                if (transaction.transactionState ==  SKPaymentTransactionStateDeferred) {
                    // update UI that you are still waiting for parent approval. You'll get "PURCHASED" if parent approved or "FAILD" if parent declined or 24 hours passed since request.
                }
                break;
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题