I am using the in_app_purchase: 3.2.2 package in my Flutter app. I am implementing Offer Codes using the presentCodeRedemptionSheet() method from the InAppPurchaseStoreKitPlatformAddition.
The system sheet opens, and redemptions work, but I am facing three major hurdles because the sheet is a system UI and doesn’t provide a direct Future or callback.
1. Callback / Synchronization Problem Since presentCodeRedemptionSheet() it doesn’t return the transaction, I am relying on the purchaseStream. However, in Sandbox, the stream is extremely slow or doesn’t trigger until I manually call restorePurchases().
- Question: Is there a way to “listen” specifically for the sheet dismissal, or is a “silent restore” on app-resume the only reliable way to catch a redemption?
2. Identifying the Offer Price The PurchaseDetails object in the stream doesn’t contain the discounted price (e.g., if the code makes it $0.99 instead of $9.99).
- Question: How can I identify the specific price paid on the frontend? If not possible on the frontend, is the
offer_code_ref_nameIn the server-side receipt the only way to map the price?
3. Handling Cancellation: If a user opens the redemption sheet and then clicks “Cancel” or “X”, my app has no way of knowing. This makes it impossible to hide loading spinners or update the UI state.
- Question: Are there any workarounds to detect when the system redemption sheet is closed without a purchase?
What I’ve tried:
-
Setting up a global
purchaseStreamlistener (works, but inconsistent in Sandbox). -
Using
AppLifecycleStateto trigger a receipt refresh when the user returns from the system sheet.
Environment: