Prerequisites
- Import the Teads inApp SDK in your project.
- AppLovin SDK: 11+
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:5.x.x@aar") {
transitive = true
}
// Teads AppLovin Adapter
implementation 'tv.teads.sdk.android:applovinadapter:5.x.x'
}
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.
Name | Value |
---|---|
Android Class Name | com.applovin.mediation.adapters.TeadsContextAdapter |
Teads Ad Unit
Follow the custom network documentation (Step. 2) on the AppLovin dashboard using the below values.
Name | Value |
---|---|
Placement ID (PID) | See information below |
Please retrieve your production PID from your local account manager.
See this page for test PIDs and creative formats.
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)
⚠️ Before loading the ad you can define if you want to disable the ad auto refreshing. This feature on AppLovin mediation works like an ad caching system since it starts to automatically request new ads and add it to a queue to be displayed sequentially on the same ad slot.
If you do not want to disable it, use it carefully since if you received too often ads that in the end are not displayed, this is going to reduce your ad fill rate.
In order to adjust the ad refrehs interval, check the official documentation.
In order to just 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 here
Check list
- ✅ Ensure Brand Safety is enabled
- ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
- ✅ Comply with app-ads.txt
- ✅ Enable ad view resizing
- ✅ Test different PIDs with various ad formats and sizes
- ✅ Enable validation mode to ensure key features are working