<br />

Interstitial ads are full-screen ads that appear at transition points in your
app, such as between screens or during the pause between levels in a game.
Your users can tap the ad to visit the destination, or close the ad and return
to the app. For details, see

[Interstitial ad guidance](https://support.google.com/admob/answer/6066980) and a
[case study](https://admob.google.com/home/resources/freaking-math-powers-revenue-increase-with-google-admob-support/).


This guide shows you how to integrate interstitial ads into a React Native
app.

## Prerequisites

- [Set up Google Mobile Ads SDK for React Native](https://developers.google.com/admob/react-native/quick-start.md.txt).
- [Enable test ads](https://developers.google.com/admob/react-native/test-ads.md.txt) and use the following test ad unit ID:

### Android

    ca-app-pub-3940256099942544/1033173712

### iOS

    ca-app-pub-3940256099942544/4411468910

## Load an ad

To load an interstitial ad, call the [`load`](https://developers.google.com/admob/react-native/reference/class/InterstitialAd.md.txt#InterstitialAd.load)
method on the [`InterstitialAd`](https://developers.google.com/admob/react-native/reference/class/InterstitialAd.md.txt) class.

The following example loads an interstitial ad on success and logs an error
on failure:

```tsx
export async function loadInterstitialAd(
  adUnitId: string,
): Promise<InterstitialAd | null> {
  try {
    const ad = await InterstitialAd.load({adUnitId});
    return ad;
  } catch (error) {
    const loadError = error as LoadAdError;
    console.error('Failed to load interstitial ad:', loadError.message);
    return null;
  }
}
```

## Listen for ad events

Before you show the ad, set the
[`adEventCallback`](https://developers.google.com/admob/react-native/reference/class/InterstitialAd.md.txt#InterstitialAd.adEventCallback) listener on the
loaded [`InterstitialAd`](https://developers.google.com/admob/react-native/reference/class/InterstitialAd.md.txt) instance. This listener
receives callbacks for ad lifecycle events, such as the ad showing on the
screen or a user tapping the ad. For available callbacks, see
[`AdEventCallback`](https://developers.google.com/admob/react-native/reference/interface/AdEventCallback.md.txt).

The following example sets callbacks to listen for ad events:

```tsx
export function registerAdEvents(ad: InterstitialAd) {
  ad.adEventCallback = {
    // Called when the ad is presented on screen.
    onAdShowedFullScreenContent: () => {
      console.log('Interstitial ad showed full screen content.');
    },
    // Called when the ad is closed by the user.
    onAdDismissedFullScreenContent: () => {
      console.log('Interstitial ad dismissed full screen content.');
      ad.destroy();
    },
    // Called when presentation fails.
    onAdFailedToShowFullScreenContent: (error) => {
      console.error('Failed to show interstitial ad:', error);
      ad.destroy();
    },
    // Called when an impression is recorded.
    onAdImpression: () => {
      console.log('Interstitial ad recorded an impression.');
    },
    // Called when the user taps the ad.
    onAdClicked: () => {
      console.log('Interstitial ad was clicked.');
    },
    // Called when the ad is estimated to have earned money.
    onAdPaid: (adValue) => {
      console.log(
        `Interstitial ad paid: ${adValue.amountMicros}` +
          ` ${adValue.currencyCode}`,
      );
    },
  };
}
```

This example also calls the `destroy` method when a user closes the
ad or when the ad fails to show. This process releases the resources the ad
used.

## Show the ad

To show an interstitial ad, call the [`show`](https://developers.google.com/admob/react-native/reference/class/InterstitialAd.md.txt#InterstitialAd.show)
method on the loaded [`InterstitialAd`](https://developers.google.com/admob/react-native/reference/class/InterstitialAd.md.txt) instance.

The following example shows an interstitial ad:

```tsx
export function showInterstitialAd(ad: InterstitialAd) {
  ad.show();
}
```

## View the full example

This section covers the full example to integrate an interstitial ad
into a React Native app.

The following example integrates the ad into a React Native component,
manages the ad instance in state, and provides controls to load
and display the ad:

```tsx
export function InterstitialSingleLoadScreen() {
  const [ad, setAd] = useState<InterstitialAd | null>(null);
  const [isLoaded, setIsLoaded] = useState(false);
  const [status, setStatus] = useState<string>('Idle');

  useEffect(() => {
    return () => {
      ad?.destroy();
    };
  }, [ad]);

  const handleLoad = async () => {
    setStatus('Loading Interstitial ad...');
    const loadedAd = await loadInterstitialAd(INTERSTITIAL_AD_UNIT_ID);
    if (loadedAd) {
      registerAdEvents(loadedAd);
      const onDismiss =
        loadedAd.adEventCallback?.onAdDismissedFullScreenContent;
      loadedAd.adEventCallback = {
        ...loadedAd.adEventCallback,
        onAdDismissedFullScreenContent: () => {
          onDismiss?.();
          setStatus('Ad dismissed.');
        },
      };
      setAd((prevAd) => {
        prevAd?.destroy();
        return loadedAd;
      });
      setIsLoaded(true);
      setStatus('Interstitial ad loaded!');
    } else {
      setStatus('Failed to load Interstitial ad.');
    }
  };

  const handleShow = () => {
    if (ad) {
      showInterstitialAd(ad);
      setIsLoaded(false);
    }
  };

  return (
    <View style={styles.container}>
      <Text style={styles.title}>Interstitial Ad</Text>
      <Text style={styles.status}>Status: {status}</Text>
      <View style={styles.buttonGroup}>
        <Button title="Load Ad" onPress={handleLoad} />
        <View style={styles.spacerSmall} />
        <Button title="Show Ad" onPress={handleShow} disabled={!isLoaded} />
      </View>
    </View>
  );
}
```

## Next steps

After you integrate interstitial ads, explore the following topics:

- [Impression-level ad revenue](https://developers.google.com/admob/react-native/impression-level-ad-revenue.md.txt)
- [User privacy and consent](https://developers.google.com/admob/react-native/privacy.md.txt)