> For the complete documentation index, see [llms.txt](https://aatkit.gitbook.io/rtbsdk-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/rtbsdk-ios-integration/other/admob-custom-events.md).

# AdMob Custom Events

### Summary

GraviteRTBAdMobMediationAdapter 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 GraviteRTBAdMobMediationAdapter 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)).
* GraviteRTBAdMobMediationAdapter Implements AdMob custom events delegates.
* The publisher requests an ad (Banner, Fullscreen or NativeAd) 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 GraviteRTBAdMobMediationAdapter asking for an ad.
* GraviteRTBAdMobMediationAdapter internally calls RTBSDK asking for an ad.
* When RTBSDK responds, GraviteRTBAdMobMediationAdapter will 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>

#### Step 1: Set Up Mediation in the AdMob Dashboard

* Log in to your AdMob dashboard and navigate to **"Mediation"** in the left menu.
* Create a new mediation group for each ad format you plan to use.
  * Ensure you select the correct **ad unit** used in your application during the **GoogleMobileAds** integration.
* Open the newly created mediation group and add a **Custom Event**.
* Edit the custom event and specify the appropriate class name for your ad format:
  * Banner ads: `GraviteRTBAdMobMediationAdapterBanner`.
  * Interstitial ads: `GraviteRTBAdMobMediationAdapterInterstitial`.
  * Native ads: `GraviteRTBAdMobMediationAdapterNativeAds`.
  * Rewarded Video: `GraviteRTBAdMobMediationAdapterRewardedVideo`
* In the **"Mediation"** section under the **"Waterfall Sources"** tab, click on **"Manage Mapping"** and add the following data to the **"Parameter"** field:
  * `{"appId": "<iTunes_app_id>", "placementId": <integer_placement_id>, "sellerId": "<seller_id>"}`.
  * Replace `<iTunes_app_id>`, `<integer_placement_id>`, and `<seller_id>` with the appropriate values for your app.
  * This data is used by the **Gravite RTBSDK** to load ads:
    * `appId` and `placementId` are required.
    * `sellerId` is optional.

#### Step 2: Add Gravite AdMob Mediation Adapter

* Integrate GraviteRTBAdMobMediationAdapter
  * Cocoapods:
    * Open your **Podfile** and include the following line:
      * `pod 'RTBSDK/GraviteRTBAdMobMediationAdapter'`
      * This will automatically add the necessary dependencies: **RTBSDK** and **GoogleMobileAds**.
  * Swift Package Manager:

    * Follow the same SPM steps [here](https://aatkit.gitbook.io/rtbsdk-ios-integration/start/setup/swift-package-manager).
    * In the last step, select `RTBSPM` and `GraviteRTBAdMobMediationAdapter`

    <figure><img src="https://1806721687-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhvdEa4oC4SqyuprOskue%2Fuploads%2Fgit-blob-8062cb35bd7f6de5281d99c4c6a001bdf4786d6f%2FScreenshot%202025-04-15%20at%2010.51.24%E2%80%AFAM.png?alt=media" alt=""><figcaption></figcaption></figure>
  * Pass GDPR preferences as early as possible, preferably in the `AppDelegate`'s `didFinishLaunchingWithOptions` method:
    * ```swift
      RTBAdMobMediationAdapterManager.shared.setIsGDPRApplies(true)
      ```
  * If your app is directed to children call this method as early as possible:
    * ```swift
      RTBAdMobMediationAdapterManager.shared.setIsChildDirected(true)
      ```

#### Step 3: Integrate Google Ad Formats

* Follow the **Google Mobile Ads SDK** [documentation](https://developers.google.com/admob/ios/quick-start) to integrate the ad formats you wish to use.
* Ensure you add your **App ID** to your app's `Info.plist` file under the key:

```xml
<key>GADApplicationIdentifier</key>
<string>Your_App_ID</string>
```

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