Interstitial Ads

This guide explains how to integrate interstitial ads into a ReactNative app.

Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as between screens. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.

Interstitial Ad management in React code is handled through the InterstitialAd class which extends the shared fullscreen ad logic. The interstitial ad is displayed as an overlay on top of all app content and cannot be added to the ReactNative component tree.

import { InterstitialAd } from 'react-native-cas';

Below is a diagram showing the ad lifecycle and how autoload affects it.

Diagram

Load Ad

CAS provides an option to enable autoload to simplify your app logic. Before using the ad, you should decide whether to enable autoload, or manually manage each ad loading cycle in your code.

When autoload is enabled, a new ad will be automatically loaded after each display, and loading failures will trigger automatic retry attempts.

useEffect(() => {
  InterstitialAd.setAutoloadEnabled(true);
}, []);

Manual load mode is useful when you only need to show a single ad per app screen, and the screens change frequently.

When you want to manually control ad loading, use the loadAd() function.

useEffect(() => {
  InterstitialAd.loadAd();
}, []);

Ad content may take some time to load after creating an ad instance. To ensure the ad displays instantly when needed, load the ad instance in advance.

Use the addAdLoadedEventListener event to be notified when the ad is ready for display.

Ad content callbacks

InterstitialAd has several optional callbacks for the ad lifecycle. These callbacks can be registered via event listeners.

useEffect(() => {
  const unsubscribeLoaded = InterstitialAd.addAdLoadedEventListener(() => {
    // Called when an ad is successfully loaded. 
    console.log('Loaded');
  });
  const unsubscribeFailedToLoad = InterstitialAd.addAdFailedToLoadEventListener((error) => {
    // Called when an ad load failed. 
    console.log('Load failed:', error);
  });
  const unsubscribeFailedToShow = InterstitialAd.addAdFailedToShowEventListener((error) => {
    // Called when the ad failed to show full screen content. 
    console.log('Failed to show:', error);
  });
  const unsubscribeShowed = InterstitialAd.addAdShowedEventListener(() => {
    // Called when the ad showed the full screen content.
    console.log('Showed');
  });
  const unsubscribeClicked = InterstitialAd.addAdClickedEventListener(() => {
    // Called when a click is recorded for an ad.
    console.log('Clicked');
  });
  const unsubscribeImpression = InterstitialAd.addAdImpressionEventListener((info: AdContentInfo) => {
    // Called when an impression occurs on the ad. 
    console.log('Impression', info);
  });
  const unsubscribeDismissed = InterstitialAd.addAdDismissedEventListener(() => {
    // Called when the ad dismissed full screen content. 
    console.log('Dismissed');
  });

  return () => {
    unsubscribeLoaded();
    unsubscribeFailedToLoad();
    unsubscribeFailedToShow();
    unsubscribeShowed();
    unsubscribeImpression();
    unsubscribeClicked();
    unsubscribeDismissed();
  };
}, []);
  • Read more about AdContentInfo structure in Impression Level Data.
  • When an error occurs during ad impression, only AdFailedToShowEvent is triggered.
    In this case, AdDismissedEvent will not be executed since the impression is not considered successful.

Show Ad

Interstitial ads should be displayed during natural pauses in the flow of an app. Between app screens is a good example, or after the user completes a task.

You can choose when to show the ad by calling:

InterstitialAd.showAd();

If the ad is not ready at that moment, the AdFailedToShowEvent will be triggered with a reason.

You have the option to check isLoaded() if it's required by your app's logic.

const isAdLoaded = await InterstitialAd.isAdLoaded();

Auto Show Ad mode

CAS provides the option to automatically show a loaded ad when the user returns to the app.

To enable this behavior, set autoshow enabled:

InterstitialAd.setAutoshowEnabled(true);

Minimum interval between impressions

The minimum interval between showing interstitial ads, in seconds.
Attempting to show a new interstitial ad before the interval has passed after the previous one was dismissed will trigger AdFailedToShowEvent with AdErrorCode.NOT_PASSED_INTERVAL.

InterstitialAd.setMinInterval(0); 

Note that the timer for the minimum interval is shared across all interstitial ad instances, but the minimum interval value may differ for each ad instance.

If you need to reset the minimum interval timer after showing a Rewarded Ad or an AppOpen Ad, you can call the InterstitialAd.restartInterval() method in the dismissal flow of those ad formats.

Mute Ad sounds

Indicates if the application’s audio is muted. Affects initial mute state for fullscreen ads. Use this method only if your application has its own volume controls (e.g., custom music or sound effect muting).

CASMobileAds.setAdSoundsMuted(true);

Not muted by default.

Release ad resource

Be sure to release ad resources when no longer needed:

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

Some best practices

Consider whether interstitial ads are the right type of ad for your app.

Interstitial ads work best in apps with natural transition points. The conclusion of a task within an app, like sharing an image or completing a game level, creates such a point. Because the user is expecting a break in the action, it's easy to present an interstitial ad without disrupting their experience. Make sure you consider at which points in your app's workflow you'll display interstitial ads and how the user is likely to respond.

Remember to pause the action when displaying an interstitial ad.

There are a number of different types of interstitial ads: text, image, video, and more. It's important to make sure that when your app displays an interstitial ad, it also suspends its use of some resources to allow the ad to take advantage of them. For example, when you make the call to display an interstitial ad, be sure to pause any audio output being produced by your app.

Allow for adequate loading time.

Just as it's important to make sure you display interstitial ads at an appropriate time, it's also important to make sure the user doesn't have to wait for them to load. Loading the ad in advance by calling loadAd() before you intend to call showAd() can ensure that your app has a fully loaded interstitial ad at the ready when the time comes to display one.

Don't flood the user with ads.

While increasing the frequency of interstitial ads in your app might seem like a great way to increase revenue, it can also degrade the user experience and lower clickthrough rates. Make sure that users aren't so frequently interrupted that they're no longer able to enjoy the use of your app.

Complete example