Skip to main content

Standard Prebid Integration - TeadsPBMPluginRenderer

This article shows you how to deliver Teads ads on your application using the Prebid Mobile SDK. This integration uses the official Prebid Mobile SDK. Teads provides a Plugin Renderer that handles ad display for Teads demand while other demand partners continue working normally.

Experimental

Experimental API.


Sample App

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

Teads Android Sample App on GitHub

Prerequisites​

Installation​

Before installing the Teads Prebid adapter, you will need to integrate Prebid 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 'org.prebid:prebid-mobile-sdk:2.1.6' // or higher

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

// Teads Prebid Adapter
implementation 'tv.teads.sdk.android:prebidadapter:6.2.3'
}

Register the Teads plugin renderer​

You need to register the Teads plugin renderer. Such registration can be done just once during the initialisation of your app or activity.

import org.prebid.mobile.PrebidMobile
import tv.teads.adapter.prebid.TeadsPBMPluginRenderer

PrebidMobile.registerPluginRenderer(TeadsPBMPluginRenderer(context))

You can also pass in the plugin renderer constructor a TeadsMediationSettings class.

import org.prebid.mobile.PrebidMobile
import tv.teads.adapter.prebid.TeadsPBMPluginRenderer
import tv.teads.sdk.AdPlacementSettings
import tv.teads.sdk.TeadsMediationSettings

val placementSettings = AdPlacementSettings.Builder()
.enableDebug()
.build()
val teadsMediationSettings = TeadsMediationSettings(adPlacementSettings = placementSettings)

val teadsPluginRenderer = TeadsPBMPluginRenderer(
context = context,
teadsMediationSettings = teadsMediationSettings
)

PrebidMobile.registerPluginRenderer(teadsPluginRenderer)

Specify contextUrl targeting​

Set the publisher's HTTP page URL that matches the content where the Teads ad will be loaded. This value helps target the context and also guarantees brand safety to our advertisers.

import org.prebid.mobile.TargetingParams

TargetingParams.addExtData("contextUrl", "https://example.com/my_article_1")

Settings​

Find the full settings list in Settings Configuration — TeadsMediationSettings.

Ad Formats​

Currently the Teads plugin renderer supports Media (formerly inRead) only. In the Prebid Mobile SDK that creative is rendered through a Prebid BannerView — this is not the Teads Anchored Banner format.

Image and video

Media can serve image and video, according to your Prebid banner ad unit setup.

If you make use of other ad formats in your Prebid SDK implementation, other demand partners will continue to be able to serve your bid requests normally.

Ad Request​

No additional step should be made on your app implementation in order to request ads, just integrate your Prebid BannerView normally according to the Prebid SDK docs.

Ad Listener​

To be fully aware of Teads ad lifecycle, subscribe on your Prebid BannerView to the TeadsPBMEventListener interface.

import org.prebid.mobile.api.rendering.BannerView
import tv.teads.adapter.prebid.TeadsPBMEventListener
import android.util.Log

bannerView?.setPluginEventListener(object : TeadsPBMEventListener {
override fun onAdRatioUpdate(adRatio: AdRatio) { }
override fun onAdExpandedToFullscreen() { }
override fun onAdCollapsedFromFullscreen() { }
override fun onFailToReceiveAd(failReason: String) { }
})

Other ad events such as onAdClicked, onAdDisplayed and so on can be listened by implementing Prebid BannerViewListener and BannerVideoListener interfaces directly. Please check all events on the Prebid SDK docs.

Ad Resizing​

This part is a must and not implementing it will drastically affect the fill rate from Teads demand.

Dynamic height

Teads ads can adopt flexible dimensions. Your app must dynamically resize the ad container when the creative requests a new ratio. AdRatio.calculateHeight(width) computes the correct height.

No action is required if the ad view height is set to wrap_content. Otherwise, implement the ratio update callback to resize programmatically.

See the sample below where the containerAdView is the view group that encapsulates your BannerView

import org.prebid.mobile.api.rendering.BannerView
import tv.teads.adapter.prebid.TeadsPBMEventListener

bannerView?.setPluginEventListener(object : TeadsPBMEventListener {
override fun onAdRatioUpdate(adRatio: AdRatio) {
val adViewParams = containerAdView.layoutParams

adViewParams.height = adRatio.calculateHeight(bannerView.measuredWidth)
containerAdView.layoutParams = adViewParams
}

override fun onAdExpandedToFullscreen() { }
override fun onAdCollapsedFromFullscreen() { }
override fun onFailToReceiveAd(failReason: String) { }
})

PluginRenderer under the hood​

If you look for more understanding regarding how a plugin renderer works over the Prebid Mobile SDK, please find more here.

Prebid Server setup​

Notice that in order to turn your Teads plugin renderer fully functional and leverage from Teads demand you need to wire the Teads Adapter to your Prebid Server, please find more here.

The following configuration for each of your ad slots name is required:

{
"name": "imp-300x250-banner"
}

A placement id provided by your publisher manager is required as the sample below:

{
"ext": {
"teads": {
"placementId": 204344
}
}
}

Checklist​