Interstitial ads

This section provides details and examples of how to configure, load, and display an interstitial ad. You can display the ad when it loads, or on some other specific event; for example, when the user clicks a button.

Set up and load an interstitial ad

Before you can display an ad in your app, you first need to configure the ad, and then pass the ad placement ID to the load method.

For example:

public class MainScript : MonoBehaviour {

    void Start () {

        // Initialise the SDK (Skip this if you already initialised it elsewhere...)
        AwesomeAds.init(true); // In production usages set logging parameter to false

        // Set configuration to production
        SAInterstitialAd.setConfigurationProduction();

        // Enables test ads
        SAInterstitialAd.enableTestMode();

        // Locks orientation to portrait
        SAInterstitialAd.setOrientationPortrait();

        // Enables the back button (Android only)
        SAInterstitialAd.enableBackButton();

        // Start loading ad
        SAInterstitialAd.load(30473);
    }
}

Configuration Methods

Interstitial ads have some default settings which can be configured using the methods detailed in the following table:

Parameter Default value Configure using
Configuration Production setConfigurationProduction()
Test mode Disabled enableTestMode(), disableTestMode()
Orientation Any setOrientationPortrait(), setOrientationLandscape(), setOrientationAny()
Back button Enabled enableBackButton(), disableBackButton()
Close button Enabled enableCloseButton(), enableCloseButtonNoDelay(), enableCloseButtonWithDelay(5.0)

Aditional load parameters

You can also send additional options during the load() call as well as an optional OpenRTB partner ID. Both parameters are optional.

var options = new Dictionary<string, string>
  {
    ["key"] = "value"
  };

string openRTBPartnerId = "1234";
SAInterstitialAd.load(30471, openRTBPartnerId, options);

Display the interstitial ad

To display the ad, call play (passing the placement ID), using either the adLoaded callback or the hasAdAvailable method.

  • Use the adLoaded callback to display the ad as soon as it is loaded. Add the callback before you call the load method:
      public class MainScript : MonoBehaviour {
    
          void Start () {
    
              // Initialise the SDK (Skip this if you already initialised it elsewhere...)
              AwesomeAds.init(true); // In production usages set logging parameter to false
    
              // Configuration
              SAInterstitialAd.setConfigurationProduction();
              SAInterstitialAd.enableTestMode();
    
              // Use the adLoaded callback to trigger playing the ad
              SAInterstitialAd.setCallback((placementId, evt) => {
    
                  // When the ad is loaded, play it
                  if (evt == SAEvent.adLoaded) {
                      SAInterstitialAd.play(placementId);
                  }
              });
    
              // Start loading ad
              SAInterstitialAd.load(30473);
          }
      }
    
  • Use the hasAdAvailable method to play the ad after another event, such as when the user clicks a button in the app.

      public class MainScript : MonoBehaviour {
    
          void Start () {
    
              // Initialise the SDK (Skip this if you already initialised it elsewhere...)
              AwesomeAds.init(true); // In production usages set logging parameter to false
    
              // Configuration
              SAInterstitialAd.setConfigurationProduction();
              SAInterstitialAd.enableTestMode();
    
              // Start loading ad
              SAInterstitialAd.load(30473);
          }
    
          public void onClick() {
              // Checks if ad is loaded
              if (SAInterstitialAd.hasAdAvailable(30473)) {
    
                  // Display the ad
                  SAInterstitialAd.play(30473);
              }
          }
      }