I have a StoreKit 2 transaction observer. I am making a purchase with StoreKit 1, by adding the payment to the SKPaymentQueue. I then want to listen to Transaction.updates
to get details about the transaction. My listener looks like this:
final class TransactionObserver {
private var updates: Task<Void, Never>?
init(delegate: TransactionObserverDelegate) {
updates = newTransactionObserverTask()
}
private func newTransactionObserverTask() -> Task<Void, Never> {
Task(priority: .utility) { [weak self] in
for await verificationResult in Transaction.updates {
await self?.handle(updatedTransaction: verificationResult)
}
}
}
private func handle(updatedTransaction verificationResult: VerificationResult<Transaction>) async {
...
}
}
For some reason, the handle(updatedTransaction:)
function never gets called on the first transaction. Only on subsequent renewals. Why? Am I doing something wrong? Shouldn't this call the listener when the transaction completes?