> 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/guang-gao/showfullscreenad.md).

# showFullScreenAd

### 功能说明

`loadFullScreenAd`使用预先加载的集成全屏广告向用户展示。 `loadFullScreenAd`与在……中使用的相同的 `adGroupId`需要传递……。已经显示过的广告无法再次显示，因此在广告关闭后需要重新加载。

Toss应用 `5.227.0` 可在……及以上使用（`5.239.0` 及以上为 Toss Ad + AdMob 集成，低于此版本则仅限 AdMob）。调用前 `showFullScreenAd.isSupported()`可通过它确认是否支持。

### 类型

```ts
showFullScreenAd(params: ShowFullScreenAdParams): () => void;
```

**参数**

```ts
type ShowFullScreenAdParams = {
  options: ShowFullScreenAdOptions;
  onEvent: (event: ShowFullScreenAdEvent) => void;
  onError: (error: unknown) => void;
};

type ShowFullScreenAdOptions = {
  /** 与 loadFullScreenAd 中使用的广告组 ID 相同。 */
  adGroupId: string;
};

type ShowFullScreenAdEvent =
  | { type: "requested" }
  | { type: "show" }
  | { type: "impression" }
  | { type: "clicked" }
  | { type: "dismissed" }
  | { type: "failedToShow" }
  | {
      type: "userEarnedReward";
      data: { unitType: string; unitAmount: number };
    };
```

事件 `type` 值：

| type               | 说明               |
| ------------------ | ---------------- |
| `requested`        | 广告展示请求成功了        |
| `show`             | 广告已显示在屏幕上        |
| `impression`       | 广告曝光已记录（产生收益的时点） |
| `clicked`          | 用户点击了广告          |
| `dismissed`        | 用户关闭了广告          |
| `failedToShow`     | 广告展示失败了          |
| `userEarnedReward` | 用户获得了奖励（仅限奖励广告）  |

**响应**

用于解除 AppBridge 回调的函数（`() => void`）会被返回。

### 错误

如果广告展示失败 `failedToShow` 事件或 `onError` 会通过回调传递。奖励广告 `userEarnedReward` 只有在该事件发生时才应发放奖励。

### 示例代码

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

const AD_GROUP_ID = "AD_GROUP_ID";
const button = document.querySelector("#show-full-screen-ad");

button.addEventListener("click", () => {
  const cleanup = showFullScreenAd({
    options: { adGroupId: AD_GROUP_ID },
    onEvent: (event) => {
      switch (event.type) {
        case "impression":
          console.log("广告展示已记录（产生收益）");
          break;
        case "userEarnedReward":
          console.log(
            "获得奖励：",
            event.data.unitType,
            event.data.unitAmount,
          );
          break;
        case "dismissed":
          console.log("广告已关闭。请重新加载下一条广告。");
          cleanup();
          break;
        case "failedToShow":
          console.error("广告展示失败了。");
          cleanup();
          break;
      }
    },
    onError: (error) => {
      console.error(error);
      cleanup();
    },
  });
});
```


---

# 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/guang-gao/showfullscreenad.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.
