Skip to main content

AppLovin MAX mediation

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


Sample App

The official Teads SDK sample application includes working AppLovin MAX integrations. Use it for implementation examples and as a reference while you set up this adapter.

Teads Android Sample App on GitHub

Prerequisites​

Installation​

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

Gradle​

project/build.gradle

allprojects {
repositories {
...
maven { url "https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod" }
}
}

app/build.gradle

dependencies {
...
implementation "com.applovin:applovin-sdk:11.5.1" // or higher

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

// Teads AppLovin Adapter
implementation 'tv.teads.sdk.android:applovinadapter:6.2.3'
}

Defining a Custom network​

In order to display a Teads ad using AppLovin mediation, you need to create a new Teads custom network and a new adunit using Teads custom network.

Teads Custom Network​

Follow the custom network documentation (Step. 1) on the AppLovin dashboard using the below values.

NameValue
Android Class Namecom.applovin.mediation.adapters.TeadsContextAdapter

Teads Ad Unit​

Follow the custom network documentation (Step. 2) on the AppLovin dashboard using the below values.

NameValue
Placement ID (PID)Teads placement ID — use 84242 (Media) or 124859 (Native) for testing. Production PIDs come from your account manager.
Production PID

Production PIDs come from your account manager. See the troubleshooting guide for test PIDs and creative formats.

Formats​

Pick the ad format you are integrating. Each format has its own setup.

Load an ad​

You will need to initialize the AppLovinSdk, then pass your Ad Unit ID that you created before, pass the teads settings using the teadsSettings key

AppLovinSdk.getInstance(this).mediationProvider = "max"
AppLovinSdk.getInstance(this).initializeSdk {} // you will need to wait this to finish before loading an ad

val adView = MaxAdView("YOUR_AD_UNIT_ID", MaxAdFormat.MREC,this)
val settingsEncoded = TeadsMediationSettings.Builder()
.build()
.toJsonEncoded()

adView.setLocalExtraParameter("teadsSettings", settingsEncoded)
adView.loadAd()

Ad Resizing​

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.

TeadsHelper.initialize()

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:

listener = object : TeadsAdapterListener {
override fun onRatioUpdated(adRatio: AdRatio) {
val params: ViewGroup.LayoutParams = adView.layoutParams

// Here the width is MATCH_PARENT
params.height = adRatio.calculateHeight(adView.measuredWidth)
adView.layoutParams = params
}

override fun adOpportunityTrackerView(trackerView: AdOpportunityTrackerView) {
}
}

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

val key = TeadsHelper.attachListener(listener)
Refresh interval

Before loading the ad you can define if you want to disable ad auto-refreshing. This AppLovin mediation feature works like an ad caching system: it automatically requests new ads and queues them to display sequentially on the same ad slot.

If you do not disable it, use it carefully: ads that load often but are not displayed will reduce your ad fill rate.

To adjust the ad refresh interval, check the official documentation.

To disable it, add the following lines.

adView.setExtraParameter( "allow_pause_auto_refresh_immediately", "true" )
adView.stopAutoRefresh()

Finally, add it to your current ad settings for the specific ad request.

val settingsEncoded = TeadsMediationSettings.Builder()
.enableDebug()
.setMediationListenerKey(key)
.build().toJsonEncoded()

adView.setLocalExtraParameter("teadsSettings", settingsEncoded)

Mediation settings​

Find the full settings list in Settings Configuration — TeadsMediationSettings.

Checklist​