# AdMob Custom Events

### Introduction <a href="#markdown-header-admob-custom-events-requires-aatkit-234" id="markdown-header-admob-custom-events-requires-aatkit-234"></a>

* Requires the AATKit version 3.2 or later.
* AATKit supports AdMob custom events for banners, fullscreen ads, rewarded videos and native ads. This allows publishers integrating AdMob to receive ads from AATKit.

### How AATKit Google Mediation Adapter works: <a href="#markdown-header-how-aatkit-admob-mediation-adapter-works" id="markdown-header-how-aatkit-admob-mediation-adapter-works"></a>

* Publishers must prepare their AdMob dashboard adding custom events to their mediation
* AATKit mediation adapter implements AdMob custom events delegates
* AATKit mediation adapter internally calls AATKit whenever GoogleMobileAds asks for an ad request (that happens when the publisher request an ad through GoogleMobileAds)
* When AATKit responds, AATKit mediation adapter notifies the GoogleMobileAds with the request result using the AdMob custom events delegate methods

### Setup <a href="#markdown-header-aatkitadmobadapter-integration-steps" id="markdown-header-aatkitadmobadapter-integration-steps"></a>

First of all, you will need to add the AATKit's repository to your repositories list. Edit your main `build.gradle` file:

```gradle
allprojects {
    repositories {
        google()
        jcenter()
        //... other repositories you use
        maven {
            url 'https://android-sdk.aatkit.com/maven/'
        }
    }
}
```

Next add AATKit Google Mediation Adapter dependency to the `build.gradle` file. Please note the version of adapter corresponds to the used version of AATKit SDK.

```
dependencies {
    //... other dependencies you use
    implementation 'com.intentsoftware.addapptr:AATKitGoogleMediationAdapter:<AATKit_VERSION>'
}
```

### Integration instructions <a href="#markdown-header-aatkitadmobadapter-integration-steps" id="markdown-header-aatkitadmobadapter-integration-steps"></a>

1. In the AdMob dashboard, click on mediation on the left menu
2. Create a new mediation for each ad format (Don't forget to choose the proper ad unit that you are using in your application in the GoogleMobileAds integration)
3. Open the newly created mediation and add a custom event
4. Edit the custom event and add the proper class name from the following:
   * Banner class name: `com.intentsoftware.addapptr.aatkitgooglemediationadapter.AddapptrEventBanner`
   * Interstitial class name: `com.intentsoftware.addapptr.aatkitgooglemediationadapter.AddapptrEventInterstitial`
   * Rewarded video class name: `com.intentsoftware.addapptr.aatkitgooglemediationadapter.AddapptrEventRewarded`
   * Native ads class name: `com.intentsoftware.addapptr.aatkitgooglemediationadapter.AddapptrEventNativeAd`
5. Integrate with GoogleMobileAds different ad formats following their documentation
6. Handle activity lifecycle by using `AATKitAdmobAdapter` public methods:

**Notify about activity resume**

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

```java
@Override
protected void onResume() {
    super.onResume();
    AATKitAdmobAdapter.resume(this);
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
override protected fun onResume() {
    super.onResume()
    AATKitAdmobAdapter.resume(this)
}
```

{% endtab %}
{% endtabs %}

**Notify about activity pause**

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

```java
@Override
protected void onPause() {
    AATKitAdmobAdapter.pause(this);
    super.onPause();
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
override protected fun onPause() {
    AATKitAdmobAdapter.pause(this)
    super.onPause()
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://aatkit.gitbook.io/android-integration/other/admob-custom-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
