---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/defold/game-review.md
  - https://yandex.com/dev/games/doc/hi/sdk/defold/game-review.md
  - https://yandex.com/dev/games/doc/ko/sdk/defold/game-review.md
  - https://yandex.com/dev/games/doc/ru/sdk/defold/game-review.md
  - https://yandex.com/dev/games/doc/tr/sdk/defold/game-review.md
  - https://yandex.com/dev/games/doc/vi/sdk/defold/game-review.md
  - https://yandex.com/dev/games/doc/zh/sdk/defold/game-review.md
  - href: zh/sdk/defold/game-review.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-review}

要检查是否能够请求游戏评级，请使用 `ysdk.feedback.can_review()` 方法。

```lua
ysdk.feedback.can_review(callback: function)
```

`callback: function` —— 被调用方法的处理函数。形式如下：

```lua
function(self, can_review: boolean, reason: string|nil): nil
```

- `can_review: boolean` —— 是否可以请求。
- `reason: string|nil` —— 不能请求评论的原因。可能的取值：
    - `NO_AUTH` —— 用户未登录。
    - `GAME_RATED` —— 用户已对游戏评级。
    - `REVIEW_ALREADY_REQUESTED` —— 请求已发送，现在等待用户操作。
    - `REVIEW_WAS_REQUESTED` —— 请求已发送，并且用户已执行操作（给出评级或关闭了弹出窗口）。
    - `UNKNOWN` —— 未发送请求，因为 Yandex 端发生了错误。

## 评级请求示例 {#review-request}

{% note alert %}

每次游戏只能请求一次游戏评级。您在执行该请求前必须使用 `ysdk.feedback.can_review()` 方法。

{% endnote %}

要邀请用户对游戏进行评分，请使用方法 `ysdk.feedback.request_review()`。

```lua
ysdk.player.open_auth_dialog(callback)
```

`callback: function` —— 被调用方法的处理程序。格式如下：

```lua
function(self, feedback_sent: boolean): nil
```

- `feedback_sent: boolean` —— 用户是否评价了游戏（true），或者关闭了弹出窗口（false）。

**示例**

```lua showLineNumbers
ysdk.feedback.can_review(function (self, can_review, reason)
  if can_review then
    ysdk.feedback.request_review(function (self, feedback_sent)
      if feedback_sent then
        print("Reward")
      end
    end)
  else
    print(reason)
  end
end)
```

---


<!-- source: zh/_includes/button-git.md -->
<a href="https://github.com/yandex-games-plugins/defold">
  <span class="button">存储库</span>
</a>
<!-- endsource: zh/_includes/button-git.md -->
