Google Ad Manager and AdMob mediation
- Latest Version: iOS release notes
- Sample App: Teads iOS Sample App
This article shows you how to deliver Teads ads — Media, Native, Interstitial, and Banner (Anchored) — on your application using the AdMob adapter or Google Ad Manager (GAM) Mediation adapter.
Using CocoaPods to have the Teads AdMob/GAM mediation plugin will automatically import the Teads inApp SDK framework.
Prerequisites
- Platform: iOS 14+
- Xcode: 26.2+
- Built with Swift 6.2.3
- GoogleMobileAdsSDK: >=12.2.0
- Media
- Native Ad
- Interstitial
- Banner
Installation
Before installing the Teads AdMob adapter, you will need to integrate GoogleMobileAds SDK into your application.
CocoaPods
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.
- Add Pod named
TeadsAdMobAdapterin your Podfile:
pod 'TeadsAdMobAdapter', '~> 6.2'
- Run the following to install the adapter in your project.
$ pod install --repo-update
- Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Swift Package Manager
SPM is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
Installing from Xcode
- Add a package by selecting
File→Add Packages…in Xcode’s menu bar. - Search for the Teads iOS SDK using the repo's URL:
https://github.com/teads/TeadsSDK-iOS
- Next, set the Dependency Rule to be
Up to Next Major Versionand specify6.2.1 < 7.0.0. - Choose the Teads product that you want to be installed in your app:
TeadsAdMobAdapter - Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Alternatively, add Teads to your Package.swift manifest
- Add it to the
dependenciesof yourPackage.swift:
dependencies: [
.package(url: "https://github.com/teads/TeadsSDK-iOS", .upToNextMajor(from: "6.2.1"))
]
- in any target that depends on a Teads product, add it to the
dependenciesarray of that target:
.target(
name: "MyTargetName",
dependencies: [
.product(name: "TeadsAdMobAdapter", package: "Teads"),
]
),
- Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Register the Adapter
TeadsAdMobAdapter is statically linked into your app — as a static binary framework via Swift Package Manager (since 6.2.1), and compiled from source via CocoaPods. Its custom-event classes are instantiated by name by the Google Mobile Ads SDK from your AdMob dashboard configuration, so nothing in your own code references them and the linker can strip them from optimised builds — the app then builds, launches and runs normally while Teads never serves.
Call TeadsAdMobMediation.register() once at startup, before MobileAds.shared.start(completionHandler:) or your first ad request:
import GoogleMobileAds
import TeadsAdMobAdapter
TeadsAdMobMediation.register()
MobileAds.shared.start()
It is safe to call unconditionally, with either CocoaPods or Swift Package Manager.
Adding -ObjC to Other Linker Flags on your app target has the same effect. CocoaPods integrations get it automatically from the Google Mobile Ads podspec, which is why this step has not been needed there; Swift Package Manager does not, so register() is the recommended route.
There is no crash and no error — the only symptom is zero Teads fill through mediation. Dead stripping happens in optimised builds, so check a Release build and search the console for Cannot find Custom Event class named followed by the class name you configured.
Defining a Custom Event
In order to display a Teads ad using AdMob or Google Ad Manager mediation, you need to create a custom event.
See the SDK documentation for more test PIDs serving different creative formats.
Admob
Follow the custom event documentation on the AdMob dashboard using the below values.
| Name | Value |
|---|---|
| Class Name | GADMAdapterTeadsBanner |
| Parameter | Teads placement ID (PID) |
Google Ad Manager
Follow the custom event documentation on Google Ad Manager using the below values.
| Name | Value |
|---|---|
| Class Name | GADMAdapterTeadsBanner |
| Parameter | Teads placement ID (PID) |
Integration
Note
Check out the sample ViewController from our iOS GitHub repository
You have the ability to pass extra parameters in order to customize third-party ad network settings. For Teads, you need to pass TeadsAdapterSettings.
- Create an instance of
TeadsAdapterSettingsand add the settings you want. - Register it into GADRequest calling
register
- Swift
- Objective-C
import TeadsAdMobAdapter
// 1. Create AdMob view and add it to hierarchy
admobAdView = GAMBannerView(adSize: GADAdSizeFluid)
slotView.addSubview(admobAdView)
admobAdView.translatesAutoresizingMaskIntoConstraints = false
admobAdView.centerXAnchor.constraint(equalTo: slotView.centerXAnchor).isActive = true
admobAdView.centerYAnchor.constraint(equalTo: slotView.centerYAnchor).isActive = true
// 2. Attach Delegate (will include Teads events)
admobAdView.adUnitID = pid // Replace with your adunit
admobAdView.rootViewController = self
admobAdView.delegate = self
// 3. Load a new ad (this will call AdMob and Teads afterward)
let adSettings = TeadsAdapterSettings { (settings) in
settings.pageUrl("https://example.com/article1")
}
let request = GADRequest()
// 4. Register adSettings to the request
request.register(adSettings)
admobAdView.load(request)
#import <TeadsAdMobAdapter/TeadsAdMobAdapter.h>
// 1. Create AdMob view and add it to hierarchy
self.admobAdView = [[GAMBannerView alloc] initWithAdSize:GADAdSizeFluid];
[self.slotView addSubview:self.admobAdView];
self.admobAdView.translatesAutoresizingMaskIntoConstraints = NO;
[self.admobAdView.centerXAnchor constraintEqualToAnchor:self.slotView.centerXAnchor].active = YES;
[self.admobAdView.centerYAnchor constraintEqualToAnchor:self.slotView.centerYAnchor].active = YES;
// 2. Attach Delegate (will include Teads events)
self.admobAdView.adUnitID = pid; // Replace with your adunit
self.admobAdView.rootViewController = self;
self.admobAdView.delegate = self;
// 3. Load a new ad (this will call AdMob and Teads afterward)
TeadsAdapterSettings *adSettings = [[TeadsAdapterSettings alloc] initWithBuild:^(TeadsAdapterSettings *settings) {
[settings pageUrl:@"https://example.com/article1"];
}];
GADRequest *request = [GADRequest request];
// 4. Register adSettings to the request
[request registerAdNetworkExtras:adSettings];
[self.admobAdView loadRequest:request];
Ad Resizing
⚠️ Warning
To resize the GAMBannerView you must use
GAMBannerView.resize()otherwise GAM will perform a new request each time you manipulate the view frame or constraints, this is stated on the Google for Developers official documentationKnown issue: the ad is flickering
- GoogleMobileAds ask TeadsAdapter to perform a new request
- ad is loading
- once ad is rendering, the ad ask for new ratio to better fit for the creative
- this ratio is beeing applied using frame/constraints update which is not allowed by GoogleMobileAds
- this UI move is not permitted by GoogleMobileAds, go back to step 1
The code below must be implemented to enable the resizing of the mediated ad slot making possible the rendering of square and vertical creatives.
Register to ad resizing through TeadsAdapterSettings by providing your delegate class and the GAMBannerView that need to be resized.
- Swift
- Objective-C
var admobAdView: GAMBannerView!
@IBOutlet weak var slotView: UIView!
@IBOutlet weak var slotViewHeightConstraint: NSLayoutConstraint! // set to 0 on InterfaceBuilder
let adSettings = TeadsAdapterSettings { settings in
settings.registerAdView(admobAdView, delegate: self)
}
@property (nonatomic, strong) GAMBannerView *admobAdView;
@property (nonatomic, weak) IBOutlet UIView *slotView;
@property (nonatomic, weak) IBOutlet NSLayoutConstraint *slotViewHeightConstraint; // set to 0 on InterfaceBuilder
TeadsAdapterSettings *adSettings = [[TeadsAdapterSettings alloc] initWithBuild:^(TeadsAdapterSettings *settings) {
[settings registerAdView:self.admobAdView delegate:self];
}];
Simply conform to the Teads delegate TeadsMediatedAdViewDelegate and implements the didUpdateRatio function.
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 you are responsible to retain it and destroy it when you don't need it anymore:
- Swift
- Objective-C
func didUpdateRatio(_ adView: UIView, adRatio: TeadsAdRatio) {
let height = adRatio.calculateHeight(for: slotView.frame.width) // call calculateHeight
slotViewHeightConstraint.constant = height //update NSLayoutConstraint of the slot
admobAdView.resize(GADAdSizeFromCGSize(CGSize(width: slotView.frame.width, height: height))) //call resize on GAMBannerView
}
- (void)didUpdateRatio:(UIView *)adView adRatio:(TeadsAdRatio *)adRatio {
CGFloat height = [adRatio calculateHeightForWidth:self.slotView.frame.size.width]; // call calculateHeight
self.slotViewHeightConstraint.constant = height; //update NSLayoutConstraint of the slot
[self.admobAdView resize:GADAdSizeFromCGSize(CGSizeMake(self.slotView.frame.size.width, height))]; //call resize on GAMBannerView
}
Warning
To resize the GAMBannerView you must use
GAMBannerView.resize()otherwise GAM will perform a new request each time you manipulate the view frame or constraints, this is stated on the Google for Developers official documentation
Mediation settings
Find the full settings list here
This native implementation is specifically designed to fit feed views You can customize view to look a like other cells around an offer immersive experience
Installation
Before installing the Teads AdMob adapter, you will need to integrate GoogleMobileAds SDK into your application.
CocoaPods
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.
- Add Pod named TeadsAdMobAdapter in your Podfile:
pod 'TeadsAdMobAdapter', '~> 6.2'
- Run the following to install the adapter in your project.
$ pod install --repo-update
- Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Swift Package Manager
SPM is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
Installing from Xcode
- Add a package by selecting
File→Add Packages…in Xcode’s menu bar. - Search for the Teads iOS SDK using the repo's URL:
https://github.com/teads/TeadsSDK-iOS
- Next, set the Dependency Rule to be
Up to Next Major Versionand specify6.2.1 < 7.0.0. - Choose the Teads product that you want to be installed in your app:
TeadsAdMobAdapter - Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Alternatively, add Teads to your Package.swift manifest
- Add it to the
dependenciesof yourPackage.swift:
dependencies: [
.package(url: "https://github.com/teads/TeadsSDK-iOS", .upToNextMajor(from: "6.2.1"))
]
- in any target that depends on a Teads product, add it to the
dependenciesarray of that target:
.target(
name: "MyTargetName",
dependencies: [
.product(name: "TeadsAdMobAdapter", package: "Teads"),
]
),
- Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Register the Adapter
TeadsAdMobAdapter is statically linked into your app — as a static binary framework via Swift Package Manager (since 6.2.1), and compiled from source via CocoaPods. Its custom-event classes are instantiated by name by the Google Mobile Ads SDK from your AdMob dashboard configuration, so nothing in your own code references them and the linker can strip them from optimised builds — the app then builds, launches and runs normally while Teads never serves.
Call TeadsAdMobMediation.register() once at startup, before MobileAds.shared.start(completionHandler:) or your first ad request:
import GoogleMobileAds
import TeadsAdMobAdapter
TeadsAdMobMediation.register()
MobileAds.shared.start()
It is safe to call unconditionally, with either CocoaPods or Swift Package Manager.
Adding -ObjC to Other Linker Flags on your app target has the same effect. CocoaPods integrations get it automatically from the Google Mobile Ads podspec, which is why this step has not been needed there; Swift Package Manager does not, so register() is the recommended route.
There is no crash and no error — the only symptom is zero Teads fill through mediation. Dead stripping happens in optimised builds, so check a Release build and search the console for Cannot find Custom Event class named followed by the class name you configured.
Defining a Custom Event
In order to display a Teads ad using AdMob or Google Ad Manager mediation, you need to create a custom event.
See the SDK documentation for more test PIDs serving different creative formats.
Admob
Follow the custom event documentation on the AdMob dashboard using the below values.
| Name | Value |
|---|---|
| Class Name | GADMAdapterTeadsNative |
| Parameter | Teads placement ID (PID) |
Google Ad Manager
Follow the custom event documentation on Google Ad Manager using the below values.
| Name | Value |
|---|---|
| Class Name | GADMAdapterTeadsNative |
| Parameter | Teads placement ID (PID) |
Integration
Note
Check out the sample ViewController from our iOS GitHub repository
Important
You're responsible for positioning the elements (title label, main image, call to action button...). Those elements need to be visible (without overlay, even transparent ones) otherwise our visibility algorithm will consider the ad view as hidden.
Interface
- Add a GADNativeAdView to the storyboard
- set
GADNativeAdViewas a cell property
class AdmobNativeAdTableViewCell: UITableViewCell {
@IBOutlet weak var nativeAdView: GADNativeAdView!
}
Load an Ad
You have the ability to pass extra parameters in order to customize third-party ad network settings. For Teads, you need to pass TeadsAdapterSettings.
- Create an instance of
TeadsAdapterSettingsand add the settings you want. - Register it into GADRequest calling
register
- Swift
- Objective-C
import TeadsAdMobAdapter
adLoader = GADAdLoader(adUnitID: pid, rootViewController: self,
adTypes: [ .native ], options: nil)
adLoader?.delegate = self
let adSettings = TeadsAdapterSettings { settings in
settings.enableDebug()
settings.pageUrl("https://example.com/article1")
}
let request = GADRequest()
// 4. Register adSettings to the request
request.register(adSettings)
adLoader.load(request)
#import <TeadsAdMobAdapter/TeadsAdMobAdapter.h>
self.adLoader = [[GADAdLoader alloc] initWithAdUnitID:pid
rootViewController:self
adTypes:@[ GADAdLoaderAdTypeNative ]
options:nil];
self.adLoader.delegate = self;
TeadsAdapterSettings *adSettings = [[TeadsAdapterSettings alloc] initWithBuild:^(TeadsAdapterSettings *settings) {
[settings enableDebug];
[settings pageUrl:@"https://example.com/article1"];
}];
GADRequest *request = [GADRequest request];
// 4. Register adSettings to the request
[request registerAdNetworkExtras:adSettings];
[self.adLoader loadRequest:request];
Store Ad (Sequence)
When implementing native in a tableView or collectionView we suggest to add GADNativeAd inside your sequence structure
private var elements = [GADNativeAd?]()
override func viewDidLoad() {
super.viewDidLoad()
(0..<8).forEach { _ in
elements.append(nil) //nil reprensents all other data of cells
}
...
}
implement GADNativeAdLoaderDelegate to store ad in you sequence structure
func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADNativeAd) {
elements.insert(nativeAd, at: adRowNumber)
let indexPaths = [IndexPath(row: adRowNumber, section: 0)]
tableView.insertRows(at: indexPaths, with: .automatic)
nativeAd.delegate = self
}
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? AdmobNativeAdTableViewCell else {
return UITableViewCell()
}
cell.nativeAdView.bind(ad, videoControllerDelegate: nil)
return cell
}
...
}
Bind GADNativeAd into your cell using custom func bind
extension GADNativeAdView {
func bind(_ ad: GADNativeAd, videoControllerDelegate: GADVideoControllerDelegate? = nil) {
self.nativeAd = ad
// Populate the native ad view with the native ad assets.
// The headline and mediaContent are guaranteed to be present in every native ad.
(headlineView as? UILabel)?.text = ad.headline
mediaView?.mediaContent = ad.mediaContent
mediaView?.isAccessibilityElement = true
// Some native ads will include a video asset, while others do not. Apps can use the
// GADVideoController's hasVideoContent property to determine if one is present, and adjust their
// UI accordingly.
let mediaContent = ad.mediaContent
if mediaContent.hasVideoContent, let delegate = videoControllerDelegate {
// By acting as the delegate to the GADVideoController, this ViewController receives messages
// about events in the video lifecycle.
mediaContent.videoController.delegate = delegate
}
}
}
Event Monitoring
The Admob SDK provides a delegate to monitor events during the ad life cycle and help you customize the ad experience in your apps.
protocol GADNativeAdDelegate {
// When an event click has been fired
func nativeAdDidRecordClick(_ nativeAd: GADNativeAd)
// When an impression has occured
func nativeAdDidRecordImpression(_ nativeAd: GADNativeAd)
...
}
Combining Custom-Rendered Native Ad and Banner Ad Requests
The GADAdLoader object offers the flexibility to customize ad requests, allowing them to yield either banner or native ads. By including GADAdLoaderAdTypeGAMBanner in the adTypes array parameter during the creation of the GADAdLoader object, along with native ad types like GADAdLoaderAdTypeNative, you indicate that banner ads should be considered alongside native ads in the competition to fulfill the request.
import TeadsAdMobAdapter
adLoader = GADAdLoader(adUnitID: pid, rootViewController: self,
adTypes: [ .native, **.gamBanner** ], options: nil)
adLoader?.delegate = self
let adSettings = TeadsAdapterSettings { settings in
settings.enableDebug()
settings.pageUrl("https://example.com/article1")
}
let request = GADRequest()
// 4. Register adSettings to the request
request.register(adSettings)
adLoader.load(request)
Mediation settings
Find the full settings list here
Installation
Before installing the Teads AdMob adapter, you will need to integrate GoogleMobileAds SDK into your application.
CocoaPods
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.
- Add Pod named
TeadsAdMobAdapterin your Podfile:
pod 'TeadsAdMobAdapter', '~> 6.2'
- Run the following to install the adapter in your project.
$ pod install --repo-update
- Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Swift Package Manager
SPM is a tool for managing the distribution of Swift code. It's integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
Installing from Xcode
- Add a package by selecting
File→Add Packages…in Xcode's menu bar. - Search for the Teads iOS SDK using the repo's URL:
https://github.com/teads/TeadsSDK-iOS
- Next, set the Dependency Rule to be
Up to Next Major Versionand specify6.2.1 < 7.0.0. - Choose the Teads product that you want to be installed in your app:
TeadsAdMobAdapter - Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Alternatively, add Teads to your Package.swift manifest
- Add it to the
dependenciesof yourPackage.swift:
dependencies: [
.package(url: "https://github.com/teads/TeadsSDK-iOS", .upToNextMajor(from: "6.2.1"))
]
- in any target that depends on a Teads product, add it to the
dependenciesarray of that target:
.target(
name: "MyTargetName",
dependencies: [
.product(name: "TeadsAdMobAdapter", package: "Teads"),
]
),
- Register the adapter, then follow the Defining a Custom Event step below to finish the integration.
Register the Adapter
TeadsAdMobAdapter is statically linked into your app — as a static binary framework via Swift Package Manager (since 6.2.1), and compiled from source via CocoaPods. Its custom-event classes are instantiated by name by the Google Mobile Ads SDK from your AdMob dashboard configuration, so nothing in your own code references them and the linker can strip them from optimised builds — the app then builds, launches and runs normally while Teads never serves.
Call TeadsAdMobMediation.register() once at startup, before MobileAds.shared.start(completionHandler:) or your first ad request:
import GoogleMobileAds
import TeadsAdMobAdapter
TeadsAdMobMediation.register()
MobileAds.shared.start()
It is safe to call unconditionally, with either CocoaPods or Swift Package Manager.
Adding -ObjC to Other Linker Flags on your app target has the same effect. CocoaPods integrations get it automatically from the Google Mobile Ads podspec, which is why this step has not been needed there; Swift Package Manager does not, so register() is the recommended route.
There is no crash and no error — the only symptom is zero Teads fill through mediation. Dead stripping happens in optimised builds, so check a Release build and search the console for Cannot find Custom Event class named followed by the class name you configured.
Defining a Custom Event
In order to display a Teads interstitial ad using AdMob or Google Ad Manager mediation, you need to create a custom event.
Custom Event Parameters
The custom event parameter must be a JSON string containing the following fields:
| Parameter | Type | Required | Description |
|---|---|---|---|
| articleUrl | String | Yes | The URL of the article/page |
| widgetId | String | Yes | Teads widget ID |
| installationKey | String | Yes | Teads installation key |
| pbf | Int | No | Floor price in US dollars. Forwarded to the auction as the placement floor price. |
Example JSON parameter:
{"articleUrl":"https://example.com/article","widgetId":"MB_2","installationKey":"NANOWDGT01"}
AdMob
Follow the custom event documentation on the AdMob dashboard using the below values.
| Name | Value |
|---|---|
| Class Name | GADMAdapterTeadsInterstitial |
| Parameter | JSON string (see above) |
Google Ad Manager
Follow the custom event documentation on Google Ad Manager using the below values.
| Name | Value |
|---|---|
| Class Name | GADMAdapterTeadsInterstitial |
| Parameter | JSON string (see above) |
Integration
Loading an Interstitial Ad
import GoogleMobileAds
class InterstitialViewController: UIViewController {
private var interstitialAd: InterstitialAd?
func loadAd() {
let request = Request()
InterstitialAd.load(with: "YOUR_AD_UNIT_ID", request: request) { [weak self] ad, error in
if let error = error {
print("Failed to load interstitial: \(error.localizedDescription)")
return
}
self?.interstitialAd = ad
self?.interstitialAd?.fullScreenContentDelegate = self
}
}
}
Presenting the Ad
func showAd() {
guard let interstitialAd = interstitialAd else {
print("Ad not ready")
return
}
interstitialAd.present(from: self)
}
Handling Fullscreen Content Events
Implement FullScreenContentDelegate to handle ad lifecycle events:
extension InterstitialViewController: FullScreenContentDelegate {
func adDidRecordImpression(_ ad: FullScreenPresentingAd) {
print("Ad recorded impression")
}
func adDidRecordClick(_ ad: FullScreenPresentingAd) {
print("Ad recorded click")
}
func ad(_ ad: FullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
print("Ad failed to present: \(error.localizedDescription)")
interstitialAd = nil
}
func adWillPresentFullScreenContent(_ ad: FullScreenPresentingAd) {
print("Ad will present")
}
func adWillDismissFullScreenContent(_ ad: FullScreenPresentingAd) {
print("Ad will dismiss")
}
func adDidDismissFullScreenContent(_ ad: FullScreenPresentingAd) {
print("Ad dismissed")
interstitialAd = nil
}
}
Overriding Parameters via Extras (Optional)
You can override the custom event parameters programmatically using TeadsAdapterSettings. This is useful for testing or when you need to change parameters at runtime:
- Swift
- Objective-C
import GoogleMobileAds
import TeadsSDK
let request = Request()
let adSettings = TeadsAdapterSettings { settings in
settings.addExtras("https://example.com/article", for: "articleUrl")
settings.addExtras("MB_2", for: "widgetId")
settings.addExtras("NANOWDGT01", for: "installationKey")
}
request.register(adSettings)
InterstitialAd.load(with: "YOUR_AD_UNIT_ID", request: request) { ad, error in
// ...
}
@import GoogleMobileAds;
#import <TeadsSDK/TeadsSDK.h>
GADRequest *request = [GADRequest request];
TeadsAdapterSettings *adSettings = [[TeadsAdapterSettings alloc] initWithBuild:^(TeadsAdapterSettings *settings) {
[settings addExtras:@"https://example.com/article" for:@"articleUrl"];
[settings addExtras:@"MB_2" for:@"widgetId"];
[settings addExtras:@"NANOWDGT01" for:@"installationKey"];
}];
[request registerAdNetworkExtras:adSettings];
[GADInterstitialAd loadWithAdUnitID:@"YOUR_AD_UNIT_ID"
request:request
completionHandler:^(GADInterstitialAd * _Nullable ad, NSError * _Nullable error) {
// ...
}];
When extras are provided, they take priority over the custom event parameters configured in the AdMob/GAM dashboard.
Ad Cache TTL
Interstitial ads have a cache TTL (time-to-live) configured server-side via the widget settings. Once loaded, the ad must be presented within this window or it expires. The default TTL is 3600 seconds (1 hour).
If the ad expires before being shown, ad(_:didFailToPresentFullScreenContentWithError:) is called on your FullScreenContentDelegate.
Mediation settings
Find the full settings list here
This page covers AdMob mediation. If you integrate Teads directly (no mediator), see the direct integration guide.
This section shows you how to deliver Teads anchored Banner ads on your application using the AdMob mediation adapter.
Installation
Add TeadsAdMobAdapter to your project. It includes the Teads inApp SDK as a transitive dependency. You'll also need the GoogleMobileAds SDK integrated separately.
CocoaPods
pod 'TeadsAdMobAdapter', '~> 6.2'
Swift Package Manager
Add https://github.com/teads/TeadsSDK-iOS with the Up to Next Major Version rule (6.2.1 ..< 7.0.0), then select the TeadsAdMobAdapter product.
Then register the adapter and follow Defining a Custom Event below.
Register the Adapter
TeadsAdMobAdapter is statically linked into your app — as a static binary framework via Swift Package Manager (since 6.2.1), and compiled from source via CocoaPods. Its custom-event classes are instantiated by name by the Google Mobile Ads SDK from your AdMob dashboard configuration, so nothing in your own code references them and the linker can strip them from optimised builds — the app then builds, launches and runs normally while Teads never serves.
Call TeadsAdMobMediation.register() once at startup, before MobileAds.shared.start(completionHandler:) or your first ad request:
import GoogleMobileAds
import TeadsAdMobAdapter
TeadsAdMobMediation.register()
MobileAds.shared.start()
It is safe to call unconditionally, with either CocoaPods or Swift Package Manager.
Adding -ObjC to Other Linker Flags on your app target has the same effect. CocoaPods integrations get it automatically from the Google Mobile Ads podspec, which is why this step has not been needed there; Swift Package Manager does not, so register() is the recommended route.
There is no crash and no error — the only symptom is zero Teads fill through mediation. Dead stripping happens in optimised builds, so check a Release build and search the console for Cannot find Custom Event class named followed by the class name you configured.
Defining a Custom Event
In order to display a Teads anchored Banner using AdMob mediation, you need to create a custom event.
Follow the custom event documentation on the AdMob dashboard using the values below.
| Name | Value |
|---|---|
| Class Name | GADMAdapterTeadsBanner |
| Parameter | JSON string (see below) |
Custom Event Parameter
The parameter must be a JSON string. The adapter routes to the anchored Banner path as soon as the JSON contains the three required keys (articleUrl, widgetId, installationKey).
| Parameter | Type | Required | Description |
|---|---|---|---|
| articleUrl | String | Yes | The URL of the article/page |
| widgetId | String | Yes | Teads widget ID |
| installationKey | String | Yes | Teads installation key |
| widgetIndex | Int | No | Index when multiple widgets share the same page (default 0) |
| userId | String | No | Publisher-provided user identifier |
| darkMode | Bool | No | Enable dark mode theme (default false) |
| extId | String | No | External tracking id |
| extSecondaryId | String | No | Secondary external tracking id |
| obPubImp | String | No | Publisher impression id override |
| pbf | Int | No | Floor price in US dollars. Forwarded to the auction as the placement floor price. |
For testing purposes, use the following:
{"articleUrl":"https://mobile-demo.outbrain.com/","widgetId":"MB_10","installationKey":"NANOWDGT01"}
For production, your articleUrl, widgetId, and installationKey will be unique values provided by your product manager. Contact your local account manager to obtain your production parameters.
Integration
Initialize Google Mobile Ads
Initialize the Google Mobile Ads SDK once at app launch, before loading any ads:
import GoogleMobileAds
MobileAds.shared.start(completionHandler: nil)
Load and Display the Banner
Add a BannerView to your view hierarchy, configure it with your ad unit id and the fixed AdSizeBanner size, disable autoload, then call load(_:).
import UIKit
import GoogleMobileAds
final class BannerViewController: UIViewController {
private var bannerView: BannerView!
override func viewDidLoad() {
super.viewDidLoad()
// 1. Build the banner view with a fixed banner size (320×50pt).
bannerView = BannerView(adSize: AdSizeBanner)
bannerView.adUnitID = "YOUR_AD_UNIT_ID" // Ad unit id configured on your AdMob dashboard
bannerView.rootViewController = self
// 2. Disable autoloading so the ad loads only via the explicit load(_:)
// call below, not automatically.
bannerView.isAutoloadEnabled = false
// 3. Pin centre + bottom to your view.
bannerView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(bannerView)
NSLayoutConstraint.activate([
bannerView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
bannerView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
// 4. Load the ad.
bannerView.load(Request())
}
}
AdSizeBanner requests a fixed 320×50pt slot from the AdMob waterfall. Adaptive sizes such as currentOrientationAnchoredAdaptiveBanner re-resolve when the banner's bounds change (rotation, SwiftUI layout passes), which can trigger duplicate ad requests; the fixed size is invariant. The Teads creative still resizes its own height inside the slot via the JS engine.
Mediation settings
Find the full settings list in the Integration Guide and Settings Configuration.
Check list
- Ensure Brand Safety is enabled
- Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
- Comply with app-ads.txt
- Test with different JSON parameter configurations
- Enable validation mode to ensure key features are working
- Implement proper error handling
- Test on different devices and screen sizes