StoreKit 2 - Use-case for Transaction.unfinished

The documentation for Transaction.updates states, "If your app has unfinished transactions, the listener receives them immediately after the app launches. Without the Task to listen for these transactions, your app may miss them." My app is currently following these instructions: I start a background Task to await results from Transaction.updates in application(didFinishLaunchingWithOptions:). However, I've noticed that when using StoreKit testing on the Simulator, my app does not receive transactions via Transactions.updates if they occur while the app is not running. For example, if I subscribe to a monthly subscription and quit the app before the first renewal, when I fire the app back up, the "StoreKit Transactions" window in Xcode shows a new unfinished transaction, and that transaction is not delivered via Transaction.updates. I know that Transaction.updates is wired up correctly because if I let renewals happen while the app is running, they are delivered.

I see two probable explanations:

  1. The simulator and/or StoreKit testing just aren't properly supporting this scenario
  2. I'm actually supposed to be querying Transactions.unfinished at some point

I'm really unsure about #2 because I haven't seen it used in any sample code, nor found its intended usage discussed in any docs. Furthermore, this sample project exhibits the same exact issue: https://developer.apple.com/documentation/storekit/in-app_purchase/implementing_a_store_in_your_app_using_the_storekit_api

Anyone have any insights here?

Hi, thanks for reaching out. What you're describing isn't the expected behavior, Transaction.updates should emit any transactions which occurred while your app was not running. Could you please file a feedback report and include a sample project which reproduces the issue, and a sysdiagnose of the device you're testing on after you reproduce the issue?

To provide more context on Transaction.updates vs. Transaction.unfinished: Transaction.updates is primarily intended to allow you to handle transaction updates that occur while your app is running. If you have a use case where you specifically need to check for unfinished transactions, I would recommend using Transactions.unfinished. Transaction.unfinished will always contain any unfinished transactions, compared to Transaction.updates which only emits unfinished transactions once at app launch.

Thanks for your reply! I just filed FB12048960; for public reference, here's what it says:

Unfinished transaction not delivered via Transaction.currentEntitlements after cold app boot

This may actually be a StoreKit testing issue, but I’m not sure. I’ve described the issue [here]. Here are the steps to reproduce:

  1. Run this Apple-provided sample app on either the simulator or a real device: https://developer.apple.com/documentation/storekit/in-app_purchase/implementing_a_store_in_your_app_using_the_storekit_api
  2. Open the StoreKit Transactions window for monitoring
  3. Purchase a monthly subscription (by default, the SKDemo app is set up with “Monthly Renewal Every 30 Seconds”)
  4. After purchasing the subscription, close the app and take it out of memory before the next Monthly renewal (i.e. within 30 seconds of the initial purchase)
  5. Relaunch the app 35-40 seconds after the initial Monthly subscription purchase.
  6. At this point, note that the renewal transaction is a) in the “Unfinished” state, and b) was not delivered to the app via the Transaction.currentEntitlements async sequence. Notably, the fact that the sample app displays the subscription as still active actually seems to be a bug: shouldn’t the .autoRenewable case verify that transaction.expirationDate isn’t in the past?
StoreKit 2 - Use-case for Transaction.unfinished
 
 
Q