Skip to content

Interstitial Ads

Interstitial ads are full-screen ads that cover the host app. Show them at a natural transition, such as between activities or game levels. The user can tap through or close the ad and return to the app. Google's interstitial guides for Android and iOS explain the format.

Use an interstitial when the user should not receive an in-app reward. Call this after initialize and consent. Prepare the ad ahead of time, register listeners first, and show it only when it is ready.

import { AdLoadInfo, AdMob, AdMobRevenueData, AdOptions, InterstitialAdPluginEvents } from '@capacitor-community/admob';

await AdMob.addListener(InterstitialAdPluginEvents.Loaded, (info: AdLoadInfo) => {
  console.log('Interstitial loaded', info.adUnitId);
});
await AdMob.addListener(InterstitialAdPluginEvents.FailedToLoad, console.error);
await AdMob.addListener(InterstitialAdPluginEvents.AdImpression, (data: AdMobRevenueData) => {
  console.log(data);
});

const options: AdOptions = {
  adId: 'YOUR_AD_UNIT_ID',
  // isTesting: true,
  // npa: true,
  // immersiveMode: true,
};
const { adUnitId } = await AdMob.prepareInterstitial(options);
await AdMob.showInterstitial({ adId: adUnitId });

method prepareInterstitial(...)

Loads an interstitial ad and returns the loaded ad unit ID.

prepareInterstitial(options: AdOptions) => Promise<AdLoadInfo>

method showInterstitial(...)

Shows a loaded interstitial ad.

showInterstitial(options?: AdShowOptions | undefined) => Promise<void>

interface AdOptions

Common options for requesting an ad.

Prop Type Description Default Since
adId string The ad unit ID to load. 1.1.2
isTesting boolean Whether to request a test ad. false 1.1.2
margin number The banner margin in logical display units (dp on Android and points on iOS). For BOTTOM_CENTER, this is the bottom margin. For TOP_CENTER, this is the top margin. 0 1.1.2
npa boolean Whether to request non-personalized ads. false 1.2.0
immersiveMode boolean Whether to display a full-screen ad in immersive mode on Android. 7.0.3

When no adId is passed to showInterstitial(), the most recently prepared ad is shown.

Prepare more than one ad

await AdMob.prepareInterstitial({ adId: 'ca-app-pub-xxx/interstitial-1' });
await AdMob.prepareInterstitial({ adId: 'ca-app-pub-xxx/interstitial-2' });

await AdMob.showInterstitial({ adId: 'ca-app-pub-xxx/interstitial-1' });

See Testing for isTesting.

Load, show, dismissal, and failure events are listed on Ad Events.