I'm using the iOS simulator with a StoreKit configuration file. I can see that there have been transactions while the app has been closed, but my StoreKit 2 listener is never called with those updates to be able to finish them When I open my app from a cold start.
I've added a listener on application(_:didFinishLaunching:launchOptions:)
like this:
func startObservingTransactions() {
task = Task(priority: .background) {
for await result in Transaction.updates {
if case .verified(let transaction) = result {
await transaction.finish()
}
}
}
}
But the Transaction.updates
loop never gets called (have added breakpoints to check). It's only ever called when a purchase is made, or subsequent transaction renewals when the app is open. Only then it will get the previously unfinished transactions.
Steps to reproduce:
- Create an app with a StoreKit config file (with sped up transactions) to purchase an item
- Make a purchase then quit the app
- Wait for a bit for more transactions to be made while the app is closed.
- Open the app from a cold start and none of the transactions will be finished by the listener in your app. Cancel the subscription via the transaction manager.
- Close and open the app from a cold start. The first transaction will be finished by the listener but none of the others will be.
In Apple's docs it says
If your app has unfinished transactions, the listener receives them immediately after the app launches
Why is this not the case?