Skip to end of metadata
Go to start of metadata

Mediate with iOS

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.

Mediation in Closed Beta

Mediation is currently in a closed Beta and is not available to all clients. For more information about our mediation capabilities, contact your AppNexus representative.

On This Page

Let us mediate other networks

Supported Networks and Media Types

This section lists the networks that we provide mediation adaptors for, and the media types that each adaptor supports. For each adaptor, we show whether it supports banners, interstitials, native, or all three.

AdaptorBannerInterstitialNativeDocs
AdMob and DFPYesYesYesGoogle Mobile Ads - iOS Mediation
AmazonYesYesNoAmazon Mobile Ads for iOS
InMobiYesYesYesInMobi iOS SDK Documentation
MillennialYesYesNoMillennial iOS SDK Documentation
MoPubYesYesNoMoPub iOS SDK Documentation
SmartAdServerYesYesNoSmartAdServer Documentation
FacebookYesYesYesFacebook Audience Network Documentation

Prerequisites

To mediate these networks, you'll 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. There are two ways to get our mediation adaptors:
    1. You can install the binary builds of the adaptors that are included with our official releases. You can also build the adaptors yourself from source.
    2. If you use CocoaPods, use the code below in your project directory's PodFile. You can include as many or as few adaptors as you like from this list:

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