Copy this into your coding assistant and add your request.
Read https://openiap.dev/docs/apis/get-available-purchases 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]
Get the user's purchases held by the store — owned non-consumables, active subscriptions, and any pending transactions not yet finished.
iOS:onlyIncludeActiveItemsIOS: true reads Transaction.currentEntitlements (active non-consumables and live subscriptions); false iterates Transaction.all, the full StoreKit 2 history including refunded and revoked entries. The default differs by layer; see Parameters. Apple docs. Android: Calls BillingClient.queryPurchasesAsync for both INAPP and SUBS and merges. Only returns purchases still owned by the user. Google docs.
alsoPublishToEventListenerIOS(optional, boolean, default false) — iOS. Re-emit results on purchaseUpdatedListener.
onlyIncludeActiveItemsIOS(optional, boolean; default true in React Native, Expo, Flutter, and MAUI, false in Swift, KMP, and Godot) — iOS.true uses Transaction.currentEntitlements (active only); false uses Transaction.all. Pass it explicitly when the difference matters.
includeSuspendedAndroid(optional, boolean, default false) — Android (Billing 8.1+). Include suspended subscriptions in the result. Suspended entries (isSuspendedAndroid === true) should NOT grant entitlements — direct the user to the subscription center to resolve payment first.
In SDK APIs that surface failures and in Godot's result-bearing API, an empty purchase list is an authoritative store result: the store query completed and found no purchases. Native transaction verification, serialization, or bridge decoding failures reject the whole query (or return success = false) with an error such as billing-response-json-parse-error; OpenIAP does not return a partial list.
Godot keeps get_available_purchases() for compatibility, so that array-only method still maps a failure to an empty array. Code that restores purchases, grants entitlements, or clears cached ownership must call get_available_purchases_result() and check success before using purchases. Never revoke or clear entitlements after a failed query.
Example
swift
let purchases = try await OpenIapModule.shared.getAvailablePurchases(nil)