Interstitial Integration for Xamarin iOS

The ironSource Interstitial is a full-screen ad unit, usually served at natural transition points during the app lifecycle. We support both static and video interstitials. You can also serve interstitials through the ironSource Mediation platform.

Before you start Make sure you have correctly integrated the ironSource Plugin into your application. Integration is outlined here.

Step 1. Implement the Delegate

The ironSource SDK fires several events to inform you of Interstitial Activity.  To receive these events, we suggest the following:

  1. Create a class which inherits from LevelPlayInterstitialDelegate. It is recommend to create a separate class for each delegate
    public class InterstitiaLevelPlayDelegate : LevelPlayInterstitialDelegate
        {
            readonly ViewController viewController;
            public InterstitiaLevelPlayDelegate(ViewController viewController)
            {
                this.viewController = viewController;
            }
            //Invoked when the end user clicked on the interstitial ad.
            public override void didClickWithAdInfo(ISAdInfo adInfo)
            {
            }
            //Invoked when the ad is closed and the user is about to return to the application.
            public override void didCloseWithAdInfo(ISAdInfo adInfo)
            {
            }
            ///Indicates that the ad failed to load
            public override void didFailToLoadWithError(NSError error)
            {
            }
            //Invoked when Interstitial ad failed to show.
            public override void didFailToShowWithError(NSError error, ISAdInfo adInfo)
            {
            }
            //Indicates that the ad was loaded
            public override void didLoadWithAdInfo(ISAdInfo adInfo)
            {
            }
            //Invoked when the Interstitial Ad Unit is opened
            public override void didOpenWithAdInfo(ISAdInfo adInfo)
            {
            }
            //Invoked when Interstitial ad was shown
            public override void didShowWithAdInfo(ISAdInfo adInfo)
            {
            }
        }

  2. Create and instantiate an InterstitiaLevelPlayDelegate object. Set the delegate using the new object.
    Make sure to call the setLevelPlayInterstitialDelegate before the SDK initialisation.

    InterstitiaLevelPlayDelegate mInterstitiaLevelPlayDelegate;
    // Define the listener 
     mInterstitiaLevelPlayDelegate = new InterstitiaLevelPlayDelegate(this);  
    // Set the delegate       
    IronSource.setLevelPlayInterstitialDelegate(mInterstitiaLevelPlayDelegate);
    

  • Do not assume the delegate methods will always invoke on the main thread. 

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 some time. 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 within this time is unlikely.

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 InterstitialDidClose 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 didLoadWithAdInfo which will inform you about ad availability.

 public override void didLoadWithAdInfo(ISAdInfo adInfo) { }

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 didLoadWithAdInfo delegate, you are ready to show an Interstitial Ad to your users. Invoke the following method to serve an Interstitial ad to your users:

IronSource.ShowInterstitialWithViewController(this);

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.