Implement a custom mediation adapter on Android

With the open mediation you are now able to implement your own mediation adapter. This page describes how to proceed on Android.

  1. Overview
  2. Custom adapter implementation
    1. Adapter class
    2. Adapter listener
    3. Client parameters
  3. Implementation samples

Overview

The Smart Display SDK cannot use a third party SDK directly.

It must instead call an intermediate component called an adapter that will be responsible of retrieving an ad from the third party SDK. This adapter will then forward the ad to the Smart Display SDK through an adapter listener.

SmartSDK / Third Party SDK with intermediate Adapter

This page is focused on the custom adapter implementation on Android. For general information about the mediation, check the 'mediation as a primary SDK' section of this documentation.

Custom adapter implementation

Adapter class

Your custom adapter class must implement one of the 4 following interfaces, depending on the ad format you want to mediate:

The methods that must be implemented depends on the chosen adapter, check the API documentation for exhaustive information.

Adapter listener

When implementing an adapter, you will receive a specific adapter listener object, implementing the SASMediationAdapterListener interface as a parameter in the method that requests a mediation ad call (requestBannerAd() for a banner, requestInterstitialAd() for an interstitial, and so on). This listener object acts as a callback that will notify the Smart Display SDK of the third party SDK ad lifecycle events.

The following sections list the adapter listener methods for each adapter type:

Banner adapter listener

When implementing a banner adapter, you MUST at least call these listener methods:

Interstitial adapter listener

When implementing an interstitial adapter, you MUST at least call these listener methods:

Rewarded video adapter listener

When implementing an rewarded video adapter, you MUST at least call these listener methods:

Native ad adapter listener

When implementing an native ad adapter, you MUST at least call these listener methods:

Client parameters

The Smart Display SDK will provide to all adapters (in the methods that request a mediation ad) a clientParameters Map<String,String> object for the ad requests. This Map contains useful information that can be used when implementing the adapter.

Here are the keys you can expect to find in the clientParameters Map (those key are constants of the SASMediationAdapter interface):

Key Description
Misc Client parameters
AD_VIEW_HEIGHT_KEY The current ad view height (only for banners)
AD_VIEW_WIDTH_KEY The current ad view width (only for banners)
GDPR client parameters
GDPR_APPLIES_KEY Boolean that states if GDPR applies for this particular app/user
GDPR_CONSENT_KEY Consent string associated with this user if any

Implementation samples

Smart provides open source adapters for some common third party SDK, you can use them as implementation samples for your own custom adapter.