Skip to main content

Games

The React Native SDK can open interactive games in a full-screen reader and receive gameplay events.

Preloading games

To warm up games assets ahead of time, call preloadGames:

storyManager.preloadGames();

Opening a game

Call showGame on storyManager with the game ID:

const success = await storyManager.showGame('GAME_ID');

Game events

Subscribe to game lifecycle and in-game custom events with onGameEvent. The listener receives an event object with event.body:

storyManager.onGameEvent((event: any) => {
console.log('Game event:', event.body);
});
EventPayloadDescription
startGame{ id: string, gameID: string }Game starts loading / rendering
eventGame{ id: string, gameID: string, name: string, payload: any }Custom event sent from inside the game
closeGame{ id: string, gameID: string }Game reader is closed
gameFailure{ id: string, gameID: string, message: string }Game failed to load or run

Call to action from games

External links or actions triggered inside a game are routed to storyLinkClickHandler with src set to CTASource.GAME_READER and payload CTAGameReaderPayload ({ url, gameInstanceId }). See Call To Action.