Ad mediation using AdMob
This is an archived version of the documentation. Actual documentation for all platforms can be found here.
Supported versions of libraries and platforms:
Minimum supported version: 5.9.1.
Maximum supported version: 6.0.0 (up to but not including).
Minimum supported version: 10.7.0.
Maximum supported version: 11.0.0 (up to but not including).
Minimum supported version: 12.0.
Supported ad formats
Adding adapters to an app
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.
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
Go to your app section.
In Ad Units, choose Add ad unit.
Select the appropriate ad format (the example shows the Rewarded format) and click Select.
Specify a name and configure the Ad Unit settings, then click Create Ad Unit.
Make sure that you received the Ad Unit ID, then click Done.
Setting up mediation
Go to Mediation and click Create Mediation Group.
Select the ad format and app platform for the Ad Unit you created.
Specify the name of the mediation group to create and continue to adding the Ad Unit.
Select your app and the created Ad Unit, and add it.
The added Ad Unit should appear in the Ad Units section. Go to adding a custom event (the Add Custom Event button).
Specify a name, configure eCPM, and click Continue.
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.
Save the changes.
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:
| {"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} |
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:
| {"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
- Request native ads as described in the Google Mobile Ads documentation.
- Set up the ad view as described in the Google Mobile Ads documentation.
- Implement the
YMAAdMobCustomEventNativeAdView
protocol in the view class that is used to display ads. - Create a view for the YAN assets that you want to display.Note.
Methods of the
nativeAgeLabel
andnativeWarningLabel
protocols must return theUIView
objects that will be displayed if their text is notnil
. Get the values of additional YAN assets using the
extraAssets
property of theGADUnifiedNativeAd
class. The asset values are set for key values inYMAAdMobNativeAdExtraAssets.h
.You can use the asset values to hide or show the corresponding view.
self.nativeAgeLabel.hidden = self.ad.extraAssets[kYMAAdMobNativeAdAgeExtraAsset] == nil;
Follow the steps described in the AdMob documentation for adaptive banner ads.
Don't pass the adWidth
and adHeight
custom event parameters. In this case, the size specified in AdMob will be used.
You can download examples of using ads here.