Storekit2 currentEntitlement function gives incorrect result in Sandbox testing after initial renewal?

I am using StoreKit2 to offer an auto-renewable subscription in an iOS app, and have observed inconsistent results from the currentEntitlement function during sandbox testing

To illustrate the issue I have created a function which prints out a timestamped entitlement, as well as subscription status using the following code.

	@MainActor func printSubscriptionInfo() async {
		let productId = "com.mycompany.autorenewablesubscription.subscription.id"
		print()
		print(Date.now)
		
		// Current entitlement
		if let currentEntitlement = await Transaction.currentEntitlement(for: productId) {
			if case .verified(let transaction) = currentEntitlement {
				print("Purchase date: \(transaction.purchaseDate)")
				print("Expiry date:   \(transaction.expirationDate!)")
			} else {
				print("Transaction not verified")
			}
		} else {
			print("No entitlement for \(productId)")
		}
				  
		// Subscription information
		let product = (availableProducts.filter { $0.id == productId }).first!
		guard let statuses = try? await product.subscription?.status, let status = statuses.first else {
			print("Unable to get subscription status")
			return
		}
		print("Subscription status: \(status.stateDescription)")
	}

The following shows the output of this function at various time points after a purchase, as well as the associated server notifications received.

Purchase completed: at 12:23:20

Function output at 12:23:40:

  • Purchase date: 12:23:09
  • Expiry date: 12:26:09
  • Subscription status: subscribed

Server notifications:

  • 12:23:13 - INTERACTIVE_RENEWAL
  • 12:25:20 - INITIAL_BUY

Function output at 12:26:18:

  • No entitlement for com.mycompany.autorenewablesubscription.subscription.id
  • Subscription status: subscribed

Server notifications:

  • 12:28:26 - INITIAL_BUY

Function output at 12:31:03

  • Purchase date: 12:29:09
  • Expiry date: 12:32:09
  • Subscription status: subscribed

The output of the function called after the first subscription renewal (ie at 12:26:09) shows no current entitlement, even though the subscription status is correct and there are no server notifications indicating expiry.

After the next expiry period has passed, the function returns correct results once more. Has anyone else noticed this behaviour?

Storekit2 currentEntitlement function gives incorrect result in Sandbox testing after initial renewal?
 
 
Q