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 make sure the shortcut can be added, use the ysdk.shortcut.can_show_prompt() method:
1ysdk.shortcut.can_show_prompt(function (self, can_show)
2 if can_show then
3 -- Here you can show the button for adding the shortcut.
4 end
5end)
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 open the window, use the ysdk.shortcut.show_prompt() method:
1ysdk.shortcut.show_prompt(function (self, accepted)
2 if accepted then
3 -- Here you can grant a reward for adding the shortcut.
4 end
5end)
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.