> 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.loadappsintossadmob.md).

# GoogleAdMob.loadAppsInTossAdMob

### 기능 설명

Google AdMob 광고를 미리 불러와서, 광고가 필요한 시점에 바로 보여줄 수 있도록 준비해요. 광고가 성공적으로 로드되면 `onEvent` 콜백으로 `type: 'loaded'` 이벤트가 전달돼요.

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

### 타입

```ts
GoogleAdMob.loadAppsInTossAdMob(params: LoadAdMobParams): () => void;
```

**Params**

```ts
interface LoadAdMobParams {
  options: LoadAdMobOptions;
  onEvent: (event: LoadAdMobEvent) => void;
  onError: (error: unknown) => void;
}

type LoadAdMobOptions = {
  /** 광고 그룹 ID예요. 앱인토스 콘솔에서 발급받은 값을 넣어주세요. */
  adGroupId: string;
  /** 광고 요청 출처를 구분하는 값이에요. */
  referrer?: string | null;
};

type LoadAdMobEvent = {
  type: "loaded";
  data: LoadAdMobResult;
};

type LoadAdMobResult = {
  /** 광고 그룹 ID예요. */
  adGroupId: string;
  /** 광고 ID예요. */
  adUnitId: string;
  /** 광고 로드 응답 정보예요. */
  responseInfo: {
    /** 광고 네트워크 응답 정보 배열이에요. */
    adNetworkInfoArray: AdNetworkResponseInfo[];
    /** 로드된 광고 네트워크 응답 정보예요. */
    loadedAdNetworkInfo: AdNetworkResponseInfo | null;
    /** 광고 응답을 식별하는 ID예요. */
    responseId: string | null;
  };
};

type AdNetworkResponseInfo = {
  /** 광고 소스 ID예요. */
  adSourceId: string;
  /** 광고 소스 이름이에요. */
  adSourceName: string;
  /** 광고 소스 인스턴스 ID예요. */
  adSourceInstanceId: string;
  /** 광고 소스 인스턴스 이름이에요. */
  adSourceInstanceName: string;
  /** 광고 네트워크 클래스 이름이에요. */
  adNetworkClassName: string | null;
};
```

**Response**

구독 해제 함수(`() => void`)를 반환해요. 호출하면 이후 도착한 이벤트와 에러가 콜백으로 전달되지 않아요.

### 에러

광고 로드에 실패하면 `onError` 콜백으로 에러가 전달돼요. 토스앱 웹뷰 환경이 아닌 곳에서 호출하면 호출 시점에 에러가 발생해요.

### 예시 코드

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

function loadAd() {
  if (!GoogleAdMob.loadAppsInTossAdMob.isSupported()) {
    console.warn("현재 환경에서는 AdMob 광고를 사용할 수 없어요.");
    return;
  }

  GoogleAdMob.loadAppsInTossAdMob({
    options: { adGroupId: "AD_GROUP_ID" },
    onEvent: (event) => {
      if (event.type === "loaded") {
        console.log("광고 로드 완료:", event.data.responseInfo.responseId);
      }
    },
    onError: (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/sdk/domains-api/ads/googleadmob.loadappsintossadmob.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.
