Skip to end of metadata
Go to start of metadata

Mediate with iOS SDK v6.0 

Mediation lets you sell ad impressions through multiple networks to generate more revenue. This is initiated by your main (mediating) SDK which calls out to one or more mediated SDKs in a "waterfall"-like process. If your main SDK can't show an ad for some reason, it can iterate over the list of mediated SDKs and contact them in the order you specify. This will continue until the impression is filled or you've run out of mediated SDKs.

Reasons to mediate to another SDK include the following:

  • To provide better monetization under specific circumstances

  • To provide access to information such as a unique user ID or the device's operating system, location, or ID

  • Some networks only accept requests from their own SDKs, forcing you to use their SDK to access their demand

This page describes how to set up mediation from an engineering perspective. For more information about how SDK mediation works at a high level, including ad ops information, see SDK Mediation.

On This Page

Let us mediate other networks

Supported Networks and Media Types

The table below lists the networks that we provide mediation adaptors for, and the media types that each adaptor supports. The version number indicates the version of the mediation SDKs that are compatible with our mediation adapters. Newer versions may work with our adapters without issues but have not been tested. 

AdaptorVersionBannerInterstitialNativeDocs
AdMob and DFP7.44.0YesYesYesGoogle Mobile Ads - iOS Mediation
Amazon2.2.15.1YesYesNoAmazon Mobile Ads for iOS
InMobi7.2.9YesYesYesInMobi iOS SDK Documentation
Millennial6.6.0YesYesNoMillennial iOS SDK Documentation
MoPub5.7.1YesYesNoMoPub iOS SDK Documentation
SmartAdServer7.0.2YesYesNoSmartAdServer Documentation
Facebook4.28.1YesYesYesFacebook Audience Network Documentation

Prerequisites

To mediate these networks, you will need the following:

  •  A supported release of our SDK. For instructions on installing our SDK, see Integrate with iOS.

  • The SDK of the network you want to mediate.

  • A mediation adaptor that allows our SDK to communicate with the network's SDK.

Integrating Mediation Adapters

Mediation adapters can be integrated with the SDK by either utilizing CocoaPods or building the adaptors from source

Using CocoaPods: 

Integrating with CocoaPods requires a local installation of their program. If you are unfamiliar with the use of CocoaPods review their installation guide. Once you have CocoaPods installed:

Use Terminal or your command line editor of choice and navigate to the project directory and create a PodFile.

After you have created a PodFile, enter the code below within it to integrate the mediation adapters. You can include as many or as few adaptors as required for your project.

Save your changes and return to Terminal and enter: 

CocoaPods will download and integrate the mediation adapters you have selected. 

Building From Source

  1. Download and unzip the latest release of our SDK from our Github Releases page. 
  2. Once the SDK has been downloaded and unzipped, navigate to the mediatedViews folder within the mobile-sdk-ios project: mobile-sdk-ios/mediation/mediatedviews. 
  3. Select the Mediation adapter folder you want to use and copy into your Xcode project.
  4. After adding the Mediation adapters you require, visit the download page for the Mediation SDKs of the adapters you selected and integrate them into your project. (Download links for each Mediation SDK can be found by following the links to their documentation sites provided in the table above.)
  5. Continue the integration process by following the instructions in the Integrate the AppNexus SDK documentation. 

Instantiating Mediation Adaptors

If you use any of the following adaptors, you need to initialize the adaptor's SDK as early as possible in the lifecycle of the application. A perfect place to do this is in the app delegate. The code samples below show how to do this for each adaptor.

AdMob

Native Mediation

The instructions in this section are only needed if you are doing native mediation. Mediating banners and interstitials should not require any initialization code or further work.

Starting with v5.1 of the SDK, the AdMob Native Mediation adapter code was modified support the Google GADUnifiedNativeAdView.

The following are no longer relevant and have been removed:

[ANAdAdapterNativeAdMob enableNativeAppInstallAds];
[ANAdAdapterNativeAdMob enableNativeContentAds];

To handle AdMob native ads, you need to create a native ad view that inherits from GADUnifiedNativeAdView:

For SDK v5.3 and higher, you need to specify the GADIsADManagerApp key in the app's info.plist with a boolean YES value.

Setting the Custom Keyword

For passing the content URL to the Google SDK, the contenturl needs to be passed as a custom keyword with the requester ad object (BannerAdView, InterstitialAdView, NativeAdRequest). The key to be used is content_url. Here is an example:

Amazon

Use the following code to instantiate the adaptor for the Amazon Ads SDK for iOS:

InMobi

Use the following code to instantiate the adaptor for the InMobi iOS SDK:

Millennial

Use the following code with the Millennial SDK to define the AOL Mobile Platform site ID:

Millennial mediation will work without this site ID. It's only necessary if you are using the AOL Mobile Platform.


Placement Setup

Interstitial Mediation

If you want to do interstitial mediation, you must make sure your placement is set up in Console with:

  • Size: 1x1
  • Media Type: Interstitial

For instructions on creating placements, see Create a Placement.

Interstitial Mediation plus RTB and/or Managed Demand

If you want to do interstitial mediation and accept RTB and/or managed demand through the same placement, you must make sure your placement is set up in Console with:

  • Size: 1x1
  • Media Type: Interstitial
  • Media Type: Banner

Then, for non-mediated demand, you must pass the actual sizes of the creatives in your ad calls using setAllowedSizes on the Interstitial Ad View.

For instructions on passing custom interstitial sizes, see the Using Custom Interstitial Sizes section of Show Interstitials.

Custom Mobile Networks

Console for Publishers has built-in support for a number of popular mobile ad networks. If you want to mediate a network it doesn't support, you must:

Let other networks mediate us

Our SDK comes with built-in support for being mediated by AdMob or MoPub. In each case, this requires additional steps:

  • Including a special adaptor that allows the MoPub or AdMob SDK to mediate ours (this is in addition to having our SDK installed). Instructions for each SDK are below.

  • Changing some settings in the AdMob or MoPub web UI. This is also described below.

Note: these instructions may not reflect the latest changes in the AdMob and MoPub UIs. We will attempt to keep them in sync, but we can't guarantee it.

Mediate us with AdMob

This section describes how to mediate our SDK using AdMob. These instructions assume that:

  • You have the AdMob SDK installed.

  • You have our SDK installed.

  • You have our AdMob mediation adaptor installed. There are several ways to get it. You can download the pre-built binary from our Github page, or build from source. You can also use CocoaPods. If you use CocoaPods, once you have created a PodFile in your project directory, you can include the AdMob mediation adaptor like this:

  • If you prefer to include the adaptor manually, you can get it from Github.

Step 1. Go into the AdMob UI and set up a Mediation Placement

See the instructions in the AdMob documentation for setting up a mediation placement.

Step 2. Configure your mediation placement with a Custom Event to call our SDK

Once you've set up a mediation placement, you must associate it with your placement in our system. In the AdMob UI, under Monetize, click the Edit mediation button to the right of your ad unit.

Click New ad network. Then, to get the AdMob SDK to call our SDK for mediation, click custom event and enter the following information:

  • Class Name: Enter a class name from our SDK's AdMob adaptor. Depending on whether you want to show banners or interstitials, the name of the class will be ANGADCustomBannerAd or ANGADCustomInterstitialAd.

  • Parameter: This is where you'll enter the placement ID from our system, e.g., 123456 (no quotes). You must enter the placement ID as an integer, not as a quoted string.

  • Label: This field is not used by our system.

Step 3. Verify that the integration is working

Verify that the integration is working as follows:

  • Use the settings in the AdMob UI to allow only this placement to serve. In other words, this Custom Event should always "win" the auction.

  • Turn on verbose logging by calling [ANLogManager setANLogLevel:ANLogLevelDebug] from your code.

  • Check the logs to make sure that the AdMob SDK is calling out to our SDK.

  • You may not see an ad load, since PSAs are turned off by default. Turn on PSAs if you want to visually verify the ad load (in addition to seeing the call in the logs). For instructions on turning on PSAs, see Integrate with iOS.

Mediate us with MoPub

This section describes how to mediate our SDK using MoPub. These instructions assume that:

  • You have the MoPub SDK installed.

  • You have our SDK installed.

  • You have our MoPub mediation adaptor installed. There are several ways to get it. You can download the pre-built binary from our Github page, or build from source. You can also use CocoaPods. If you use CocoaPods, once you have created a PodFile in your project directory, you can include the MoPub mediation adaptor like this:

  • If you prefer to include the adaptor manually, you can get it from Github.

Step 1. Go into the MoPub UI and set up a Custom Native Network

See the instructions in the MoPub documentation for setting up a Custom Native Network.

Step 2. Configure your Custom Native Network to call our SDK

Once you've set up a Custom Native Network, you must associate it with your placement in our system. In the MoPub UI, go to the Network Detail screen and click the Edit Network button.

To get the MoPub SDK to call our SDK for mediation, click Edit Section and enter a Custom Event Class and Custom Event Class Data as follows:

  • Custom Event Class: Enter a class name from our SDK's MoPub mediation adaptor. Depending on whether you want to show banners or interstitials, enter ANMoPubMediationBanner or ANMoPubMediationInterstitial.

  • Custom Event Class Data: Enter the JSON MoPub needs to get its SDK talking to ours.

Here's an example:

These refer to the placement ID from our system, and to the height and width of the ads that placement should be able to accept. Note that the values must be strings.

Step 3. Verify that the integration is working

Verify that the integration is working as follows:

  • Use the settings in the MoPub UI to allow only this placement to serve. In other words, this Custom Native Network should always "win" the auction.

  • Turn on verbose logging by calling [ANLogManager setANLogLevel:ANLogLevelDebug] from your code.

  • Check the logs to make sure that the MoPub SDK is calling out to our SDK.

  • You may not see an ad, since PSAs are turned off by default. Turn on PSAs if you want to visually verify the ad load (in addition to seeing the call in the logs). For instructions on turning on PSAs, see Integrate with iOS.

Related Topics