Smart AdServer mediation
This article shows you how to deliver Teads ads on your application using the Smart Ad Server Mediation adapter.
The official Teads SDK sample application includes working Smart AdServer integrations. Use it for implementation examples and as a reference while you set up this adapter.
Prerequisites
- Import the Teads inApp SDK in your project.
- SmartCoreSdk: 7.14.0+
- SmartDisplaySdk: 7.14.0+
- AndroidX (⚠️ SmartSDK mandatory)
Installation
Before installing the Teads Smart adapter, you will need to integrate Smart SDK into your application.
Gradle
project/build.gradle
allprojects {
repositories {
...
maven { url "https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod" }
maven { url 'https://packagecloud.io/smartadserver/android/maven2' }
}
}
app/build.gradle
dependencies {
...
implementation 'com.smartadserver.android:smart-core-sdk:7.14.0@aar'
implementation ("com.smartadserver.android:smart-display-sdk:7.14.0@aar") {
transitive = true
}
// Teads inApp SDK
implementation("tv.teads.sdk.android:sdk:6.2.3@aar") {
transitive = true
}
// Teads Smart Adapter
implementation 'tv.teads.sdk.android:smartadapter:6.2.3'
}
Defining a Custom Event
In order to display a Teads ad using Smart, you need to create a custom event.
| Name | Value |
|---|---|
| SDK Name | TeadsSDK |
| Ad Format Type | Banner |
| Adapter Class | tv.teads.adapter.smart.SmartAdapter |
| Placement Info | { "placementId": #PID#, "teadsAdSettingsKey": "[sas_kw | teadsAdSettingsKey]" } |
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.
- Media
- Native Ad
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.
- Kotlin
- Java
TeadsHelper.initialize()
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:
- Kotlin
- Java
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) {
}
}
listener = new TeadsAdapterListener() {
@Override
public void onRatioUpdated(AdRatio adRatio) {
ViewGroup.LayoutParams params = adView.getLayoutParams();
// Here the width is MATCH_PARENT
params.height = adRatio.calculateHeight(adView.getMeasuredWidth());
adView.setLayoutParams(params);
}
@Override
public void adOpportunityTrackerView(AdOpportunityTrackerView trackerView) {
}
};
Use the helper to attach a listener, it will return you a UNIQUE key to reference the current listener attached.
- Kotlin
- Java
val key = TeadsHelper.attachListener(listener)
int key = TeadsHelper.attachListener(listener);
Finally, add it to your current ad settings for the specific ad request
- Kotlin
- Java
val settings = TeadsMediationSettings.Builder()
.setMediationListenerKey(key)
.build()
val bannerPlacement = SASAdPlacement(
siteID,
pageName,
formatID,
SmartHelper.getTargetFromTeadsAdSettings(settings),
supplyChainObjectString
)
TeadsMediationSettings settings = new TeadsMediationSettings.Builder()
.setMediationListenerKey(key)
.build();
SASAdPlacement bannerPlacement = new SASAdPlacement(
siteID,
pageName,
formatID,
SmartHelper.INSTANCE.getTargetFromTeadsAdSettings(settings),
supplyChainObjectString
);
Display an ad
Create your TeadsMediationSettings and add it to the SASAdPlacement.
- Kotlin
- Java
val settings = TeadsMediationSettings.Builder()
.build()
val placement = SASAdPlacement(
siteID,
pageName,
formatID,
SmartHelper.getTargetFromTeadsAdSettings(settings),
supplyChainObjectString
)
val nativeAdManager = SASNativeAdManager(context, adPlacement)
TeadsMediationSettings settings = new TeadsMediationSettings.Builder()
.build();
SASAdPlacement placement = new SASAdPlacement(
siteID,
pageName,
formatID,
SmartHelper.INSTANCE.getTargetFromTeadsAdSettings(settings),
supplyChainObjectString
);
SASNativeAdManager nativeAdManager = new SASNativeAdManager(context, adPlacement);
Then, your SASNativeAdManager is ready to request a native ad, so you want to register
the proper listener and use our ViewBinder inside it.
Then you can use loadNativeAd()
- Kotlin
- Java
nativeAdManager.nativeAdListener = object : SASNativeAdManager.NativeAdListener {
override fun onNativeAdLoaded(nativeAd: SASNativeAdElement) {
TeadsSmartViewBinder(context!!, [YOUR_LAYOUT_TO_INFLATE], nativeAd)
.title(R.id.ad_title)
.body(R.id.ad_body)
.iconImage(R.id.teads_icon)
.callToAction(R.id.teads_cta)
.mediaLayout(R.id.teads_mediaview)
.adChoice(R.id.ad_choice)
.bind()
}
override fun onNativeAdFailedToLoad(e: Exception) {
// the native ad loading failed
}
}
nativeAdManager.loadNativeAd()
nativeAdManager.setNativeAdListener(new SASNativeAdManager.NativeAdListener() {
@Override
public void onNativeAdLoaded(SASNativeAdElement nativeAd) {
new TeadsSmartViewBinder(context, [YOUR_LAYOUT_TO_INFLATE], nativeAd)
.title(R.id.ad_title)
.body(R.id.ad_body)
.iconImage(R.id.teads_icon)
.callToAction(R.id.teads_cta)
.mediaLayout(R.id.teads_mediaview)
.adChoice(R.id.ad_choice)
.bind();
}
@Override
public void onNativeAdFailedToLoad(Exception e) {
// the native ad loading failed
}
});
nativeAdManager.loadNativeAd();
Mediation settings
Find the full settings list in Settings Configuration — TeadsMediationSettings.
Checklist
- ✅ Ensure Brand Safety is enabled
- ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
- ✅ Comply with app-ads.txt
- ✅ Implement proper error handling
- ✅ Enable ad view resizing for Media
- ✅ Test different PIDs with various ad formats and sizes. See Test PIDs and Configurations