First transaction not appearing in Transaction.updates

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?

Replies

Hello. It appears you attempting to use a mix of original StoreKit and StoreKit for initiating transactions and monitoring, which is not supported. It's recommended to use one or the other when initiating transactions and monitoring for updates and new transactions. https://developer.apple.com/documentation/storekit