Implement a custom mediation adapter on iOS

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

  1. Overview
  2. Custom adapter implementation
    1. Adapter class
    2. Adapter delegate
    3. Client parameters
    4. Overridable views
  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 delegate.

SmartSDK / Third Party SDK with intermediate Adapter

This page is focused on custom adapter implementation on iOS. 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 must be a class that implement a SASMediationAdapter protocol. The Smart Display SDK gives you 4 protocols to implement depending on which ad format you want to mediate:

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

Please note that all methods MUST be overriden for your adapter to work properly: incomplete adapter implementation can lead to crashes.

Adapter delegate

When implementing an adapter, you will retrieve an adapter delegate from the adapter init: method. This delegate can be used to forward information about the third party SDK to the Smart Display SDK.

While some of these info are optional, some other delegate methods must be called otherwise the mediation might not work as expected (no ad display, not waterfall, no impression counting, …).

The following sections list the required delegate methods for each adapter type:

Banner adapter delegate

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

Interstitial adapter delegate

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

Rewarded video adapter delegate

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

Native ad adapter delegate

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

Client parameters

The Smart Display SDK will provide to all adapters a dictionary called clientParameters for the ad requests. This dictionary contains several useful information that can be used when developing the adapter.

Here are the keys you can expect to find in the clientParameters dictionary:

Key Description
Misc Client parameters
SASMediationClientParameterLocation The current user location, if available
SASMediationClientParameterAdViewSize The current ad view size (only for banners)
GDPR client parameters
SASMediationClientParameterGDPRApplies Boolean that states if GDPR applies for this particular app/user
SASMediationClientParameterGDPRConsent Consent string associated with this user if any

Overridable views (native ads only)

The Smart Display SDK will provide to native ad adapters a dictionary called overridableViews during ad registering. This dictionary contains references to views that you might want to replace by views provided by the third party SDK.

Here are the keys you can expect to find in the overridableViews dictionary:

Key Description
SASMediationOverridableNativeAdMediaView The view used to display a video media
SASMediationOverridableAdChoicesView The button used to redirect the user to the privacy policy

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.