Skip to content

Interstitial ads

Marius Bughiu edited this page Jan 25, 2025 · 1 revision

Interstitial ads are displayed using the IInterstitialAdService service. The service is registered by the plugin and can be either injected or retrieved from the service provider as follows:

var interstitialAdService = IPlatformApplication.Current.Services.GetService<IInterstitialAdService>();

Once you grab hold of the service instance, the next step is to preload the interstitial ad. You can do so by calling the PrepareAd method. You can pass your adUnitId as a parameter, or call it without any parameters to use the configured AdConfig.DefaultInterstitialAdUnitId. After the ad is prepared, simply call ShowAd() to display the interstitial ad.

Interface

public interface IInterstitialAdService
{
    IInterstitialAd CreateAd(string adUnitId = null);

    void PrepareAd(string adUnitId = null);

    void ShowAd();
}

Methods

PrepareAd

void PrepareAd(string adUnitId = null)

Preloads an intersitial ad using the provided adUnitId. If no adUnitId is provided, it will use configured default - AdConfig.DefaultInterstitialAdUnitId.

ShowAd

void ShowAd()

Displays the interstitial ad which was prepared when PrepareAd was called. If no ad was prepared, nothing will be shown.

CreateAd

IInterstitialAd CreateAd(string adUnitId = null)

Creates an interstitial ad instance which you can use to preload and show later on. This enables you to preload multiple interstitial ads at the same time, using different ad unit IDs. If no adUnitId is provided, it will use configured default - AdConfig.DefaultInterstitialAdUnitId.

Clone this wiki locally