Skip to main content

Module store

Module store 

Source
Expand description

StoreKit 2 in-app purchases as Bevy resources + messages.

Flow:

  1. On iOS, read AppStoreEnvironment to choose non-production service configuration for Xcode, sandbox, or unavailable execution. Wait while it is AppStoreEnvironment::Pending. The resource is absent off iOS.
  2. Insert StoreConfig with your product ids. The plugin calls into the backend once, which fetches products and the current entitlements.
  3. Read StoreProducts for prices/titles to render your store UI.
  4. Send PurchaseRequest / RestoreRequest to act.
  5. React to PurchaseCompleted / EntitlementsChanged, or just read the Entitlements resource — owns(id) is the source of truth and covers fresh purchases, restores, and already-owned-on-relaunch alike.

Structs§

Entitlements
The set of currently-entitled product ids (non-consumables + active subs). owns(id) is the gate to use everywhere — it stays correct across purchase, restore, and relaunch.
EntitlementsChanged
Emitted when the entitlement set changes. Read Entitlements for the new state.
ProductInfo
One purchasable product, as reported by StoreKit (localized price/title).
ProductsUpdated
Emitted when the catalogue state or contents change.
PurchaseCompleted
Emitted once per purchase attempt when it reaches a terminal state.
PurchaseRequest
Request a purchase of the given product id.
RestoreRequest
Request restoration of past purchases (AppStore.sync()).
StoreConfig
The product ids to offer. Insert before or after adding the plugin; the store initializes on the first frame it sees a non-empty config.
StorePlugin
StoreProducts
The fetched catalogue. Mirrors the backend; read-only to consumers.

Enums§

AppStoreEnvironment
The environment reported by the verified StoreKit 2 app transaction.
ProductsState
Loading state of the product catalogue.
PurchaseOutcome
Terminal result of a purchase attempt.