Login
Welcome
Login

Google Ad Manager and AdMob mediation - inRead


This article shows you how to deliver Teads ads on your application using the AdMob adapter or Google Ad Manager (GAM) Mediation adapter.

Sample App on GitHub
Teads inApp SDK Flutter sample App

Prerequisites

Flutter

  • Flutter: >= 2.5.0

iOS

  • Teads iOS SDK: >= 5.0.22
  • Teads iOS Admob adapter: >= 5.0.22
  • Platform: iOS 10+ (99% of the devices)

Android

  • Teads Android SDK: >= 5.0.22
  • Teads Android Admob adapter: >= 5.0.22

Installation

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

Using packages

To add the package, teads_admob_adapter, to an app:

  1. Depend on it
    • Open the pubspec.yaml file located inside the app folder, and add teads_admob_adapter: under dependencies.
  2. Install it
    • From the terminal: Run flutter pub get.

      OR
    • From Android Studio/IntelliJ: Click Packages get in the action ribbon at the top of pubspec.yaml.

      OR
    • From VS Code: Click Get Packages located in right side of the action ribbon at the top of pubspec.yaml.
  3. Import it
    • Add a corresponding import statement in the Dart code.

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 this article for more test PIDs serving different creative formats.

Follow the custom event documentation on the AdMob dashboard using the below values.

Or

Follow the custom event documentation on Google Ad Manager using the below values.

iOS

Name Value
Class Name TeadsAdMobAdapter.GADMAdapterTeadsBanner
Parameter Teads placement ID (PID)

Android

Name Value
Class Name tv.teads.adapter.admob.TeadsAdapter
Parameter Teads placement ID (PID)

Integration

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

  • Create an instance of TeadsAdapterSettings and add the settings you want before loading an ad.
Future<void> _requestAd() async {
    // Instantiate an AdManagerAdRequest object
    AdManagerAdRequest request = const AdManagerAdRequest();

    // Create custom Teads settings
    TeadsAdapterSettings settings = TeadsAdapterSettings();
    await settings.enableDebug();

    // Create an AdSize for landscape creatives
    double width = MediaQuery.of(context).size.width;
    _adSize = AdSize(width: width.toInt(), height: width ~/ (16/9));

    // Prepare the ad object
    setState(() {
        _bannerAd = AdManagerBannerAd(
        sizes: [_adSize],
        adUnitId: _adUnit,
        request: request,
        listener: AdManagerBannerAdListener(
            // Called when an ad is successfully received.
            onAdLoaded: (Ad ad) => print('Ad loaded.'),
            // Called when an ad request failed.
            onAdFailedToLoad: (Ad ad, LoadAdError error) {
            // Dispose the ad here to free resources.
            ad.dispose();
            print('Ad failed to load: $error');
            },
            // Called when an ad opens an overlay that covers the screen.
            onAdOpened: (Ad ad) => print('Ad opened.'),
            // Called when an ad removes an overlay that covers the screen.
            onAdClosed: (Ad ad) => print('Ad closed.'),
            // Called when an impression occurs on the ad.
            onAdImpression: (Ad ad) => print('Ad impression.'),
        ),
        );
        _bannerAd?.load();
    });
}

iOS

In your AppDelegate, in the didFinishLaunchingWithOptions function, add the following:

import google_mobile_ads
import teads_admob_adapter

override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    GeneratedPluginRegistrant.register(with: self)

    ...
    FLTGoogleMobileAdsPlugin.register(FLTTeadsMediationNetworkExtras(), registry: self)
    ...

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

Android

In your MainActivity, in the configureFlutterEngine function, add the following:

import io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin
import tv.teads.teadsadmobadapter.teads_admob_adapter.FLTTeadsMediationInReadNetworkExtras

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
    super.configureFlutterEngine(flutterEngine)

    ...
    GoogleMobileAdsPlugin.registerMediationNetworkExtrasProvider(
        flutterEngine, FLTTeadsMediationInReadNetworkExtras()
    )
    ...

}

Ad Resizing

The teads_admob_adapter does not support ad resizing.

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.