Games
The RN SDK can open interactive games in a full-screen reader.
Opening a game
Call showGame on the storyManager with the game ID:
storyManager.showGame(gameID);
Game events
Games report their lifecycle through the same event bus as the story reader. Subscribe with storyManager.on(...):
storyManager.on('eventGame', (payload: any) => {
console.log('eventGame', {payload});
// payload.result holds the game outcome
});
| Event | Payload | Fires when |
|---|---|---|
gameReaderWillShow | {} | The game reader is about to open |
startGame | {id, gameID} | A game starts |
eventGame | {id, gameID, name, payload} | The game sends a custom in-game event |
finishGame | {id, gameID, result} | A game finishes (result holds the outcome) |
gameComplete | {data, result, url} | A completed game returns its final data |
closeGame | {id, gameID} | A game is closed |
gameReaderDidClose | {} | The game reader is dismissed |
gameFailure | {id, gameID, message} | A game fails to load or run |
tip
Remove listeners when the component unmounts to avoid duplicate handlers.