Unpredictable delays in async responses from StoreKit 2

Hi,

I've been reported, and I've experienced myself, extremely slow responses from StoreKit 2 on boot.

I can reproduce the issue quite consistently with the iPhone, sometimes Transaction.currentEntitlements hangs for minutes even after the device has attained full Internet access.

My app is a VPN client, so there's certainly a chicken-and-egg situation, but I'm performing a basic test without the in-app validation in the packet tunnel provider. The tunnel starts fine on boot (on-demand), whereas the app takes ages to return from AppTransaction.shared and Transaction.currentEntitlements.

I guess this is caused by some network call inside the framework (maybe spoiled by the on-demand VPN?), but with no timeout, exceptions, logging, or future-proof fallback (appStoreReceiptURL is deprecated), I'm poking in the dark. It goes without saying, keeping the users waiting minutes to be credited for their purchases is a no-go.

I still can't find a reasonable workaround, but the frustrating part is that StoreKit 2 was supposed to make these things straightforward. At times, it doesn't feel "ready" and I spend on it a lot of time that I'd rather invest in the product.

Does this sound familiar to anybody?

Thanks in advance

Davide

Better said: a workaround I've come up with is a boot grace period during which the app and the tunnel operate (almost) unrestricted. After the grace period (2-3 minutes), I expect to validate against StoreKit with less chance of delays. It's an annoying complexity, but also one that seems to work.

Unpredictable delays in async responses from StoreKit 2
 
 
Q