alexgophermix
alexgophermix

Reputation: 4279

iOS transactions not in SKPaymentTransactionStateRestored state during restore flow

I've been having a lot of trouble with the in app purchase restore flow. It seems that a very small subset of my users cannot restore properly. I used to have my own custom built implementation but I found it harder to debug and decided to switch over to RMStore.

This is not a bug with RMStore - it has existed before I switched over to using it.

Going through my analytics it seems that some users hit the restore success case BUT never successfully trigger the premium state. Restore code is below.

[[RMStore defaultStore] restoreTransactionsOnSuccess:^(NSArray *transactions){
    if ([SKPaymentQueue defaultQueue].transactions.count == 0) {
        [self.tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"RESTORE"
                                                                   action:@"failure"
                                                                    label:@"no_purchases"
                                                                    value:nil] build]];
        [self fail:@"There are no items available to restore at this time."];
    } else {
        // seems to be triggered every time a successful restore made if there are items
        [self.tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"RESTORE"
                                                                   action:@"success"
                                                                    label:@"items_in_queue"
                                                                    value:nil] build]];
        for (SKPaymentTransaction *transaction in transactions) {
            if (transaction.transactionState == SKPaymentTransactionStateRestored) {
                if ([transaction.payment.productIdentifier isEqualToString:(NSString*)productID]) {
                    [Utils setPremium:YES];
                }
            }
        }

        [self success];
    }
} failure:^(NSError *error) {
    //...
}];

My only guess here is that the transactionState of the affected user's transaction is not SKPaymentTransactionStateRestored. I have confirmed with some of the affected users and they have all purchased the premium version. What other state could their transaction be in?

Should I be finishing any transactions in this case that are not SKPaymentTransactionStateRestored via [[SKPaymentQueue defaultQueue] finishTransaction:transaction];? Would this recover users that were stuck in this state?

Edit: This is a non-consumable purchase and the id has been the same since it was created.

Upvotes: 0

Views: 105

Answers (0)

Related Questions