Skip to main content
Version: v1.0.0

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();
ParameterDescription
configIdRequired. Stored impression ID.
adFormats{PrebidAdFormat.banner} (default), {PrebidAdFormat.video} or both.
videoParametersVideo signals for video demand.
controlsRendering controls.
impOrtbConfigOpenRTB JSON merged into the impression.
globalOrtbConfigRequest-level OpenRTB JSON for this ad unit only.
pbAdSlotPrebid 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).
gpidGlobal 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).
adPositioniOS only Ad position (imp.pos), e.g. PrebidAdPosition.fullScreen. Prebid Android's fullscreen units have no setter.
listenerPrebidInterstitialAdListener.

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​

  • isLoaded is true from onAdLoaded until the ad is shown, fails, closes or expires.
  • loadAd() again replaces the previous ad; the old one stops sending events.
  • show() before onAdLoaded, or with no foreground Activity / view controller, reports onAdFailed instead of failing silently.
  • onAdExpired fires when the bid's exp elapses before show(). Load again.
  • Call destroy() when you're done, typically in onAdClosed or your widget's dispose.
  • Android only winningBid holds the bid of the last load (price, bidder, size, targeting keywords), for analytics; null before a load, without a bid, and on iOS, where Prebid keeps it internal.
CallbackWhen
onAdLoadedReady to show.
onAdFailed(String)Load or show failed.
onAdDisplayedOn screen.
onAdClickedThe user tapped the creative.
onAdClosedThe user closed the ad.
onUserEarnedReward(PrebidReward)Rewarded only: the reward condition was met.
onAdExpiredThe bid expired before it was shown.
onAdImpressionMediation 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,
),
);
FieldDescriptionPlatforms
closeButtonArea, closeButtonPositionClose button size (fraction of the screen, 0..1) and corner.Both
skipButtonArea, skipButtonPosition, skipDelaySkip button size, corner, and the seconds before it appears.Interstitial: both. Rewarded: Android
isMuted, isSoundButtonVisibleStart muted; show the mute button.Both
minSizePercentageMinimum creative size as a percentage of the screen.Interstitial: both. Rewarded: iOS (core and GAM; AdMob and MAX rewarded have none)
isAutoCloseOnCompletionEnabledClose when the video completes.iOS interstitials (Prebid has no such setting for rewarded)
supportSKOverlayPresent 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.