Jump to top

InterstitialAd

interface

A class for interacting and showing Interstitial Ads.

An Interstitial advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level in a game. An Interstitial is a full screen advert, laid on-top of your entire application which the user can interact with. Interactions are passed back via events which should be handled accordingly inside of your app.

Example

First create a new Interstitial instance, passing in your Ad Unit ID from the Firebase console, and any additional request options. The example below will present a test advert, and only request a non-personalized ad.

import { InterstitialAd, TestIds } from '@react-native-firebase/admob';

const interstitial = InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {
    requestNonPersonalizedAdsOnly: true,
});

Each advert needs to be loaded from AdMob before being shown. It is recommended this is performed before the user reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup event listeners to listen for updates from AdMob, such as advert loaded or failed to load.

Event types match the AdEventType interface. Once the advert has loaded, we can trigger it to show:

import { AdEventType } from '@react-native-firebase/admob';

interstitial.onAdEvent((type) => {
  if (type === AdEventType.LOADED) {
    interstitial.show();
  }
});

interstitial.load();

The advert will be presented to the user, and several more events can be triggered such as the user clicking the advert or closing it.

Properties

adUnitId

</>

The Ad Unit ID for this AdMob ad.

adUnitId: string;

loaded

</>

Whether the advert is loaded and can be shown.

loaded: boolean;

Methods

load

</>

Start loading the advert with the provided RequestOptions.

load(): void;

onAdEvent

</>

Listen to ad events. See AdEventTypes for more information.

onAdEvent(listener: AdEventListener): () => void;

show

</>

Show the loaded advert to the user.

show(showOptions?: AdShowOptions): Promise<void>;

createForAdRequest

</>

Creates a new InterstitialAd instance.

createForAdRequest(adUnitId: string, requestOptions?: RequestOptions): InterstitialAd;