Skip to main content

Games

Usage

Open game

You can open a game using the method storyManager.openGame(gameInstanceId).

Parameters:

ParameterTypeDescription
gameInstanceIdstring | numberUnique identifier of the game
storyManager.openGame("gameId");

Close game

You can close the currently active game using the method storyManager.closeGame().

storyManager.closeGame();

Example

import { StoryManagerConfig, IASContainer, storyManager } from "@inappstory/react-sdk";
import { useEffect } from "react";

export const App = () => {
const openMyGame = async () => {
try {
await storyManager.openGame("{game-id}");
} catch(error: unknown) {
console.error(error)
}
}

useEffect(() => {
openMyGame()
}, []);

const storyManagerConfig: StoryManagerConfig = {
apiKey: "{projectToken}"
};

return (
<IASContainer
config={storyManagerConfig}
gameReaderOptions={{ /* yout appearance options */}}
/>
);
}

Customization

PropertyTypeDescriptionDefault Value
loader.default.colorstringMain loader color"white"
loader.default.accentColortringAccent color of the loader"transparent"
loader.customstring?Custom loader SVG or component as a stringnull
closeButtonPosition"start" | "end"Position of the close button"end"
closeButton.svgSrc.baseStatestringSVG icon for the close button-
game.backdropColortringBackground color of the game container"rgb(51, 51, 51)"
borderRadiusnumberBorder radius of the main container5
backdrop.opacitynumberOpacity of the backdrop while loading the game1
backdrop.backgroundstringBackground color of the backdrop"#1a1a1a"

Events

import { storyManager } from "@inappstory/react-sdk"

storyManager.on("startGame", (payload) => console.log(payload));


startGame

Description: Fired when a game starts.

Payload:

FieldTypeDescription
idstringUnique game ID

closeGame

Description: Fired when a game is closed.


eventGame

Description: Fired when a custom game event occurs.

Payload:

FieldTypeDescription
namestringName of the event
payloadanyEvent-specific payload