Use this page with AI
Copy this into your coding assistant and add your request.
Read https://openiap.dev/docs/apis/open-redeem-offer-code and https://openiap.dev/llms.txt. Follow the reading instructions, detailed reference, and linked guides relevant to my task before making changes.
Inspect my existing project and reuse its framework and conventions. Ask me for missing product decisions. Implement the requested behavior and run the applicable checks.
Show the working result, the commands and actual test results, and any remaining limitations. Keep your explanation brief.
My request: [describe what customers should be able to do]openRedeemOfferCode
Open the platform's offer/promo code redemption flow so the user can enter a code.
Available in OpenIAP 3.3.0 / openiap-apple 3.3.0 / openiap-google 3.4.0.
iOS: Presents the App Store offer code redemption sheet. Xcode 27+ builds running on iOS 27+, Mac Catalyst 27+, or visionOS 27+ resolve the verified redeemed purchase; older sheet APIs resolve null after presentation. Apple docs. Android: On Google Play builds, launches the Play Store redeem page (https://play.google.com/redeem) and resolves null; the billing client does not need to be initialized. Meta Horizon and Amazon Appstore have no equivalent redemption surface and resolve null without launching anything.
Redeemed purchases are delivered through the standard purchase listeners. Register purchaseUpdatedListener before calling, and always reconcile with getAvailablePurchases when the app resumes — the complete reconciliation sequence is in the Offer Code Redemption guide.
Signature
func openRedeemOfferCode() async throws -> PurchaseIOS?Returns#
Promise<Purchase | null> — the redeemed Purchase when the provider reports the transaction immediately. Official Apple providers return it on Apple 27+ runtimes from Xcode 27+ builds; community providers can also return a purchase. Verify a community receipt before granting access. Other official outcomes resolve null:
- iOS 15–26 / visionOS 1–26: the system sheet was presented, but that API path cannot return the transaction directly.
- Google Play: the Play Store redeem page was launched; the redemption completes outside the app.
- Meta Horizon / Amazon Appstore: no redemption flow exists, so nothing was launched.
Throws#
Presentation or launch failures reject with the provider’s error code. Apple platforms without the redemption sheet (macOS, tvOS, watchOS) throw feature-not-supported. Official Horizon and Amazon providers resolve null without launching a flow; a community provider without this handler throws feature-not-supported. Godot emits purchase_error and returns null on failed or unsupported redemption.
Example
let purchase = try await OpenIapModule.shared.openRedeemOfferCode()
if let purchase {
print("Redeemed purchase:", purchase.productId)
}Live example: expo-iap · react-native-iap · flutter_inapp_purchase · kmp-iap