---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.4
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/sdk-shortcut.md
  - https://yandex.com/dev/games/doc/hi/sdk/sdk-shortcut.md
  - https://yandex.com/dev/games/doc/ko/sdk/sdk-shortcut.md
  - https://yandex.com/dev/games/doc/ru/sdk/sdk-shortcut.md
  - https://yandex.com/dev/games/doc/tr/sdk/sdk-shortcut.md
  - https://yandex.com/dev/games/doc/vi/sdk/sdk-shortcut.md
  - https://yandex.com/dev/games/doc/zh/sdk/sdk-shortcut.md
  - href: zh/sdk/sdk-shortcut.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/zh/llms.txt

# 桌面快捷方式

<!-- source: zh/_includes/script-common.md -->
<!-- source: zh/_includes/script/index-js.md -->

<!-- endsource: zh/_includes/script/index-js.md -->

<!-- source: zh/_includes/script/requirements-js.md -->

<!-- endsource: zh/_includes/script/requirements-js.md -->

<!-- source: zh/_includes/script/image-modal-js.md -->

<!-- endsource: zh/_includes/script/image-modal-js.md -->
<!-- endsource: zh/_includes/script-common.md -->

通过使用原生对话框,您可以为用户提供将游戏链接添加为桌面快捷方式的选项。


在显示对话框之前,请先确保该选项可用。


## 检查是否可以添加快捷方式 {#can-add-shortcut}

选项是否可用,取决于设备、内部浏览器规则以及 [Yandex Games](https://yandex.com/games/){.external} 平台的限制。

为确保可以添加快捷方式,请使用 `ysdk.shortcut.canShowPrompt()` 方法：

```javascript showLineNumbers
const ysdk = await YaGames.init();

const prompt = await ysdk.shortcut.canShowPrompt();

if (prompt.canShow) {
  // 您可以在此处显示用于添加快捷方式的按钮。
}
```

## 打开对话框 {#dialog-add-shortcut}

完成检查后,您可以在游戏内显示一个按钮(或其他界面元素),点击该按钮即可打开添加快捷方式的对话框。

要调用该对话框,请使用 `ysdk.shortcut.showPrompt()` 方法：


```javascript showLineNumbers
YaGames.init().then(ysdk => ysdk.shortcut.showPrompt()).then(result => {
  console.log('Shortcut created?:', result);
  if (result.outcome === 'accepted') {
    // 您可以在此处提供添加快捷方式的奖励。
  }
});
```

首次调用该方法时，将为 [Yandex Games](https://yandex.com/games/){.external} 目录创建快捷方式。如果快捷方式已经存在，将创建一个包含游戏链接的快捷方式。


---

<!-- source: zh/_includes/sdk-support.md -->
{% note info %}

技术支持团队将协助您将已完成的游戏发布到 Yandex 游戏平台。关于开发和测试方面的具体问题，其他开发人员将在[Discord 频道](https://discord.com/invite/wU4p3whr4T){.external}中进行回答。

{% endnote %}

如果您遇到 Yandex Games SDK 方面的问题或有其他问题想要咨询，请联系支持部门：

<!-- source: zh/_includes/button-chat.md -->
<a href="https://yandex.com/chat/#/user/a4fa5c06-75db-9b38-6eea-b1673785f7d5">
  <span class="button">写入聊天信息</span>
</a>
<!-- endsource: zh/_includes/button-chat.md -->
<!-- endsource: zh/_includes/sdk-support.md -->
