Twitter MoPub mediation

On this page

This article shows you how to deliver Teads ads on your application using the MoPub Mediation adapter.

Using CocoaPods to have Teads AdMob/GAM mediation plugin will automatically import the Teads SDK framework.

Sample App on GitHub


  • Android SDK: 19+
  • Mopub SDK: 5.0.0+
  • Platform: iOS 10+
  • Xcode: 11.0+
  • MoPub SDK: 5.13+, <= 5.15.0


Displaying Teads inRead via banners.


Before installing the Teads adapter, you need to integrate the MoPub SDK into your application.


app build.gradle

Following JFrog announcement that Bintray will be deprecated from may 1st 2021, Teads SDK is now relying on Artifactory as an alternative hosting solution. More info.

// Teads Repository
maven {
url "https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod"
maven {
url "https://s3.amazonaws.com/moat-sdk-builds"
maven {
// Mandatory for Huawei device compatibility
url "https://developer.huawei.com/repo/"

Next, in the same file edit the app dependencies node:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'

// Required dependency
implementation 'com.google.android.gms:play-services-ads:15.0.1'

// Teads SDK
implementation("tv.teads.sdk.android:sdk:X.Y.Z@aar") {
transitive = true

// Adapter helper

// Teads MoPub Adapter
implementation 'tv.teads.sdk.android:mopubadapter:X.Y.Z'

// Mandatory for Huawei device compatibility
implementation 'com.huawei.hms:ads-identifier:'

// Mopub SDK
implementation('com.mopub:mopub-sdk:5.0.0@aar') {
transitive = true

Replace the X.Y.Z above with the latest release version.

Before installing the Teads adapter, you need to integrate the MoPub SDK into your application.


If your project is managing dependencies through CocoaPods, you just need to add this pod in your Podfile.

It will install the Teads adapter and Teads SDK.

  1. Add pod named MoPub-Teads-Adaptersin your Podfile:
    platform :ios, '10.0'
    pod 'MoPub-Teads-Adapters'

    podn'mopub-ios-sdk', '<= 5.15.0'
  2. Run pod install --repo-update to install the adapter in your project.
  3. Follow the Define Custom Event step to finish the integration.


  1. Integrate the latest version of Teads SDK to your project using this Quick Start Guide.
  2. Download the latest release of TeadsMoPubAdapter.
  3. Drop adapter files in your iOS project.
  4. Follow the Define Custom Event step to finish the integration.



The MoPubView will automatically refresh your ad unit at a time interval that you set using the MoPub web interface. You need to disable automatic refreshing content



MPAdView automatically refreshes an ad unit at a time interval specified via the MoPub web interface. You need to disable automatic refreshing content


Defining a Custom Event

In order to display a Teads ad through MoPub mediation, you need to create a custom SDK network on MoPub dashboard.

When creating a custom SDK network, you are required to define these parameters:

Custom Event Class
  • v4.6.0 and above TeadsMoPubAdapter.MPAdapterTeadsBanner
  • v4.5.0 and below MPAdapterTeadsBanner
Custom Event Class Data{"PID": "__publisher_PID__"}

See this article to find test PIDs serving different creative formats.

Migrating from v4.5.0 (and below) to v4.6.0 (and above)

To ensure retro compatibility with users still using v4.5.0 (and below) and v4.6.0 (and above) at the same time, define the two custom events below:

  1. Custom Event for v4.6.0 and above
    Custom Event Class
    Custom Event Class Data{"PID": "__publisher_PID__"}
  2. Custom Event v4.5.0 and below
    Custom Event Class
    Custom Event Class Data{"PID": "__publisher_PID__"}


Don't forget to replace the __publisher_PID__ with your Teads placement ID.

Depending on your integration method, you need to prefix Custom Event Class like __module_name__.MPAdapterTeadsBanner where you need to replace __module_name__ by the name of your app/framework module in which you integrate the adapter:

  • appName
  • appName_targetName (if you have multiple targets in your project or if the project name is different from the target name)

Remember to replace any non-alphanumeric characters such as dashes with underscores.


If you add a Teads banner placement in MoPub and you integrate the adapter through our ObjC class files in an ObjC app named "Demo", you'll use MPAdapterTeadsBanner for Custom Event Class.

Mediation settings


Only available for banner ads.

With MoPub banner ads, you have the ability to pass local extras in order to customize third-party ad network settings.

For Teads, you need to use the AdSettings class to pass mediation settings.

  1. Create an instance of AdSettings.
  2. Populate it with your custom settings.
  3. Set the pageUrl if you are in article placement to enable brand safety
  4. Register it into MoPubView using setLocalExtras method.
  5. Teads banner ad will receive your specific local extras when it will load.
AdSettings adSettings = new AdSettings.Builder()

MoPubView bannerAdView = new MoPubView(getActivity());
You have the ability to pass extra parameters in order to customize third-party ad network settings. For Teads, you need to use MPAdapterTeadsExtras class to pass extra parameters.
  • Create an instance of MPAdapterTeadsExtras
  • Populate it with your custom settings. 
  • Popupale your MPAdView with your MPAdapterTeadsExtras object as Dictionary.
// Create banner ad view
adView = MPAdView(adUnitId: self.unitId, size: MediationConstants.MoPubBannerAdSize)
adView.delegate = self
// Add extra parameters for Teads Network
let adSettings = TeadsAdSettings { (settings) in
settings.setUsPrivacy(consent: "1YNN")
settings.enableDebug() // For test purposes
try? settings.subscribeAdResizeDelegate(self, forAdView: adView)
// Required to enable ad slot resizing (See specific section. 4.7.5 and above)
// adView type should be MPAdView otherwise it will throw an error
adView.register(teadsAdSettings: adSettings)
// Disabling ad auto refreshing
// Load banner

Here is a list of available parameters

Ad Resizing


Vertical and Square ads are compatible with Teads SDK v4.7.5 and above only

The code below must be implemented to enable the resizing of the mediated ad slot making possible the rendering of square and vertical creatives.

Initialize the TeadsHelper first.


You can instantiate a new listener as below, the listener needs to be a class member field or strong referenced somewhere, we keep internally a weak reference to it, so it goes garbage collected when you don't need it anymore:

mListener = new TeadsBannerAdapterListener() {
public void onRatioUpdated(float adRatio) {
ViewGroup.LayoutParams params = adFrame.getLayoutParams();
// Here the width is MATCH_PARENT
params.height = Math.round(params.width / adRatio);


we require ONE listener per ad experience to resize the correct ad

Use the helper to attach a listener, it will return you the UNIQUE of the current listener attached.

int key = TeadsHelper.attachListener(mListener);

Finally, add it to your current ad settings for the specific ad request, see Ad Settings

AdSettings adSettings = new AdSettings.Builder().addAdapterListener(key).build();

Subscribe to ad resizing through Teads Ad Settings by providing your delegate class and the adView that need to be resized

let settings = TeadsAdSettings { (settings) in
try? settings.subscribeAdResizeDelegate(self, forAdView: adView)

Simply conform to the Teads delegate TFAMediatedAdViewDelegate and implements the didUpdateRatio function.

extension SimpleAdMobBannerViewController : TFAMediatedAdViewDelegate {

func didUpdateRatio(_ adView: UIView, ratio: CGFloat) {
guard let adView = adView as? DFPBannerView else {
let width = adView.frame.width
adView.resize(GADAdSizeFromCGSize(CGSize(width: width, height: width / ratio)))


Request App Tracking Transparency authorization (iOS 14+)

iOS 14 introduced App Tracking Transparency

Please refer here to know more about it.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.