> 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/sdk/domains-api/ads/googleadmob.showappsintossadmob.md).

# GoogleAdMob.showAppsInTossAdMob

### 기능 설명

`GoogleAdMob.loadAppsInTossAdMob`으로 미리 불러온 AdMob 광고를 사용자에게 노출해요. 광고 표시 과정에서 발생하는 이벤트가 `onEvent` 콜백으로 순차 전달돼요.

이벤트 스타일로 동작하며, 반환값으로 앱브릿지 콜백을 해제하는 함수를 받아요. 광고가 닫히면 꼭 해제해 주세요.

호출 전에 `GoogleAdMob.showAppsInTossAdMob.isSupported()`로 지원 여부를 확인할 수 있어요.

### 타입

```ts
GoogleAdMob.showAppsInTossAdMob(params: ShowAdMobParams): () => void;
```

**Params**

```ts
interface ShowAdMobParams {
  options: ShowAdMobOptions;
  onEvent: (event: ShowAdMobEvent) => void;
  onError: (error: unknown) => void;
}

type ShowAdMobOptions = {
  /** loadAppsInTossAdMob에서 사용한 것과 같은 광고 그룹 ID예요. */
  adGroupId: string;
};

type ShowAdMobEvent =
  | { 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` | 사용자가 리워드를 획득했어요 (리워드 광고 전용) |

**Response**

앱브릿지 콜백을 해제하는 함수(`() => void`)를 반환해요.

### 에러

광고 표시에 실패하면 `failedToShow` 이벤트 또는 `onError` 콜백으로 전달돼요. 리워드 광고는 `userEarnedReward` 이벤트가 발생했을 때만 리워드를 지급해야 해요. `dismissed`만으로는 사용자가 광고를 끝까지 봤는지 알 수 없어요.

### 예시 코드

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

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

button.addEventListener("click", () => {
  const cleanup = GoogleAdMob.showAppsInTossAdMob({
    options: { adGroupId: "AD_GROUP_ID" },
    onEvent: (event) => {
      switch (event.type) {
        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/sdk/domains-api/ads/googleadmob.showappsintossadmob.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.
