Login
Welcome
Login

Smart Ad mediation

This article shows you how to deliver Teads ads on your application using the Smart Ads Server adapter.


Requirements

  • Platform: iOS 9+
  • Xcode: 11.0+
  • TeadsSDK >= 4.8.0
  • Smart-Display-SDK >= 7.6.2

Installation

Before installing the Teads adapter, you will need to integrate Smart Ads Server into your application.

Using CocoaPods to have Teads Smart Ads Server mediation plugin will automatically import the Teads SDK framework.

https://documentation.smartadserver.com/displaySDK/ios/gettingstarted.html

CocoaPods

pod 'TeadsSASAdapter'

Defining a Custom Event

In order to display a Teads ad using Smart, you'll need to use the custom adapter template with these parameters:

Name

Value

SDK Name

TeadsSDK

Ad Format Type

Banner

Adapter Class

TeadsSASAdapter.TeadsSASBannerAdapter

Placement Info

{ "placementId": 84242, "teadsAdSettingsKey": "[sas_kw|teadsAdSettingsKey]" }

The placement Id   is a demo one provided for testing purposes only. 

See this article to find test PIDs serving different creative formats.

Please ensure you replaced it with the one provided by your publisher manager for production delivery.

Mediation settings

You have the ability to pass extra parameters in order to customize third-party ad network settings. For Teads, you need to instantiate a TeadsAdSettingss

let teadsAdSettings = TeadsAdSettings { (settings) in

settings.enableDebug()

settings.pageUrl("https://yourwebsite.com/yourarticle")

}

Then add it your keywords using the TeadsSASAdapterHelper

var keywordsTargetting = "lemondekw=titi"

keywordsTargetting = TeadsSASAdapterHelper.concatAdSettingsToKeywords(keywordsStrings: keywordsTargetting, adSettings: teadsAdSettings)

// Create a placement

let adPlacement = SASAdPlacement(siteId: webSiteId, pageId: pageId, formatId: formatId, keywordTargeting: keywordsTargetting)



If you have no keywords you can simply create a new variable keywords that way

If you have no keywords you can simply create a new variable keyword that way

let keywordsTargetting = TeadsSASAdapterHelper.teadsAdSettingsToString(adSettings: teadsAdSettings)

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.

Subscribe to ad resizing through Teads Ad Settings by providing your delegate class and the adView that need to be resized

let teadsAdSettings = TeadsAdSettings { (settings) in

try? settings.subscribeAdResizeDelegate(self, forAdView: banner)

}

Simply conform to the Teads delegate TFAMediatedAdViewDelegate and implements the didUpdateRatio function.

class YourViewController : UIViewController, SASBannerViewDelegate, TFAMediatedAdViewDelegate

func didUpdateRatio(_ adView: UIView, ratio: CGFloat) {

let width = adView.bounds.width

bannerHeightConstraint?.constant = width / ratio

}

Requirements

  • AndroidX (⚠️ SmartSDK mandatory)

  • Android SDK: 19+

  • SmartCoreSdk: 7.8.0+

  • SmartDisplaySdk: 7.8.0+

Installation

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

Gradle

app build.gradle

Following JFrog announcement that Bintray will be deprecated from may 1st 2021, Teads SDK is now relying on Artifactory as an alternative hosting solution. More info.

// Teads Repository
repositories{
maven {
url "https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod"
}
maven {
// Mandatory for Huawei device compatibility
url "https://developer.huawei.com/repo/"
}
}

Next, in the same file, edit the app dependencies node:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'

// Add Smart Display SDK
implementation 'com.smartadserver.android:smart-display-sdk:7.8.0@aar'
implementation 'com.smartadserver.android:smart-core-sdk:7.8.0@aar'

// Add dependencies required by Smart Display SDK
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.google.android.exoplayer:exoplayer:2.12.0'

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

// Adapter helper
implementation("tv.teads.sdk.android:adapterhelper:X.Y.Z@aar")

// Teads Smart Adapter
implementation 'tv.teads.sdk.android:smartadapter:X.Y.Z'

// Mandatory for Huawei device compatibility
implementation 'com.huawei.hms:ads-identifier:3.4.28.313'

implementation 'com.huawei.hms:location:4.0.2.300'
}

Replace the X.Y.Z above with the latest release version.

Defining a Custom Event

In order to display a Teads ad using Smart, you'll need to use the custom adapter template with these parameters:

Name

Value

SDK Name

TeadsSDK

Ad Format Type

Banner

Adapter Class

tv.teads.adapter.smart.SmartBannerAdapter

Placement Info

{ "placementId": 84242, "teadsAdSettingsKey": "[sas_kw|teadsAdSettingsKey]" }

The placement Id 84242 is a demo one provided for testing purposes only. 

See this article to find test PIDs serving different creative formats.

Please ensure you replaced it with the one provided by your publisher manager for production delivery.

Mediation settings

You have the ability to pass extra parameters in order to customize third-party ad network settings. For Teads, you need to use AdSettings class to pass extra parameters.

  1. Create an instance of AdSettings.Builder.

  2. Populate it with your custom settings.

  3. Set the adapter listener to have to correct ad ratio.

  4. Set the userConsent to be compliant with GDPR.

  5. Set the UsPrivacy to be compliant with CCPA.

  6. Set the pageUrl if you are in article placement to enable brand safety

  7. Register it into SASAdPlacement while instantiating it in the target field thanks to SmartHelper getTargetFromTeadsAdSettings method.

  8. Teads ads will receive your specific custom settings when it will load.

// Create extra parameters for Teads
AdSettings.Builder builder = new AdSettings.Builder()
.enableDebug() // Enable debug mode
.userConsent("subjectToGDPR", "consentString") // Enable GDPR support
.setUsPrivacy("1YNN") // Enable CCPA support
.pageUrl("https://page.com/article1/") // Enable BrandSafety
.addAdapterListener(key) // See specific section
.enableValidationMode(); // Enable Validation Mode (for test only)

AdSettings settings = builder.build();

// Smart: Create ad placement
SASAdPlacement adPlacement = SASAdPlacement("YOUR_SITE_ID", "YOUR_PAGE_NAME", "YOUR_FORMAT_ID", SmartHelper.getTargetFromTeadsAdSettings(adSettings), supplyChainObjectString)

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:

mListener = new TeadsBannerAdapterListener() {
@Override
public void onRatioUpdated(float adRatio) {
ViewGroup.LayoutParams params = adFrame.getLayoutParams();

// Here the width is MATCH_PARENT
params.height = Math.round(params.width / adRatio);

adFrame.setLayoutParams(params);
}
};

Important: we require ONE listener per ad experience to resize the correct ad

Please use the helper to attach a listener, it will return you the UNIQUE of the current listener attached.
int key = TeadsHelper.attachListener(mListener);

Finally, add it to your current ad settings for the specific ad request, see Ad Settings

AdSettings adSettings = new AdSettings.Builder()
.addAdapterListener(key).build();





Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.