I have 2 apps that use StoreKit2 to handle purchases auto renewing subscriptions. It is implemented according to Apple's example on this page.
On Sandbox, it works correctly.
In production, it works correctly for most users (I can see by the sales numbers) but a small percentage of users report that the system purchase dialog is not appearing at all.
Upon further investigation it turns out that the dialog sometimes only appears after minutes of waiting, sometimes up to 5 minutes. When it finally appears, it works correctly.
On my own devices with production versions (downloaded from the App Store) I also get the delay. Other apps (by other developers) show the dialog immediately. Therefore I am guessing there may be something wrong with my code.
What may cause the purchase() dialog to appear after such a long waiting time?