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.
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:
- 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) { } }
- 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
To request an interstitial ad, call the following method:
IronSource.LoadInterstitial();
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) { }
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);