本文介绍了使用未付款的用户恢复应用内购买的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程式中测试应用程式内购买。

I'm trying to test the in app purchase in my app.

当我使用购买应用程式购买的测试使用者一切工作正常。

When i restore the in app purchase with a test user who bought the in app purchase it all works fine.

但是,当我尝试使用没有的用户恢复应用内购买时,调用以下方法:

But when i try to restore an in app purchase with a user who didn't make the in app purchase before i expected the framework to call the following method:

-paymentQueue:restoreCompletedTransactionsFailedWithError:

但框架调用:

-paymentQueueRestoreCompletedTransactionsFinished:

像我的测试用户已经购买了在应用程序购买....

like my test user already bought the in app purchase....

这是正常的行为吗?

推荐答案

请参阅这里的答案:

您必须在事务观察器中处理它。

You'll have to handle it in transaction observer.

过程:

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

然后调用以下事务观察器:

Then following transaction observer is called:

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
    int thisIsTheTotalNumberOfPurchaseToBeRestored = queue.transactions.count;

    for (SKPaymentTransaction *transaction in queue.transactions)
    {
        NSString *thisIsProductIDThatHasAlreadyBeenPurchased = transaction.payment.productIdentifier;

        if([thisIsProductIDThatHasAlreadyBeenPurchased isEqualToString:product1ID])
        {
            //Enable product1 here
        }
    }
}

这篇关于使用未付款的用户恢复应用内购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 21:26