> [!WARNING]
> **DEPRECATED:** The Google Mobile Ads C++ SDK is *deprecated* as of June 17, 2024 and should not be adopted in projects that don't already use it. It will enter *End-of-Maintenance (EoM)* on June 17, 2025. Note that versions of the SDK released before the EoM date will continue to function, but no further bug fixes or changes will be released after the EoM date.
>
> Instead of the Google Mobile Ads C++ SDK, consider using the
> [iOS](https://developers.google.com/admob/ios/quick-start.md.txt) and
> [Android](https://developers.google.com/admob/android/quick-start.md.txt) SDKs from AdMob.
> For support, reach out to the
> [contact us form](https://support.google.com/admob/contact/contact_us_gma_sdk).

<br />

AdMob Mediation is a feature that lets you serve ads to your apps from
multiple sources, including the AdMob Network, third-party ad networks, and
[AdMob campaigns](https://support.google.com/admob/answer/6162747). AdMob Mediation
helps maximize your fill rate and increase your monetization by sending ad
requests to multiple networks to ensure you find the best available network to
serve ads.
[Case study](https://admob.google.com/home/resources/cookapps-grows-ad-revenue-86-times-with-admob-rewarded-ads-and-mediation/).

## Prerequisites

Before you can integrate mediation for an ad format, you need to integrate that
ad format into your app:

- [Banner](https://developers.google.com/admob/cpp/banner.md.txt)
- [Interstitial](https://developers.google.com/admob/cpp/interstitial.md.txt)
- [Rewarded](https://developers.google.com/admob/cpp/rewarded.md.txt)

New to mediation? Read [Overview of AdMob
mediation](https://support.google.com/admob/answer/3063564).

## Initialize the Mobile Ads SDK

The quick start guide shows you how to [initialize the Mobile Ads
SDK](https://developers.google.com/admob/cpp/quick-start#initialize_the_mobile_ads_sdk).
During that initialization call, mediation adapters also get
initialized. It is important to wait for initialization to complete before you
load ads in order to ensure full participation from every ad network on the
first ad request.

The sample code below shows how you can check each adapter's initialization
status prior to making an ad request.

```c++
// Initialize the Google Mobile Ads library
firebase::gma::Initialize(*app);

// In a game loop, monitor the initialization status
auto initialize_future = firebase::gma::InitializeLastResult();

if (initialize_future.status() == firebase::kFutureStatusComplete &&
    initialize_future.error() == firebase::gma::kAdErrorCodeNone) {
  // Initialization completed successfully, log the adapter status:
  std::map<std::string, firebase::gma::AdapterStatus> adapter_status_map =
      firebase::gma::GetInitializationStatus().GetAdapterStatusMap();

  for (auto it = adapter_status_map.begin(); it != adapter_status_map.end(); ++it) {
    std::string adapter_class_name = it->first;
    firebase::gma::AdapterStatus adapter_status = it->second;
    printf("adapter: %s \t description: %s \t is_initialized: %d latency: %d\n",
       adapter_class_name.c_str(),
       adapter_status.description().c_str(),
       adapter_status.is_initialized(),
       adpater_status.latency());
  }
} else {
  // Handle initialization error.
}
```

For more information about working with Futures, see
[Use Futures to monitor the completion status of method
calls](https://developers.google.com/admob/cpp/quick-start#futures).

## Check the value of `adNetworkClassName`

Each ad result contains information about the class name of the ad network that
fetched the current ad.

Here is a sample code that logs the ad network class name from an `AdResult`
returned from an `AdView`. Similar code can be used for interstitial and
rewarded ads:

```c++
firebase::Future<AdResult> load_ad_future = banner_view.loadAd(ad_request);

// In a game loop, monitor the ad load status
if (load_ad_future.status() == firebase::kFutureStatusComplete &&
    load_ad_future.error() == firebase::gma::kAdErrorCodeNone) {
  const AdResult* ad_result = load_ad_future.result();
  printf("Loaded ad with adapter class name: %s\n",
    ad_result->adapter_class_name().c_str());
} else {
  // Handle the load ad error.
}
```

## Banner ads mediation

Make sure to disable refresh in all third-party ad networks UI for banner ad
units used in AdMob Mediation. This will prevent a double refresh since AdMob
also triggers a refresh based on your banner ad unit's refresh rate.

## Next steps

The Google Mobile Ads C++ SDK wraps the Android and iOS SDK implementations for
mediation. Therefore further configuration, including the installation of
mediation adapters, is specific to the Android and iOS platforms. For more
information, see the [Google Mobile Ads Android SDK Choose networks
guide](https://developers.google.com/admob/android/choose-networks) and the [Google
Mobile Ads iOS SDK Choose networks
guide](https://developers.google.com/admob/ios/choose-networks).