Desktop shortcut
Using a native dialog box, you can offer the user to add a shortcut link to their desktop that leads to your game.
Before displaying the dialog box, make sure that the option is available.
Checking whether adding a shortcut is available
Whether the option is available depends on the platform, internal browser rules, and Yandex Games restrictions. To verify that the shortcut can be added, use the ysdk.shortcut.can_show_prompt()
method:
ysdk.shortcut.can_show_prompt(function (self, can_show)
if can_show then
-- Here you can show the button for adding the shortcut.
end
end)
Opening a dialog box
After checking, you can show a button (or another UI element) in the game and make it call a dialog box for adding a shortcut when clicked. To call the dialog, use the ysdk.shortcut.show_prompt()
method:
ysdk.shortcut.show_prompt(function (self, accepted)
if accepted then
-- Here you can grant a reward for adding the shortcut.
end
end)
The first time the method is called, a shortcut is created for the Yandex Games catalog. If it already exists, a shortcut with a link to the game will be created.