Native Ad - MoPub mediation

This native implementation is specifically designed to fit feed views
You can customize the ad view to look like the other cells around, to offer a more immersive experience.

This article shows you how to deliver Teads Native ads in your application using the Mopub Mediation adapter.

Using CocoaPods to have Teads AdMob/GAM mediation plugin will automatically import the Teads inApp SDK framework.

Sample App on GitHub
Teads inApp SDK iOS sample App


  • Platform: iOS 10+
  • Xcode: 12.1+
  • MoPub SDK: 5.13+


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


If your project is managing dependencies through CocoaPods, you just need to add this pod in your Podfile.

It will install the Teads adapter along with the Teads inApp SDK.

  1. Add Pod named TeadsMoPubAdapter your Podfile:
pod 'TeadsMoPubAdapter', '~> 5.0'
  1. Run the following to install the adapter in your project.
$ pod install --repo-update to install
  1. Follow the Defining a Custom Event step below to finish the integration.


  1. Integrate the latest version of the Teads inApp SDK to your project.
  2. Download the latest release of TeadsAdMobAdapter.
  3. Drop adapter files in your iOS project.
  4. Follow the Defining a Custom Event step below to finish the integration.

Defining a Custom Event

In order to display a Teads ad using MoPub, you need to create a custom event.

See this article for more test PIDs serving different creative formats.

Name Value
Custom Event Class TeadsMoPubAdapter.MPAdapterTeadsNative
Custom Event Class Data {"PID": "#PID#"}


Don't forget to replace the #PID# with your Teads placement ID.



You're responsible for elements positioning: title label, main image, call to action button, …. These elements need to be visible (without overlay, even transparent ones) otherwise our visibility algorithm will consider the ad view as hidden.


  1. Add a MoPubNativeAdView to the storyboard
class MoPubNativeAdView: UIView {
    @IBOutlet private weak var titleLabel: UILabel!
    @IBOutlet private weak var mainTextLabel: UILabel!
    @IBOutlet private weak var iconImageView: UIImageView!
    @IBOutlet private weak var callToActionLabel: UILabel!
    @IBOutlet private weak var mainImageView: UIImageView!
    @IBOutlet private weak var sponsoredByLabel: UILabel!

Load an Ad

Register a custom View, this view will handle ad binding

let settings = MPAdapterTeadsNativeAdRendererSettings()

settings.renderingViewClass = MoPubNativeAdView.self

let config: MPNativeAdRendererConfiguration =
    MPAdapterTeadsNativeAdRenderer.rendererConfiguration(with: settings)

let adRequest: MPNativeAdRequest = MPNativeAdRequest(adUnitIdentifier: pid, rendererConfigurations: [config])

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

  • Register your TeadsAdSettings into MPNativeAdRequestTargeting using register.
let targeting: MPNativeAdRequestTargeting = MPNativeAdRequestTargeting()
targeting.desiredAssets = [kAdTitleKey, kAdTextKey, kAdCTATextKey, kAdIconImageKey, kAdMainImageKey, kAdStarRatingKey, kAdSponsoredByCompanyKey]

let adSettings = TeadsAdapterSettings { (settings) in
targeting.register(teadsAdSettings: adSettings)
adRequest.targeting = targeting

adRequest.start { [weak self] (request, response, error) in
    if let error = error {
        print("Error: \(error.localizedDescription)")
    } else if let ad = response {

Store Ad (Sequence)

When implementing native in a tableView or collectionView we suggest adding MPNativeAd inside your sequence structure

private var elements = [MPNativeAd?]()

override func viewDidLoad() {

    (0..<8).forEach { _ in
        elements.append(nil) //nil reprensents all other data of cells

implement a custom func to handle storage process

// custom func, called from `adRequest.start` closure
func didReceiveAd(_ ad: MPNativeAd) {
    ad.delegate = self
    self.elements.insert(ad, at: self.adRowNumber)
    let indexPaths = [IndexPath(row: self.adRowNumber, section: 0)]
    self.tableView.insertRows(at: indexPaths, with: .automatic)

Ad Binding

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    if let ad = elements[indexPath.row] {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: teadsAdCellIndentifier, for: indexPath) as? MoPubNativeTableViewCell else {
            return UITableViewCell()

        if let av = try? ad.retrieveAdView() {
            av.frame = cell.nativeAdView.bounds
            av.autoresizingMask = [.flexibleHeight, .flexibleWidth]

        cell.nativeAdView.isHidden = false
        return cell

Event Monitoring

The Mopub SDK provides a delegate to monitor events during the ad life cycle and help you customize the ad experience in your apps.

protocol MPNativeAdDelegate {
    // implement this in order for TeadsSDK to be able to count clicks
    func viewControllerForPresentingModalView() -> UIViewController! {
        return self
    // When an impression has occured
    func nativeAdDidRecordImpression(_ nativeAd: GADNativeAd)

Mediation settings

Find the full settings list here

Did you find it helpful? Yes No

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