IAP: Receives `paymentQueueRestoreCompletedTransactionsFinished:` callback with unfinished transactions

僤鯓⒐⒋嵵緔 提交于 2019-12-11 18:55:09

问题


Some times I get this callback

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue

Even before I receive this

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions

I don't even get to say finishTransaction:. I find this superweird. I've all this time been assuming paymentQueueRestoreCompletedTransactionsFinished: wouldn't be triggered before I had marked every unfinished transaction as finished.

Is this expected behavior?

This is what I found in documentation

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue Description Tells the observer that the payment queue has finished sending restored transactions. This method is called after all restorable transactions have been processed by the payment queue. Your application is not required to do anything in this method.

I'm not sure what it means.


回答1:


I found the header file itself to be most clear on this part.

@interface SKPaymentQueue : NSObject
...
// Array of unfinished SKPaymentTransactions.  Only valid while the queue has observers.  Updated asynchronously.
@property(nonatomic, readonly) NSArray *transactions;

@end

@protocol SKPaymentTransactionObserver
// Sent when all transactions from the user's purchase history have successfully been added back to the queue.
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
...
@end

These two in conjunction make it unambiguous. paymentQueueRestoreCompletedTransactionsFinished is triggered once StoreKit has added all transactions to SKPaymentQueue. -[SKPaymentQueue transactions] only has a list of unfinished transactions.

I think the docs could have been more clear about this.



来源:https://stackoverflow.com/questions/22303699/iap-receives-paymentqueuerestorecompletedtransactionsfinished-callback-with

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