Login
Welcome
Login

MoPub

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 TeadsSDK framework.

Requirements

  • Android SDK: 16+
  • Mopub SDK: 5.0.0+
  • Platform: iOS 9+
  • Xcode: 9.0+
  • MoPub SDK: 5.5+

Features

Displaying Teads inRead via banners.

Installation

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

Gradle

app build.gradle

// Teads Repository
repositories{
    maven {
        url  "http://dl.bintray.com/teads/TeadsSDK-android"
    }
    maven {
        url "https://s3.amazonaws.com/moat-sdk-builds"
    }
}

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-basement:12.0.1'

    // Teads SDK
    implementation("tv.teads.sdk.android:sdk:4.2.3@aar") {
        transitive = true
    }

    // Teads MoPub Adapter
    implementation 'tv.teads.sdk.android:mopubadapter:4.2.3'

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

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

CocoaPods

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, '9.0'
    pod 'MoPub-Teads-Adapters'
  2. Run pod install --repo-update to install the adapter in your project.
  3. Follow the Define Custom Event step to finish the integration.

Manually

  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.

Integration

Important

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

bannerAdView.setAutorefreshEnabled(false)

Important

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

adView.stopAutomaticallyRefreshingContents()

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:

NameDescription
Custom Event ClassClass name of the adapter
Custom Event Class DataJSON configuration for the network
  1. For the Custom Event Class parameter, you will need to use one of these names depending on ad type:

    Banner ad:

    tv.teads.adapter.mopub.TeadsBannerAdapter
    MPAdapterTeadsBanner
  2. For the Custom Event Class Dataparameter, you will need to put this JSON settings dictionary.
    {"PID":"__publisher_PID__"}

Important

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 this:

  • if you're using our Objective-C framework or standalone class files:
    • Banner ad: MPAdapterTeadsBanner
  • if you're using our Swift framework:
    • Banner ad: TeadsMoPubAdapter.MPAdapterTeadsBanner
  • if you're using our Swift standalone class files:
    • Banner ad: __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.

Example

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

Note

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 TeadsLocalExtras class to pass mediation settings.

  1. Create an instance of TeadsLocalExtras.
  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.
TeadsLocalExtras teadsLocalExtras = new TeadsLocalExtras.Builder()
                .enableDebug()
                .pageUrl("https://page.com/article1/")
                .build();

MoPubView bannerAdView = new MoPubView(getActivity());
bannerAdView.setAdUnitId(adUnitID);
bannerAdView.setLocalExtras(teadsLocalExtras.getExtras());
bannerAdView.setAutorefreshEnabled(false);

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
}
adView.register(teadsAdSettings: adSettings)
// Disabling ad auto refreshing
adView.stopAutomaticallyRefreshingContents()
// Load banenr
adView.loadAd()

Here is a list of available extra parameters:

SettingsDescription
enableDebug()Enable debug logs from Teads SDK.
enableLigtEndScreen()Enable/disable light mode for the end screen
disableLocation()Disable the collection of user location. By default, SDK will collect user location if corresponding permissions have been granted to the host application.
disableMediaPreload()Disable preload of media files (like videos). If disabled, media files will be loaded lazily.
pageUrl(_ urlString: String)The publisher equivalent web page URL for brand safety purposes.
userConsent(subjectToGDPR: String, consent: String) The user consent, European regulation requirement, see the GDPR consent management documentation
disableTeadsAudioSessionManagement()Disable audio session management
enableValidationMode()Enable validation tool session, see the Validate your integration section
disableCrashMonitoring()Disable crash monitoring, see the Crash monitoring documentation

Ad Containers

In order to provide you with accurate stats and optimize your revenues, it's necessary to give the ad container to the Teads ad view. This will allow us to determine ad opportunities.

The Ad container is the view in which you will add the ad view. In the case of the AdMob mediation, you can provide it thanks to TeadsLocalExtras.

TeadsLocalExtras.Builder teadsLocalExtras = new TeadsLocalExtras.Builder()
                .adContainerId(mBannerAdContainer.getId());

Unfortunately, it's not available on MoPub since they do not give us the possibility to send extra parameters.

Did you find it helpful? Yes No

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