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

為{幸葍}努か 提交于 2019-12-03 17:31:06

问题


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 block the UI, and update my UI to reflect that the transaction state is deferred. But what am I supposed to place in the method -(void)transactionDeferred:(SKPaymentTransaction *)transaction to disregard the transaction for the time being?

Do I only have update the UI? Also what should the content of the UI be? Do I need to replace the price label with something like "Your purchase is deferred"? I don't think there is a way to test this, at least I haven't seen anything about it with my sandbox test account. If there was a way to go through the process and see how it works, it would make a lot more sense to me.


回答1:


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];




回答2:


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;
        }
    }
}


来源:https://stackoverflow.com/questions/26187148/what-should-the-app-do-in-response-to-a-deferred-skpaymenttransaction

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