Events

You can track events that occur when the user clicks certain buttons in the game.

Available events and associated methods:

enum ESdkEventName {
    EXIT = 'EXIT',
    HISTORY_BACK = 'HISTORY_BACK'
}

ysdk = {
    EVENTS: {
        EXIT: ESdkEventName.EXIT,
        HISTORY_BACK: ESdkEventName.HISTORY_BACK
    },

    dispatchEvent(eventName: ESdkEventName, detail?: object): Promise<unknown> {},

    onEvent(eventName: ESdkEventName, listener: Function): () => void {}
};

HISTORY_BACK event

To track clicks on the Back button, use the following method:

ysdk.onEvent(ysdk.EVENTS.HISTORY_BACK, () => {
    // Showing the custom game dialog to the user with the options
    // to confirm exiting the game, going to the internal settings, store, and so on
});

Alert

The event is available only if the game is running on a TV.

EXIT event

If the user confirms exiting the game in the custom dialog box that pops up after clicking Back, the game must send an exit event. To do this, use the following method:

ysdk.dispatchEvent(ysdk.EVENTS.EXIT);

Note

Our support team can help publish finished games or WebApps on Yandex Games. If you have any questions about development or testing, ask them in the Discord channel.

If you are facing an issue or have a question regarding the use of Yandex Games SDK, please contact support:

Write to chat