Use this page with AI

Copy this into your coding assistant and add your request.

Read https://openiap.dev/docs/apis/end-connection 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]
See an example request →

endConnection

End connection to the store service. Call this when the owner of a manually managed connection unmounts or when the app-wide IAP session is no longer needed. Hook cleanup differs by framework; see the example below.

iOS: Cancels the StoreKit Transaction.updates task and clears in-memory caches. Apple docs. Android: Calls BillingClient.endConnection(); the client cannot be reused after this — call initConnection again to reconnect. Google docs.

React Native / Expo: if native teardown throws, the promise rejects without clearing the current connection or listener state, so the app can retry. React Native keeps registered listeners after teardown and reattaches them on the next initConnection. In Expo, a false result means the bridge has already cleared its connection state and listeners; reconnect and register fresh listeners before the next store call.

Godot / Apple providers: A failed disconnection keeps the current session and listeners available, including when the provider returns false. Retry teardown; successful disconnection clears both native and GDScript connection state.

SwiftUI: OpenIapStore cancels automatic purchase refreshes and ignores queued callbacks from the ended session. Reconnecting registers listeners before initialization so provider ownership replays reach the store. Failed teardown keeps the current connection and listeners; a provider returning false throws not-ended so you can retry.

Signature

swift
func endConnection() async throws -> Bool

Returns#

Promise<boolean> — true when the connection was closed cleanly.

Example

swift
let ended = try await OpenIapModule.shared.endConnection()
if !ended { print("Store teardown did not complete") }