Skip to content

Store State

The SDK connects to the store, reconnects when the connection drops, and retries in the background when the store cannot be reached. Most games never need to look at the store’s state: Purchase() waits for a reconnecting store on its own, and answers StoreUnavailable when it cannot reach it in time.

Reading the state

StoreState says whether the store can sell right now:

StoreLifecycleState state = playOpsSDK.InAppPurchases().StoreState;
StateMeaning
NotInitializedThe store has not been started. Configurations are not initialized yet, or the configuration has no products.
ConnectingThe store is being started for the first time.
ReadyThe store is connected and can sell.
UnavailableThe store was started, but it is unreachable right now. The SDK is already retrying.

Unavailable does not mean the store is gone for good. The SDK keeps retrying in the background, and the state goes back to Ready when it reconnects.

When the store gives up

StoreUnavailable is raised when the store is unreachable and the SDK has stopped retrying. Brief outages are retried internally and never raise it, so it is the one signal that it is time to tell the player rather than wait:

inAppPurchases.StoreUnavailable += () =>
{
ShowStoreDownMessage();
};

The SDK tries again when the app comes back to the foreground, when the network comes back, and when the player starts a purchase. The event can be raised again later in the same session if those attempts fail too.