Desktop shortcut

Using a native dialog box, you can offer the user to add a shortcut to the home screen — a link to the game.

Before showing the dialog box, make sure the option is available.

Checking whether adding a shortcut is available

The availability of the option depends on the device, the browser's internal rules, and the platform restrictions of Yandex Games.

To verify that the shortcut can be added, use the ysdk.shortcut.canShowPrompt() method:

1const ysdk = await YaGames.init();
2
3const prompt = await ysdk.shortcut.canShowPrompt();
4
5if (prompt.canShow) {
6    // Here you can show the button for adding the shortcut.
7}

Opening a dialog box

After checking, you can show a button (or another interface element) in the game that opens the dialog box for adding a shortcut when clicked.

To call the dialog, use the ysdk.shortcut.showPrompt() method:

1const ysdk = await YaGames.init();
2
3const result = await ysdk.shortcut.showPrompt();
4
5if (result.outcome === 'accepted') {
6    // Here you can grant a reward for adding the shortcut.
7}

On the first call of the method, a shortcut to the Yandex Games catalog is created. If it already exists, a shortcut with a link to the game itself will be created.


Note

Support staff help you publish a ready-made game on the Yandex Games platform. For applied questions about development and testing, other developers will answer in the Discord community.

If you encounter a problem or have a question while using the Yandex Games SDK, contact support:

Write to chat