Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
635 views
in Technique[技术] by (71.8m points)

iphone - iOS in-app-purchase restore returns many transactions

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...