AdMob
prebid_mobile_sdk_admob puts Prebid demand inside the AdMob mediation waterfall. Prebid's mediation ad units run the auction and hand the winning bid to the AdMob ad through the Prebid AdMob adapter; AdMob renders the Prebid creative or a competing AdMob ad.
Install
flutter pub add prebid_mobile_sdk prebid_mobile_sdk_admob
The package bundles the Google Mobile Ads SDK, which needs an AdMob app ID:
- Android:
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-…~…"/>inAndroidManifest.xml. - iOS:
GADApplicationIdentifierinios/Runner/Info.plist.
Initialize Google Mobile Ads once at startup (for example MobileAds.instance.initialize() from google_mobile_ads 8.0.0 or later; 7.x pins Google Mobile Ads iOS 12, which Prebid's AdMob adapters don't support). In the AdMob dashboard, add Prebid as a custom event on your ad units, as described in Prebid's AdMob integration guide.
Banner
import 'package:prebid_mobile_sdk_admob/prebid_mobile_sdk_admob.dart';
PrebidAdMobBannerAd(
configId: 'prebid-demo-banner-320-50',
adMobAdUnitId: 'ca-app-pub-3940256099942544/6300978111',
width: 320,
height: 50,
listener: PrebidBannerAdListener(
onAdLoaded: () => debugPrint('AdMob banner loaded'),
onAdImpression: () => debugPrint('impression'),
),
)
| Parameter | Description |
|---|---|
configId, adMobAdUnitId | Required. Prebid stored impression ID and AdMob ad unit ID. |
width, height | Required. The Prebid request size. The slot resizes to the rendered creative. |
additionalSizes | Further Prebid request sizes, e.g. [Size(728, 90)]. The AdMob view keeps its own size. |
adFormats | Formats Prebid requests: {PrebidAdFormat.video} for an outstream video banner, {PrebidAdFormat.banner, PrebidAdFormat.video} for a multiformat banner. null or an empty set requests a display banner. AdMob renders whichever creative wins. |
videoParameters | Video signals for a video or multiformat banner. iOS only: Prebid Android's mediation banner has no video-parameters setter, so Android sends the SDK's defaults. |
adaptive | true gives the AdMob view a landscape inline adaptive size for the full available width. The slot takes AdMob's height once the ad loads. width x height stays the Prebid request size. |
refreshIntervalSeconds | Prebid auto-refresh. Each refresh runs a new auction and reloads the AdMob view. null or 0 (default) turns it off on both platforms. Prebid clamps other values to 30–120 s on Android and 15–120 s on iOS. Turn off the AdMob unit's own refresh so the two don't stack. |
autoLoad, controller | Load on demand, or stop Prebid's refresh, with a PrebidBannerAdController (stopRefresh()). |
adPosition, impOrtbConfig | Ad position and impression-level OpenRTB JSON. |
globalOrtbConfig | Request-level OpenRTB JSON for this ad unit only. |
pbAdSlot | Prebid ad slot (imp.ext.data.pbadslot); on iOS sent in the imp JSON, since Prebid iOS has no setter on mediation units. |
gpid | Global Placement ID (imp.ext.gpid), sent in the imp JSON (a gpid already in impOrtbConfig wins). |
An adaptive banner with an extra Prebid size, as in Prebid's test app:
PrebidAdMobBannerAd(
configId: 'prebid-demo-banner-320-50',
adMobAdUnitId: 'ca-app-pub-3940256099942544/6300978111',
width: 320,
height: 50,
adaptive: true,
additionalSizes: const [Size(728, 90)],
refreshIntervalSeconds: 30,
)
Preloaded banner (feeds)
PrebidAdMobPreloadedBannerAd loads a banner before its slot is on screen and keeps it across the views showing it, so a banner in a scrolling list isn't re-auctioned each time it scrolls back. It takes the parameters above, without autoLoad and controller; see Preload a banner for the lifecycle. The banner loads before any layout, so with adaptive: true it spans width instead of measuring the available width; set adaptiveWidth (for example the screen width) to span more while width stays the Prebid request size.
final ad = PrebidAdMobPreloadedBannerAd(
configId: 'prebid-demo-banner-320-50',
adMobAdUnitId: 'YOUR_ADMOB_BANNER_AD_UNIT_ID',
width: 320,
height: 50,
);
await ad.load();
PrebidAdMobPreloadedBannerAdView(ad: ad); // in the list item
await ad.destroy(); // when the screen goes away
Interstitial and rewarded
late final PrebidAdMobInterstitialAd interstitial;
interstitial = PrebidAdMobInterstitialAd(
configId: 'prebid-demo-display-interstitial-320-480',
adMobAdUnitId: 'ca-app-pub-3940256099942544/1033173712',
listener: PrebidInterstitialAdListener(
onAdLoaded: () => interstitial.show(),
onAdClosed: () => interstitial.destroy(),
),
);
await interstitial.loadAd();
PrebidAdMobRewardedAd works the same way with a PrebidRewardedAdListener and onUserEarnedReward. Both take controls, videoParameters, impOrtbConfig, globalOrtbConfig, pbAdSlot and gpid; the interstitial takes isVideo for video demand, or adFormats (for example {PrebidAdFormat.banner, PrebidAdFormat.video} for a multiformat interstitial), which overrides isVideo. Set the interstitial's display minimum size with PrebidFullscreenControls(minSizePercentage: Size(30, 30)); rewarded ads have no minimum size or auto-close in Prebid's mediation units. supportSKOverlay doesn't apply: Prebid's mediation units have no SKOverlay setting.
Native
PrebidAdMobNativeAd(
configId: 'prebid-demo-banner-native-styles',
adMobAdUnitId: 'YOUR_ADMOB_NATIVE_AD_UNIT_ID',
listener: PrebidAdMobNativeAdListener(
onAdLoaded: () => debugPrint('native loaded'),
onAdImpression: () => debugPrint('impression'),
onAdClicked: () => debugPrint('click'),
),
)
Rendered in AdMob's NativeAdView, so AdMob tracks impressions and clicks. PrebidAdMobNativeAdListener has onAdLoaded, onAdImpression, onAdClicked, onAdOpened and onAdFailed. nativeParameters (NativeParameters) sets the requested assets, event trackers, context and request options; unset, it requests Prebid's reference assets and impression trackers, with the social, general social and in-feed context. It also takes impOrtbConfig, globalOrtbConfig, pbAdSlot and gpid (the last two sent in the imp JSON). The slot fills the parent's width (the screen width inside a Row or a horizontal list), or width, and grows from height to the rendered content.
Events
Banner, interstitial and rewarded listeners receive AdMob's onAdImpression as well as the core callbacks. show() before the ad is loaded, or without a foreground Activity / view controller, reports onAdFailed; isLoaded turns false after show(), onAdClosed and onAdFailed.
On Android, an ad that loads before PrebidMobile.initializeSdk has finished reports onAdFailed with "The Prebid SDK is not initialized". Prebid Android drops requests made before initialization without calling back, so the load would otherwise never finish and AdMob's waterfall never run. Initialize Prebid first, then load. Prebid iOS handles such requests itself.
Testing the adapter fallback
PrebidAdMob.debugDropBidProbability is a testing-only hook. Leave it at 0 in production apps. Set it between 0 and 1 and the plugin throws away the Prebid bid after the auction, with that probability, before AdMob loads. The Prebid adapter then finds no bid and AdMob falls back to its waterfall. Prebid's internal test app runs its "Random" cases at 0.5:
PrebidAdMob.debugDropBidProbability = 0.5;
Banners read the value when they are created, and roll again on every Prebid refresh. Interstitials and rewarded ads read it on each loadAd(). Native ads ignore it. On Android the plugin pops the bid from Prebid's BidResponseCache, as the test app does. Prebid iOS keeps no bid cache, so on iOS the plugin clears the Prebid extras on the AdMob request and keeps the hb_* keywords.
Compatibility
| prebid_mobile_sdk_admob | Prebid Android | Prebid iOS | Ad SDK Android | Ad SDK iOS | Tested with |
|---|---|---|---|---|---|
| 1.1.0latestOct 30, 2026 | 3.4.1 | >= 3.4.1, < 4.0 | play-services-ads 25.5.0 | Google-Mobile-Ads-SDK >= 13.0.0 | google_mobile_ads ^9.1.0 |
| 1.0.0Oct 11, 2026 | 3.4.0 | >= 3.4.1, < 4.0 | play-services-ads 25.5.0 | Google-Mobile-Ads-SDK >= 13.0.0 | google_mobile_ads ^9.1.0 |