Ad mediation using AdMob

Supported versions of libraries and platforms:

YandexMobileAdsSDK

Minimum supported version: 2.15.0.

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

GoogleMobileAdsSDK

Minimum supported version: 7.46.0.

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

iOS

Minimum supported version: 9.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 two integration methods: static and dynamic. Select the same integration method for the adapters that was used when connecting the YandexMobileAds SDK.

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

pod 'YandexMobileAdsAdMobAdapters', '0.5.0'
If you don't use CocoaPods
  1. Download and add the framework with adapters (YandexMobileAdsAdMobAdapters.framework) to the project.
  2. Make changes to the Build Settings file:

    In Framework Search Paths, add the path to the directory containing the framework.

Setting up mediation in AdMob

Get a Block ID 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
blockID Yes string The Block ID issued in the Yandex Partner interface. {"blockID": "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.
{"blockID": "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. {"blockID": "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. {"blockID": "R-M-XXXXXX", "adWidth": 300, "adHeight": 50}

Requesting and displaying native ads using the Google Mobile Ads iOS SDK

Banner ads
Follow the steps described in the Google Mobile Ads documentation for banner ads.
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 components 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 components using the extraAssets property of the GADUnifiedNativeAd class. The component values are set for key values in YMAAdMobNativeAdExtraAssets.h.

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

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

You can download examples of using ads at the links.

Swift
Objective-C