开发者

restoreCompletedTransactions broken?

Is restoreCompletedTra开发者_开发百科nsactions 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 {
}


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


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

Your code should be something like:

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


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.


Products Consumable cannot be restored.

Products Non-Consumable can be restored.

Check if your products are type Non-Consumable.


You should not need the updatedTransactions callback if you are getting paymentQueueRestoreCompletedTransactionsFinished. The "queue" has a list of your transactions and you can loop thru those.

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


Make sure your build number in Xcode does not have a space in it. For example "1.0 Beta". With a space updatedTransactions will not be called. Also receipt verification can fail.


Two additional points which weren't mentioned here:

  1. If you are using Firebase make sure you add an observer before you initialize Firebase, https://firebase.google.com/docs/analytics/get-started?platform=ios
  2. Make sure that you call finishTransaction method while handling the purchase. You won't be able to restore not completed transactions.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜