Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/admob-plus/admob-plus/llms.txt

Use this file to discover all available pages before exploring further.

import { InterstitialAd } from 'admob-plus-cordova'

const interstitial = new InterstitialAd({
  adUnitId: 'ca-app-pub-xxx/yyy'
})

await interstitial.load()
await interstitial.show()
InterstitialAd displays full-screen ads that cover the interface of the app. They are typically displayed at natural transition points, such as between game levels or after completing a task.

Constructor

options
MobileAdOptions
required
Configuration options for the interstitial ad

Methods

load()

Loads the interstitial ad. Must be called before showing the ad.
await interstitial.load()
Returns: Promise<void>

show()

Displays the interstitial ad. The ad must be loaded first.
if (await interstitial.isLoaded()) {
  await interstitial.show()
}
Returns: Promise<void>

isLoaded()

Checks if the interstitial ad is loaded and ready to show.
const loaded = await interstitial.isLoaded()
if (loaded) {
  await interstitial.show()
}
Returns: Promise<boolean> - True if the ad is loaded, false otherwise

on()

Registers an event listener for ad events.
const unsubscribe = interstitial.on('load', (event) => {
  console.log('Interstitial loaded', event)
})

// Later, to remove the listener:
unsubscribe()
eventName
string
required
Name of the event to listen for
callback
function
required
Function to call when the event occurs
Returns: () => void - Function to remove the event listener

Properties

id
string
The unique identifier for this ad instance
adUnitId
string
The AdMob ad unit ID

Examples

Basic Usage

const interstitial = new InterstitialAd({
  adUnitId: 'ca-app-pub-xxx/yyy'
})

await interstitial.load()
await interstitial.show()

With Event Listeners

const interstitial = new InterstitialAd({
  adUnitId: 'ca-app-pub-xxx/yyy'
})

interstitial.on('load', () => {
  console.log('Interstitial loaded and ready to show')
})

interstitial.on('dismiss', () => {
  console.log('User dismissed the interstitial')
  // Load the next ad
  interstitial.load()
})

interstitial.on('show', () => {
  console.log('Interstitial is now showing')
})

interstitial.on('showfail', (event) => {
  console.error('Failed to show interstitial', event.error)
})

await interstitial.load()

Check Before Showing

const interstitial = new InterstitialAd({
  adUnitId: 'ca-app-pub-xxx/yyy'
})

await interstitial.load()

// Later, at a natural transition point
if (await interstitial.isLoaded()) {
  await interstitial.show()
} else {
  console.log('Ad not ready yet')
}

With Targeting

const interstitial = new InterstitialAd({
  adUnitId: 'ca-app-pub-xxx/yyy',
  keywords: ['game', 'puzzle'],
  contentUrl: 'https://example.com/game'
})

await interstitial.load()
await interstitial.show()

Non-Personalized Ads (GDPR)

const interstitial = new InterstitialAd({
  adUnitId: 'ca-app-pub-xxx/yyy',
  npa: '1' // Request non-personalized ads
})

await interstitial.load()
await interstitial.show()