Integrate Third-Party Ad Networks

The MoPub SDK can mediate most ad networks through our pre-built adapters, and custom events. To see the latest list of supported ad networks, and to get the latest certified versions of mediation adapters, visit the MoPub Mediation Integration Tool. The tool also provides a convenient integration approach, discussed below.

This guide walks you through the mediation setup process, specifically where to download adapters and how to integrate them into your app project.

Integrate Adapters via CocoaPods

MoPub Mediation Integration Tool provides a new and convenient integration approach. Simply select the ad networks you would like to mediate, and the page will output the pod name information to include in your app. Once your pod is final, simply run pod install to get the latest adapters. If you are getting started with mediation and do not need to tweak anything, this approach will be the most beneficial.

Integrate Adapters Manually via Source Code (GitHub)

You can still integrate adapters manually using the existing process if you prefer. We have migrated our mediation adapters to a new GitHub repository.

  1. Download the mediation adapters. Within the repository, you can find the adapter files grouped by ad networks. Simply clone the entire repository or manually download the adapter files that you would like to use.

  2. Add the adapter files to your app project. In your app project, make sure the necessary directory paths exist (if you are a new publisher, you may not have them).

    You will need to place the adapter files into the respective directory depending on the ad network(s) you plan to mediate, in the following format: [ad network name]/[adapter files]

    For example, to mediate AdColony, add the AdColony .m and .h files (AdColonyInterstitialCustomEvent and AdColonyRewardedVideoCustomEvent) to an AdColony directory.

    Important notes:

    • Facebook Audience Network: The FacebookNativeAdAdapter makes use of MPNativeAdAdapterDelegate. Make sure you implement this delegate in your code.

    • Manual Reference Counting: If you are using Manual Reference Counting, set the -fobjc-arc compiler flag on these files. Follow these instructions in our integration article.

  3. Import third-party SDKs and incorporate them into your project. This information can usually be found on the ad network’s support page.

  4. You’re all set! Be sure to visit the MoPub Publisher UI to set up the corresponding network campaigns and target the proper ad units. Refer to our Networks tab documentation for more detail.

Set Up Ad Renderers for Native Ads

Setting up the native ad renderer for mediated ad networks is required to run native ads. Create and register the appropriate renderer for each ad network to ensure that your native ad views are laid out as intended. Refer to our Networks tab documentation for more detail. Don’t forget the default MPStaticNativeAdRenderer, shown below.

MoPub Renderer

MPNativeAdRendererConfiguration *mopubConfiguration =

  [MPStaticNativeAdRenderer rendererConfigurationWithRendererSettings:settings];

Third-Party Ad Networks’ Renderers

As an example, the following is the code snippet for Google’s ad renderer:

MPNativeAdRendererConfiguration *googleConfiguration =

  [MPGoogleAdMobNativeRenderer rendererConfigurationWithRendererSettings:settings];

Mintegral Renderer

To register Mintegral’s renderer, use the following code:

MPNativeAdRendererConfiguration *mintegralConfiguration =

  [MintegralNativeAdRenderer rendererConfigurationWithRendererSettings:settings];

Facebook Audience Network Renderer

Starting with the 5.2.0 release of the Facebook Audience Network SDK, you have the option to simplify your ad layout by using a pre-defined template provided by Facebook. You won’t need to use a custom layout. Simply pass your MPStaticNativeAdRendererSettings to the FacebookNativeAdRenderer’s rendererConfigurationWithRendererSettings: call, and register that configuration with the ad request (FacebookNativeAdRenderer is a new adapter class introduced in the 5.2.0.0 release):

MPStaticNativeAdRendererSettings *settings = [[MPStaticNativeAdRendererSettings alloc] init];
MPNativeAdRendererConfiguration *config = [FacebookNativeAdRenderer rendererConfigurationWithRendererSettings:settings];

MPNativeAdRequest *adRequest = [MPNativeAdRequest requestWithAdUnitIdentifier:@"YOUR_AD_UNIT_ID" rendererConfigurations:@[config]];

Note: At this time, we only encourage you to use the FacebookNativeAdRenderer from above with MoPub’s manual native ad integration, because of layout issues found when integrating with the Ad Placer (MPTableViewAdPlacer, or MPCollectionViewAdPlacer, and such). You may notice an irregular layout of assets when using the FacebookNativeAdRenderer in conjunction with the MoPub Ad Placer. This behavior has been confirmed by the Facebook Audience Network team.

Register Ad Renderers

Register your ad renderers as follows:

// MPTableViewAdPlacer
MPTableViewAdPlacer placer = [MPTableViewAdPlacer placerWithTableView:self.tableView viewController:self rendererConfigurations:@[mopubConfiguration, googleConfiguration]];
 self.placer.delegate = self;

// MPCollectionViewAdPlacer
MPCollectionViewAdPlacer placer = [MPCollectionViewAdPlacer placerWithCollectionView:self.collectionView viewController:self rendererConfigurations:@[mopubConfiguration, googleConfiguration]];

// MPNativeAdRequest (Manual Integration)
MPNativeAdRequest adRequest = [MPNativeAdRequest requestWithAdUnitIdentifier:nativeAdId rendererConfigurations:@[mopubConfiguration, googleConfiguration]];

Last updated March 04, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)