> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/sdk/domains-api/you-xi/game.getuserprofile.md).

# Game.getUserProfile

> 函数式 API `getGameCenterGameProfile`也能用它实现相同功能。

### 功能说明

获取 Toss 游戏中心的个人资料信息。如果没有个人资料， `statusCode`为 `'PROFILE_NOT_FOUND'`会返回对应的响应。如果有个人资料，会一并提供昵称和个人资料图片 URL。

Toss App Android/iOS `5.221.0` 可在上述环境中使用。在无法接收到桥接响应的环境中， `undefined`可能会返回。

### 类型

```ts
Game.getUserProfile(): Promise<GameCenterGameProfileResponse | undefined>;
```

**参数**

无

**响应**

```ts
type GameCenterGameProfileResponse =
  | { statusCode: "PROFILE_NOT_FOUND" }
  | {
      statusCode: "SUCCESS";
      nickname: string;
      profileImageUri: string;
    };
```

### 示例代码

```js
import { Game } from "@apps-in-toss/web-framework";

const button = document.querySelector("#load-profile");
const nicknameElement = document.querySelector("#nickname");

button.addEventListener("click", async () => {
  try {
    const profile = await Game.getUserProfile();

    if (profile?.statusCode === "SUCCESS") {
      nicknameElement.textContent = profile.nickname;
      console.log(profile.nickname, profile.profileImageUri);
    } else {
      console.log("没有个人资料。");
    }
  } catch (error) {
    console.error(error);
  }
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/sdk/domains-api/you-xi/game.getuserprofile.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
