Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restoreCompletedTransactions broken?

Is restoreCompletedTransactions broken in SDK 4.3 ?

I am trying to restore my auto-renewable subscription. It is not resulting in callback to updatedTransactions. Here is my code.

 {
 ....
 [appDelegate.inapp loadStore];

 [[SKPaymentQueue defaultQueue]  restoreCompletedTransactions];
 ....
 }

Expecting callback to updatedTransactions, but do not receive it.

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
     NSLog(@"IN updatedTransactions,  transaction.transactionState");

    for (SKPaymentTransaction *transaction in transactions)
    {

        switch (transaction.transactionState)
        {
            ...
            ...
            case SKPaymentTransactionStateRestored:
            NSLog(@"IN updatedTransactions,  SKPaymentTransactionStateRestored");
            [self restoreTransaction:transaction];
            break;

        }
    }
}

But I do receive call to this at the end.

-(void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
}
like image 845
okgo Avatar asked Apr 11 '11 23:04

okgo


4 Answers

This can still(1) happen if you're testing in the Sandbox environment and your Test User is broken. Create a new Test User in iTunes Connect, and try again.

It's not entirely clear what makes Test Users go bad; from what I gather, using them once in a non-sandbox environment can do this, but there may be other reasons as well.

(1) Xcode 4.3.1, iOS SDK 5.1

like image 158
Andreas Ley Avatar answered Dec 04 '22 20:12

Andreas Ley


Make sure to add observer before using [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

Your code should be something like:

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

like image 20
Alaa Eldin Avatar answered Dec 04 '22 20:12

Alaa Eldin


I was able to get around this but its very odd. On my testing device im getting bugged by iTunes to log in to multiple test user accounts. I usually just hit cancel and test my restore with the account that I want to restore. This time I decided to enter the password for these other annoying login boxes. It worked and next time I relaunched my app and hit restore it did not bug me to log in to the other test accounts, just the one I was testing. I proceeded with the restore and it did restore the items I wanted to see.

Id say were experinecing stupid sandbox issues and also we know apple has changed in app purchasing in general. Keep playing around with it, you'll get it to work out.

Hope this helps you out.

like image 32
Ryan Thomas Avatar answered Dec 04 '22 19:12

Ryan Thomas


Products Consumable cannot be restored.

Products Non-Consumable can be restored.

Check if your products are type Non-Consumable.

like image 45
Rondinelli Morais Avatar answered Dec 04 '22 20:12

Rondinelli Morais