Ad mediation using AdMob

Warning.

This is an archived version of the documentation. Actual documentation for all platforms can be found here.

  1. Supported ad formats
  2. Adding adapters to an app
  3. Setting up mediation in AdMob
  4. Requesting and displaying ads using the Google Mobile Ads iOS SDK

Supported versions of libraries and platforms:

YandexMobileAdsSDK

Minimum supported version: 5.9.1.

Maximum supported version: 6.0.0 (up to but not including).

GoogleMobileAdsSDK

Minimum supported version: 10.7.0.

Maximum supported version: 11.0.0 (up to but not including).

iOS

Minimum supported version: 12.0.

Adding adapters to an app

Note.

Before connecting an adapter, you need to integrate the Yandex Mobile Ads SDK. Otherwise, loading an ad will result in an error.

The YandexMobileAdsAdMobAdapters library has been adapted to work with the CocoaPods dependency management system and supports a static integration method.

To connect the library, add the dependency to the project's Podfile:
pod 'YandexMobileAdsAdMobAdapters', '5.9.1.0'

Setting up mediation in AdMob

Get an adUnitID in the Yandex Partner interface for each Ad Unit created in AdMob. Then set up mediation in the AdMob web interface:

Creating an Ad Unit

  1. Go to your app section.

  2. In Ad Units, choose Add ad unit.

  3. Select the appropriate ad format (the example shows the Rewarded format) and click Select.

  4. Specify a name and configure the Ad Unit settings, then click Create Ad Unit.

  5. Make sure that you received the Ad Unit ID, then click Done.

Setting up mediation

  1. Go to Mediation and click Create Mediation Group.

  2. Select the ad format and app platform for the Ad Unit you created.

  3. Specify the name of the mediation group to create and continue to adding the Ad Unit.

  4. Select your app and the created Ad Unit, and add it.

  5. The added Ad Unit should appear in the Ad Units section. Go to adding a custom event (the Add Custom Event button).

  6. Specify a name, configure eCPM, and click Continue.

  7. Add a custom event and fill in the following fields:

    Class Name — Specify YMAAdMobCustomEventBanner, YMAAdMobCustomEventInterstitial, YMAAdMobCustomEventNative, or YMAAdMobCustomEventRewarded.

    Parameter — Enter the custom event in JSON format as shown in the Custom event parameters table.

  8. Save the changes.

Custom event parameters
Parameter Required Type Description Example
adUnitID Yes string The adUnitID issued in the Yandex Partner interface. {"adUnitID": "R-M-XXXXXX"}
openLinksInApp No boolean

Defines how web links will be opened:

  • true — Web links open in the app.
  • false or omitted — Web links open in the browser.
{"adUnitID": "R-M-XXXXXX", "openLinksInApp": true}
adWidth No number Width of the banner. Can be used for passing a size that isn't supported by AdMob. It must match the banner size chosen in the Yandex Partner interface. {"adUnitID": "R-M-XXXXXX", "adWidth": 300, "adHeight": 50}
adHeight No number Height of the banner. Can be used for passing a size that isn't supported by AdMob. It must match the banner size chosen in the Yandex Partner interface. {"adUnitID": "R-M-XXXXXX", "adWidth": 300, "adHeight": 50}
Custom event parameters
Parameter Required Type Description Example
adUnitID Yes string The adUnitID issued in the Yandex Partner interface. {"adUnitID": "R-M-XXXXXX"}
openLinksInApp No boolean

Defines how web links will be opened:

  • true — Web links open in the app.
  • false or omitted — Web links open in the browser.
{"adUnitID": "R-M-XXXXXX", "openLinksInApp": true}
adWidth No number Width of the banner. Can be used for passing a size that isn't supported by AdMob. It must match the banner size chosen in the Yandex Partner interface. {"adUnitID": "R-M-XXXXXX", "adWidth": 300, "adHeight": 50}
adHeight No number Height of the banner. Can be used for passing a size that isn't supported by AdMob. It must match the banner size chosen in the Yandex Partner interface. {"adUnitID": "R-M-XXXXXX", "adWidth": 300, "adHeight": 50}

Requesting and displaying ads using the Google Mobile Ads iOS SDK

Banner ads
Follow the steps described in the Google Mobile Ads documentation for banner ads.
Adaptive banner ads

Follow the steps described in the AdMob documentation for adaptive banner ads.

Note.

Don't pass the adWidth and adHeight custom event parameters. In this case, the size specified in AdMob will be used.

Interstitial ads
Follow the steps described in the Google Mobile Ads documentation for interstitial ads.
Rewarded ads
Follow the steps described in the Google Mobile Ads documentation for rewarded ads.
Native ads
  1. Request native ads as described in the Google Mobile Ads documentation.
  2. Set up the ad view as described in the Google Mobile Ads documentation.
  3. Implement the YMAAdMobCustomEventNativeAdView protocol in the view class that is used to display ads.
  4. Create a view for the YAN assets that you want to display.
    Note.

    Methods of the nativeAgeLabel and nativeWarningLabel protocols must return the UIView objects that will be displayed if their text is not nil.

  5. Get the values of additional YAN assets using the extraAssets property of the GADUnifiedNativeAd class. The asset values are set for key values in YMAAdMobNativeAdExtraAssets.h.

    You can use the asset values to hide or show the corresponding view.

    self.nativeAgeLabel.hidden = self.ad.extraAssets[kYMAAdMobNativeAdAgeExtraAsset] == nil;

You can download examples of using ads here.