Restoring an in app purchase with a user who never paid for it

。_饼干妹妹 提交于 2019-12-03 14:34:54
Mesbah

See the answer here: iOS in-app-purchase restore returns many transactions

You'll have to handle it in transaction observer.

In short, you start restore process with:

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

Then following transaction observer is called:

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
    int thisIsTheTotalNumberOfPurchaseToBeRestored = queue.transactions.count;

    for (SKPaymentTransaction *transaction in queue.transactions)
    {
        NSString *thisIsProductIDThatHasAlreadyBeenPurchased = transaction.payment.productIdentifier;

        if([thisIsProductIDThatHasAlreadyBeenPurchased isEqualToString:product1ID])
        {
            //Enable product1 here
        }
    }
}

Try MKStoreKit framework https://github.com/MugunthKumar/MKStoreKit It is pretty good, well maintained framework. I have a few apps with in-app purchases. Never had any issues like that.

@Tibidabo I wouldn't recommend MKStoreKit because it has a big hole in restore purchased items functionality.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!