Interstitial Integration for Xamarin Android

Before You Start

Make sure you have correctly integrated the ironSource Xamarin Plugin in your application. Integration is outlined here.

Step 1. Implement the Interstitial Video Listener

The ironSource SDK fires several events to inform you of your Interstitial activity. To receive these events, register to the interface of the ad unit:

IInterstitialListener

The Plugin will notify your listener of all possible events listed below:

IronSource.SetInterstitialListener(this);
 /*
  * Invoked when the ad is closed and the user is about to return to the 
  * application.
  */
public void OnInterstitialAdClosed()
{
}
 /*
  * Invoked when the Interstitial Ad Unit is opened
  */
public void OnInterstitialAdOpened()
{
}
 /*
  * invoked when there is no Interstitial Ad available after calling load function.
  */
public void OnInterstitialAdLoadFailed(IronSourceError error)
{
}
 /*
  * Invoked when the ad was opened and shown successfully.
  */
public void OnInterstitialAdShowSucceeded()
{
}
 /*
  * Invoked when Interstitial ad failed to show.
  * @param error - An object which represents the reason of showInterstitial failure.
  */
public void OnInterstitialAdShowFailed(IronSourceError error)
{
}
 /*
  * Invoked when Interstitial Ad is ready to be shown after load function was called.
  */
public void OnInterstitialAdReady()
{
}
 /*
  * Invoked when the end user clicked on the interstitial ad.
  */
public void OnInterstitialAdClicked()
{
}
Note:

  • The onInterstitialAdOpened() and onInterstitialAdShowSucceeded() events convey that the ad format has taken over the app screen and been displayed but does not indicate that an ad has been successfully served to your end-user.
  • Do not assume the callbacks are always running on the main thread. Any UI interaction or updates resulting from ironSource’s callbacks need to be passed to the main thread before executing.

Step 2. Load Interstitial Ad

We recommend requesting an Interstitial Ad a short while before you plan on showing it to your users as the loading process can take time.
To request an interstitial ad, call the following method:

IronSource.LoadInterstitial();

 Note: If you’d like to serve several Interstitial Ads in your application, you must repeat this step after you’ve shown and closed the previous Interstitial Ad. Once the onInterstitialAdClosed function is fired, you will be able to load a new Interstitial ad.

Step 3. Check Ad Availability

After you call the LoadInterstitial in Step 2, you will be notified when the ad is loaded and ready to be shown to your user through the delegate with the method OnInterstitialAdReady which will inform you about ad availability.

public void OnInterstitialAdReady(){}

In addition, you can also ask for the ad availability directly by calling the following function:

IronSource.IsInterstitialReady();

We don’t recommend making consecutive requests for an interstitial ad in a short timespan. Numerous requests in a short period of time have no added value as the chance of available inventory at this time is unlikely.

Step 4. Show Interstitial Ad

Once you receive the onInterstitialAdReady callback, you are ready to show an Interstitial Ad to your users. Invoke the following method to serve an Interstitial ad to your users:

IronSource.ShowInterstitial();

You can also show Interstitial and specify the placement you would like to watch:

IronSource.ShowInterstitial(placementName);

Important! Once you’ve successfully completed step 4, you will have shown your user an Interstitial Ad. In the case you want to serve another Interstitial ad, you must repeat Step 3 to request an additional Interstitial.
 

Done!
You can now deliver ironSource Interstitial Ads on your app!