iOS in-app-purchase restore returns many transactions

杀马特。学长 韩版系。学妹 提交于 2019-11-28 01:56:23

问题


When I am restoring my previous purchase. Storekit is calling updateTransations with large number of previous transactions. Don't know why it is returning these large amount like 100, 200 ,245, 360, 650 seems like random in every restore.

Is that happen in the sandbox only? If no, what should be the criteria of selecting the item. I have many items with the same product id?


回答1:


There have been a lot of complaints about using updateTransactions for restoring. The below code will work but it requires the user to enter in their username and password. (for now developers have been sticking this in a IBAction call which requires a button)

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

Then the below delegate is called.

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
     for (SKPaymentTransaction *transaction in queue.transactions) 
    {
        if ([myItem.productID isEqualToString:transaction.payment.productIdentifier])
        {
            myItem.purchased = YES;
        }
    }
}

I want to know how to do this without putting a "restore" button on my interface if there are no items that need to be restored.



来源:https://stackoverflow.com/questions/10912442/ios-in-app-purchase-restore-returns-many-transactions

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