Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restoreCompletedTransactions never calls updatedTransactions in StoreKit

I've been banging my head against the wall for a few days with this, since everything used to work fine, but now that I've moved to Mountain Lion, XCode 4.5 and iOS5.1 and iOS6, this issue came along and I thought it might be related to the configuration switch.

I call [[SKPaymentQueue defaultQueue] restoreCompletedTransactions] and moments later paymentQueueRestoreCompletedTransactionsFinished is called, but there is no sign of any call to updatedTransactions. It's like the request got lost in space.

I'm also having a possibly related problem with purchases. If I try to repurchase an item using makePurchase, which from what I understand should also lead to a SKPaymentTransactionStateRestored, I get the "Already purchased.. download" message followed by the dreaded "Cannot connect to iTunes store..." with a "PaymentTransactionStateFailed" error code 2. What is error code 2?

The item is a normal non-consumable in-app puchase, and this happens when testing the StoreKit in sandbox mode.

I'm seeing others on this forum with similar issues with the only reply being that this is an intermittent bug i the StoreKit. Is this still the most plausible case?

Any news on this would be appreciated.

like image 480
user1823538 Avatar asked Nov 15 '12 13:11

user1823538


1 Answers

If you clear the purchase history more info here, or the user has never made a purchase before. paymentQueue:updatedTransactions will never be called. You need to add paymentQueueRestoreCompletedTransactionsFinished. Also to be sure check

queue.transactions.count == 0

All code here:

public func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
            print("paymentQueueRestoreCompletedTransactionsFinished",queue.transactions.count)
            if queue.transactions.count == 0 {
                //call FailedNotification
            }
        }
like image 80
kiril kiroski Avatar answered Oct 07 '22 01:10

kiril kiroski