# 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:
    * &#x20;`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:&#x20;
        * `pod 'AATKit/<SOME_NETWORK>'`
        * For more information about adding ad networks, please check [AATKit Cocoapods Integration Section](../start/setup/minimum-ios-version)
  *   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&#x26;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'`         |
| ------------- | ---------------------------- |
| AdX           | `pod '`AATKit`/AdX'`         |
| AppLovinSDK   | `pod 'AATKit/AppLovinSDK'`   |
| AppNexus      | `pod 'AATKit/AppNexus'`      |
| CriteoSDK     | `pod 'AATKit/CriteoSDK'`     |
| DFP           | `pod 'AATKit/DFP'`           |
| Facebook      | `pod 'AATKit/Facebook'`      |
| FeedAd        | `pod 'AATKit/FeedAd'`        |
| Inmobi        | `pod 'AATKit/Inmobi'`        |
| IronSource    | `pod 'AATKit/IronSource'`    |
| OguryAds      | `pod 'AATKit/OguryAds'`      |
| PrebidSDK     | `pod 'AATKit/PrebidSDK'`     |
| Pubnative     | `pod 'AATKit/PubNative'`     |
| Smaato        | `pod 'AATKit/Smaato'`        |
| SmartAdServer | `pod 'AATKit/SmartAdServer'` |
| Unity         | `pod 'AATKit/Unity'`         |
| Vungle        | `pod 'AATKit/Vungle'`        |
