SKPaymentTransactionStateRestored doesn't get called when In App purchase is being restored

青春壹個敷衍的年華 提交于 2019-12-03 12:46:16

[queue restoreCompletedTransactions] will trigger SKPaymentTransactionStateRestored state, where queue is SKPaymentQueue. You should not expect this to be called after your user confirms transactions. Instead user would be warned by the device if he had already purchased the product.

I've a clue. The method (paymentqueue:updatedTransactions:) and especcially the SKPaymentTransactionStateRestored: state is getting called, when i create a SKProductRequest and start loading it.

SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithArray: productIdentifiers]];
        request.delegate = self; 
        [request start];

I'll have a look on Apples solution and see, if i can find any differences.

You can implement paymentQueueRestoreCompletedTransactionsFinished: to determine if a restore was finished:

http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKPaymentTransactionObserver_Protocol/Reference/Reference.html

NicTesla

In case, it's not solved yet, you might do it with a logical trick. When the restore is beeing triggered, remember it with a boolean flag (or a enum state, if you prefer) and show a different message when the SKPaymentTransactionStatePurchased is beeing triggered. You might implement the two delegate methods

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue

and

- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error

to find out, when the restore has been finished. And to be save in this case, you might not let the user make any purchases, while the restore is in progress. You could show the user something like this, so the user sees, that something is currently happening.

This is what i did and it works for me.

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