Integrate Third-Party Ad Networks on iOS
- Recommended: Use Our Mediation Integration Tool
- Integrate Adapters Manually via Source Code (GitHub)
- Set Up Ad Renderers for Native Ads
MoPub partners with most ad networks and supports these mediation partners with pre-built adapters. Refer to our list of supported ad networks. You can easily integrate our pre-built adapters by using the MoPub Mediation Integration Tool. You can still mediate ad networks with whom we do not partner (unsupported networks) by writing your own mediation adapters.
Use this guide to set up mediation by downloading adapters and integrating them into your app project. There are two ways to integrate networks: through our MoPub Mediation Integration Tool (recommended), or manually via source code.
Recommended: Use Our Mediation Integration Tool
We recommend that you integrate adapters using our MoPub Mediation Integration Tool. This is the more efficient option if you’re just getting started with mediation, and don’t need to customize anything.
Our tool provides a new and convenient integration approach. Simply select the ad networks you want 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.
Integrate Adapters Manually via Source Code (GitHub)
If you prefer, you can still integrate adapters manually using the existing process. We have migrated our mediation adapters to a new GitHub repository.
Download the mediation adapters. Within the repository, you can find the adapter files grouped by ad network. Simply clone the entire repository or manually download the adapter files that you want to use.
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).
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
AdColonyRewardedVideoCustomEvent) to an
Facebook Audience Network: The
FacebookNativeAdAdaptermakes 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-arccompiler flag on these files. Follow these instructions in our integration article.
Incorporate third-party SDKs into your project. You can usually find this information on the ad network’s support page.
Set Up Ad Renderers for Native Ads
To run native ads through mediated ad networks, you must set up the native ad renderer. 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.
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];
Facebook Audience Network Renderer
Starting with the 5.2.0 release of the Facebook Audience Network SDK, you can 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
rendererConfigurationWithRendererSettings: call, and register that configuration with the ad request (
FacebookNativeAdRenderer is a new adapter class introduced in the 18.104.22.168 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 caused by integrating with the Ad Placer (
MPCollectionViewAdPlacer, etc.). 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.
To register Pangle’s renderer, use the following code:
MPNativeAdRendererConfiguration *pangleConfiguration = [PangleNativeAdRenderer rendererConfigurationWithRendererSettings:settings];
MPNativeAdRendererConfiguration *mintegralConfiguration = [MintegralNativeAdRenderer rendererConfigurationWithRendererSettings:settings];
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]];
How can we make this article better for you?
Last updated August 28, 2021
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.
© 2021 MoPub (a division of Twitter, Inc.)