Banner Integration for Xamarin iOS

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

Step 1. Create Layout and load banner

First, you’ll need to create a Banner view to configure the Banner.

  • To load the banner ad, initiate the Banner view by calling this method (in this example it’s the BANNER banner size):
    var bannerSize = new ISBannerSize("BANNER", 320, 50);
    IronSource.LoadBannerWithViewController(this, bannerSize);

    Note: Supported Banner syntaxt: (“BANNER”, 320, 50), (“LARGE”, 320, 90), (“RECTANGLE”, 300, 250), (“SMART”, 0, 0)

    See table below for details about our supported standard banner sizes:

    ISBannerSize Description Dimensions in points (WxH)
    BANNER Standard Banner 320 x 50
    LARGE Large Banner 320 x 90
    RECTANGLE Medium Rectangular Banner 300 x 250
    SMART
    Smart Banner If (iPhone ≤ 720) 320 x 50
    If (iPad > 720) 728 x 90

Note:  SDK will not show more than one banner at a time.

Step 2. Implement the Delegate

Next, the ironSource SDK fires several delegate methods to inform you of Banner activity. To receive these events, we suggest the following:

  1. Create a class which inherits from LevelPlayBannerDelegate. We recommend to create a separate class for each delegate
    public class BannerLevelPlayDelegate : LevelPlayBannerDelegate
        {
            private ViewController viewController;
            public BannerLevelPlayDelegate(ViewController viewController)
            {
                this.viewController = viewController;
            }
           //Called after a banner has been clicked.
            public override void didClickWithAdInfo(ISAdInfo adInfo)
            {
            }
           //Called after a full screen content has been dismissed.
            public override void didDismissScreenWithAdInfo(ISAdInfo adInfo)
            {
            }
           //Called after a banner has attempted to load an ad but failed.
            public override void didFailToLoadWithError(NSError error)
            {
            }
           //Called when a user would be taken out of the application context.
            public override void didLeaveApplicationWithAdInfo(ISAdInfo adInfo)
            {
            }
           //Called after a banner ad has been successfully loaded
            public override void didLoad(ISBannerView bannerView, ISAdInfo adInfo)
            {
            }
           //Called when a banner is about to present a full screen content.
            public override void didPresentScreenWithAdInfo(ISAdInfo adInfo)
            {
            }
        }

  2. Create and instantiate a BannerLevelPlayDelegate object. Set the delegate using the new object.
    BannerLevelPlayDelegate mBannerLevelPlayDelegate;
    // Define the listener 
    mBannerLevelPlayDelegate = new BannerLevelPlayDelegate(this);
    // Set the delegate
    IronSource.setLevelPlayBannerDelegate(mBannerLevelPlayDelegate);
    

Note:  
  • Do not assume the delegate methods are invoked on the main thread.

Step 4. Safe Area Layout Implementation

Safe area refers to the layout guides introduced as part of iOS11, defining the allowed position views in iOS applications. It makes sure that your application will not cover any ancestor views, including navigation and tab bars.

Implement Safe Area:

Here’s an example that initiates and loads a banner in the didLoad method:

        public override void didLoad(ISBannerView bannerView, ISAdInfo adInfo)
        {
            this.bannerView = bannerView;
            nfloat y = this.viewController.View.Frame.Size.Height - (bannerView.Frame.Size.Height / 2);
// Takes care safe area in iOS 10 and above      
      if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                y -= this.viewController.View.SafeAreaInsets.Bottom;
            }
            bannerView.Center = new CGPoint(this.viewController.View.Frame.Size.Width / 2, y);
            this.viewController.View.AddSubview(bannerView);
            bannerView.AccessibilityLabel = "bannerContainer";
        }

Step 5. Destroy the Banner Ad

To destroy a banner, call the following method:

InvokeOnMainThread(() =>
            {
                if (this.bnDelegate.DestroyBanner())
                {
                    bannerViewController = null;
                }
            });

A destroyed banner can no longer be loaded. If you want to serve it again, you must initiate it again.

Step 6.  Integrate a Banner Provider

Next, integrate the ad network adapters to serve Banners through Unity LevelPlayMediation. We currently support ironSource, Admob, AppLovin and Meta Audience Network Banners.

For better understanding of bannerSize’s behaviour per network, please follow table:

BANNER LARGE RECTANGLE SMART
ironSource Banner Large Banner / Leaderboard
AdMob Banner Large Banner IAM Medium Rectangle Banner / Leaderboard
AppLovin Banner Banner Medium Rectangle Banner / Leader
Meta Audience
Network
Standard Banner Large Banner Medium Rectangle Banner / Leader
UnityAds Banner Banner Leaderboard
Vungle Banner Banner Medium Rectangle Banner / Leaderboard

Done!
You are now all set up to serve Banners in your application.