Interstitial & rewarded
Fullscreen ads follow a load → show → destroy lifecycle. Both classes present from the top-most view controller (iOS) or the current Activity (Android).
Interstitial
late final PrebidInterstitialAd interstitial;
interstitial = PrebidInterstitialAd(
configId: 'prebid-demo-display-interstitial-320-480',
adFormats: const {PrebidAdFormat.banner, PrebidAdFormat.video},
listener: PrebidInterstitialAdListener(
onAdLoaded: () => interstitial.show(),
onAdFailed: (error) => debugPrint('failed: $error'),
onAdClosed: () => interstitial.destroy(),
),
);
await interstitial.loadAd();
| Parameter | Description |
|---|---|
configId | Required. Stored impression ID. |
adFormats | {PrebidAdFormat.banner} (default, on both platforms), {PrebidAdFormat.video} or both. |
videoParameters | Video signals for video demand. |
controls | Rendering controls. |
impOrtbConfig | OpenRTB JSON merged into the impression. |
globalOrtbConfig | Request-level OpenRTB JSON for this ad unit only. |
pbAdSlot | Prebid ad slot (imp.ext.data.pbadslot). Prebid iOS has no setter here, so on iOS the plugin adds it to the imp JSON (a pbadslot in impOrtbConfig wins). |
gpid | Global Placement ID (imp.ext.gpid). Neither SDK has a setter on these units, so the plugin adds it to the imp JSON (a gpid in impOrtbConfig wins). |
adPosition | iOS only Ad position (imp.pos), e.g. PrebidAdPosition.fullScreen. Prebid Android's fullscreen units have no setter. |
listener | PrebidInterstitialAdListener. |
Rewarded
late final PrebidRewardedAd rewarded;
rewarded = PrebidRewardedAd(
configId: 'prebid-demo-video-rewarded-320-480',
listener: PrebidRewardedAdListener(
onAdLoaded: () => rewarded.show(),
onUserEarnedReward: (reward) => debugPrint('${reward.count} ${reward.type}'),
onAdClosed: () => rewarded.destroy(),
),
);
await rewarded.loadAd();
PrebidRewardedAd takes the same videoParameters, controls, impOrtbConfig, globalOrtbConfig, pbAdSlot, gpid and adPosition as the interstitial, plus adFormats (iOS only: Prebid Android's rewarded unit always asks for both). On Android only videoParameters.maxDuration applies, as for the interstitial.
PrebidReward carries type, count and the creative's optional ext map. The reward rules (after a playback event, after a time, on completion) come from the bid's rewarded configuration on Prebid Server.
Lifecycle
isLoadedis true fromonAdLoadeduntil the ad is shown, fails, closes or expires.loadAd()again replaces the previous ad; the old one stops sending events.show()beforeonAdLoaded, or with no foreground Activity / view controller, reportsonAdFailedinstead of failing silently. Without an Activity / view controller the ad is kept, so a latershow()can still present it.- A load replaces the ad's previous load. To preload the next ad on the same object, wait for
onAdClosed: loading while an ad is on screen drops its remaining events (its close, a reward). onAdExpiredfires when the bid'sexpelapses beforeshow(). Load again.- Call
destroy()when you're done, typically inonAdClosedor your widget'sdispose. winningBidholds the bid of the last load (price, bidder, size, targeting keywords), for analytics;nullbefore a load and without a bid.
| Callback | When |
|---|---|
onAdLoaded | Ready to show. |
onAdFailed(String) | Load or show failed. |
onAdDisplayed | On screen. |
onAdClicked | The user tapped the creative. |
onAdClosed | The user closed the ad. |
onUserEarnedReward(PrebidReward) | Rewarded only: the reward condition was met. |
onAdExpired | The bid expired before it was shown. |
onAdImpression | Mediation only (AdMob, MAX). |
Rendering controls
PrebidInterstitialAd(
configId: 'prebid-demo-video-interstitial-320-480',
adFormats: const {PrebidAdFormat.video},
controls: const PrebidFullscreenControls(
closeButtonPosition: PrebidButtonPosition.topLeft,
closeButtonArea: 0.1,
skipDelay: 5,
isMuted: true,
isSoundButtonVisible: true,
),
);
| Field | Description | Platforms |
|---|---|---|
closeButtonArea, closeButtonPosition | Close button size (fraction of the screen, 0..1) and corner. | Both |
skipButtonArea, skipButtonPosition, skipDelay | Skip button size, corner, and the seconds before it appears. | Interstitial: both. Rewarded: Android |
isMuted, isSoundButtonVisible | Start muted; show the mute button. | Both |
minSizePercentage | Minimum creative size as a percentage of the screen. | Interstitial: both. Rewarded: iOS (core and GAM; AdMob and MAX rewarded have none) |
isAutoCloseOnCompletionEnabled | Close when the video completes. | iOS interstitials (Prebid has no such setting for rewarded) |
supportSKOverlay | Present an SKOverlay (App Store sheet) for SKAdNetwork ads. | iOS only |
Every field is optional: null keeps the SDK default.
Video parameters on Android
Prebid Android's rendering interstitial and rewarded units have no video-parameters setter, so the request carries the SDK's defaults and videoParameters.maxDuration only caps the length of the rendered video. iOS sends every field. See Platform differences.