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

前端 未结 2 1089
忘了有多久
忘了有多久 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 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;
            }
        }
    }
    

提交回复
热议问题