问题
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