> For the complete documentation index, see [llms.txt](https://aatkit.gitbook.io/ios-integration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aatkit.gitbook.io/ios-integration/other/admob-custom-events.md).

# AdMob Custom Events

### AATAdMobMediationAdapter

AATAdMobMediationAdapter is a Gravite framework that implements [AdMob custom events](https://developers.google.com/admob/ios/custom-events/setup). It supports the following ad formats:

* Banners
* Fullscreen
* Rewarded Video
* Native Ads

### How AATAdMobMediationAdapter Works <a href="#how-aatadmobmediationadapter-works" id="how-aatadmobmediationadapter-works"></a>

* Publishers must prepare their AdMob dashboard by adding custom events to their mediation (See Google instructions [Add a custom event](https://support.google.com/admob/answer/3083407)).
* AATAdMobMediationAdapter Implements AdMob custom events delegates.
* The publisher requests an ad (Banner, Fullscreen, RewardedVideo or NativeAd) normally from GoogleMobileAds (To learn how to request an ad from GoogleMobileAds, please visit [Google’s documentation](https://developers.google.com/admob/ios/quick-start)).
* GoogleMobileAds internally calls AATAdMobMediationAdapter asking for an ad.
* AATAdMobMediationAdapter internally calls AATKit asking for an ad.
* When AATKit responds, AATAdMobMediationAdapter would notify GoogleMobileAds with the response using the AdMob custom events delegate methods. And in return, GoogleMobileAds will notify you of the response using the normal GoogleMobileAds callback.

### Integration steps <a href="#integration-steps" id="integration-steps"></a>

* In your AdMob dashboard, click on mediation on the left menu.
* Create a new mediation for each ad format (Please choose the proper ad unit you are using in your application in the GoogleMobileAds integration).
* Open the newly created mediation and add a custom event.
* Edit the custom event and add the proper class names from the following:
  * Banner class name: `AATAdMobBannerAdapter`.
  * Interstitial class name: `AATAdMobInterstitialAdapter`.
  * Rewarded video class name: `AATAdMobRewardedVideoAdapter`.
  * Native ads class name: `AATAdMobNativeAdAdapter`.
* Integrate AATAdMobMediationAdapter:
  * Cocoapods:
    * `pod 'AATKit/AATAdMobMediationAdapter'`
      * The above line will add only the basic required dependencies of AATAdMobMediationAdapter (AATKit-Core and GoogleMobileAds)
      * To add other ad networks, you must add them via AATKit by adding the following to your Podfile:
        * `pod 'AATKit/<SOME_NETWORK>'`
        * For more information about adding ad networks, please check [AATKit Cocoapods Integration Section](/ios-integration/start/setup/minimum-ios-version.md)
  * Swift Package Manager:

    * Follow the same SPM steps [here](https://aatkit.gitbook.io/ios-integration/start/setup/swift-package-manager).
    * In the last step, select `AATKit-Core`, `AATAdMobMediationAdapter` and other ad networks' adapters as needed.

    <figure><img src="https://3006681101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC07HayBzqyav5R2yFhOr%2Fuploads%2FVhzzzgwfUrAYy9p4dXe1%2FScreenshot%202025-04-16%20at%204.48.45%E2%80%AFPM.png?alt=media&amp;token=5c3bc804-b7f5-414b-815e-3531254af33f" alt=""><figcaption></figcaption></figure>
* Initialise AATKit as early as you can (in the AppDelegate `didFinishLaunchingWithOptions` for example) by calling:
  * `AATAdMobMediationAdapterManager.shared.initAATKit()`
* Integrate with GoogleMobileAds different ad formats following their [GMA documentation](https://developers.google.com/admob/ios/quick-start) (Please add the proper app ID to your info.plist under `GADApplicationIdentifier` key)
* In the `viewDidAppear()` of the viewController that requests an ad from Google, call the following `AATAdMobMediationAdapterManager` public API:

{% tabs %}
{% tab title="Swift" %}

```swift
AATAdMobMediationAdapterManager.sharedInstance().viewControllerDidAppear(self)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
[[AATAdMobMediationAdapterManager sharedInstance] viewControllerDidAppear:self];
```

{% endtab %}
{% endtabs %}

* In the `viewWillDisappear()` of the same viewController, call the `AATAdMobMediationAdapterManager` public API:

{% tabs %}
{% tab title="Swift" %}

```swift
AATAdMobMediationAdapterManager.sharedInstance().viewControllerWillDisappear()
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
[[AATAdMobMediationAdapterManager sharedInstance] viewControllerWillDisappear];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If your integration is successfully done, you should see logs with this pattern `AATAdMobMediationAdapter [LOG_LEVEL]:` while testing your integration. If not, please revisit your dashboard and the above steps again.
{% endhint %}

### Recommended Ad Networks

Here’s a list of the recommended ad networks and how to add them to your project:

| Admob       | `pod 'AATKit/Admob'`       |
| ----------- | -------------------------- |
| AppLovinSDK | `pod 'AATKit/AppLovinSDK'` |
| AppNexus    | `pod 'AATKit/AppNexus'`    |
| DFP         | `pod 'AATKit/DFP'`         |
| Inmobi      | `pod 'AATKit/Inmobi'`      |
| IronSource  | `pod 'AATKit/IronSource'`  |
| Prebid      | `pod 'AATKit/Prebid'`      |
| Pubnative   | `pod 'AATKit/PubNative'`   |
| Unity       | `pod 'AATKit/Unity'`       |
| Vungle      | `pod 'AATKit/Vungle'`      |
