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 Admob Adapter
implementation 'tv.teads.sdk.android:applovinadapter:5.x.x'
}
Defining a Custom network
In order to display a Teads native 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.
Display an ad
Create your custom layout
Create your new layout for an ad item with your favorite ViewGroup container (eg. RelativeLayout
, ConstraintLayout
…)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/ad_headline"
...
/>
<FrameLayout
android:id="@+id/media_view_container"
...
/>
// THIS CONTAINER IS MANDATORY, IT WILL BE USED AS AD_CHOICES
<FrameLayout
android:id="@+id/ad_options_view"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
...
/>
...
</RelativeLayout>
Native Ad Elements
titleView
(Guaranteed in every request)mediaView
(Guaranteed in every request)adChoicesView
(Mandatory)bodyView
callToActionView
iconView
advertiserView
Request an ad
Create the View binder
Take your layout id and pass it to the builder constructor MaxNativeAdViewBinder.Builder
,
fill every field you need for your integration
private fun createNativeAdView(): MaxNativeAdView {
val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.layout_applovin_native)
.setTitleTextViewId(R.id.title_text_view) // MANDATORY
.setBodyTextViewId(R.id.body_text_view)
.setAdvertiserTextViewId(R.id.advertiser_textView)
.setIconImageViewId(R.id.icon_image_view)
.setMediaContentViewGroupId(R.id.media_view_container) // MANDATORY
.setOptionsContentViewGroupId(R.id.ad_options_view) // MANDATORY (AdChoices)
.setCallToActionButtonId(R.id.cta_button)
.build()
return MaxNativeAdView(binder, this)
}
Create the AdLoader
AppLovinSdk.getInstance(this).mediationProvider = "max"
AppLovinSdk.getInstance(this).initializeSdk {} // you will need to wait this to finish before loading an ad
val nativeAdLoader = MaxNativeAdLoader("YOUR_AD_UNIT_ID", this)
nativeAdLoader.setNativeAdListener(object : MaxNativeAdListener() {
override fun onNativeAdLoaded(nativeAdView: MaxNativeAdView, ad: MaxAd) {
if (nativeAd != null) nativeAdLoader.destroy(nativeAd)
// NativeAd is stored to allow destroying it as above before replacing it
nativeAd = ad
// Add ad view to view.
containerAdView.removeAllViews()
containerAdView.addView(nativeAdView)
}
override fun onNativeAdLoadFailed(adUnitId: String, error: MaxError) {}
override fun onNativeAdClicked(ad: MaxAd) {}
})
Load an ad
Create the TeadsMediationSettings
, then add the settings to the local extra parameters
val settingsEncoded = TeadsMediationSettings.Builder()
.enableDebug()
.build().toJsonEncoded()
nativeAdLoader.setLocalExtraParameter("teadsSettings", settingsEncoded)
nativeAdLoader.loadAd(createNativeAdView())
Mediation settings
Find the full settings list here
Check list
- ✅ Ensure Brand Safety is enabled
- ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA).
- ✅ Comply with app-ads.txt
- ✅ Enable ad view resizing
- ✅ Test different test PIDs for multiple ad format and size testing
- ✅ Enable validation mode to ensure key features are working