> 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/ads/loadfullscreenad.md).

# loadFullScreenAd

### 功能说明

预先加载综合插屏广告。优先展示 Toss Ad，在不可用的环境中会自动切换到 AdMob，因此可以稳定地展示广告。必须在展示广告之前调用。

会根据 Toss App 版本而不同地工作：

| Toss App 版本                   | 支持功能                                           |
| ----------------------------- | ---------------------------------------------- |
| `5.239.0` 及以上                 | Toss Ad + AdMob 集成（优先 Toss Ad，不可用时自动切换到 AdMob） |
| `5.227.0` 及以上 \~ `5.239.0` 以下 | 仅显示 AdMob 广告                                   |
| `5.227.0` 以下                  | 不支持                                            |

调用前 `loadFullScreenAd.isSupported()`可通过它确认是否支持。

### 类型

```ts
loadFullScreenAd(params: LoadFullScreenAdParams): () => void;
```

**Params**

```ts
type LoadFullScreenAdParams = {
  options: LoadFullScreenAdOptions;
  onEvent: (event: LoadFullScreenAdEvent) => void;
  onError: (error: unknown) => void;
};

type LoadFullScreenAdOptions = {
  /** 是广告组 ID。请填入在 Apps in Toss 控制台中获取的值。 */
  adGroupId: string;
};

type LoadFullScreenAdEvent = {
  type: "loaded";
};
```

**Response**

用于解除 AppBridge 回调的函数(`() => void`）作为返回值。

### 错误

如果广告加载失败 `onError` 错误会通过回调传递。若在不支持的版本中调用， `onError`会传递错误，因此在调用前请 `isSupported()`进行确认。

### 示例代码

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

let isAdLoaded = false;

function prepareAd() {
  if (!loadFullScreenAd.isSupported()) {
    console.warn("当前环境无法使用插屏广告。");
    return;
  }

  const cleanup = loadFullScreenAd({
    options: { adGroupId: "AD_GROUP_ID" },
    onEvent: (event) => {
      if (event.type === "loaded") {
        console.log("广告加载完成");
        isAdLoaded = true;
        cleanup();
      }
    },
    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/ads/loadfullscreenad.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.
