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. If teardown resolves false, the bridge has already cleared its connection state and listeners; reconnect and register fresh listeners before the next store call.

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") }