Banner Integration for Unity

Banners are a rectangular, system-initiated ads that can be either static or animated, and are served in a designated area around your live app content. 

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

Starting from ironSource SDK 7.8.0, you can use a container as part of your banner integration. Learn more.

Step 1. Load Banner Ad

To load a Banner ad, call the following method:

  • Load the Banner view by calling this method (in this example it’s the BANNER banner size):
    IronSource.Agent.loadBanner(IronSourceBannerSize.BANNER, IronSourceBannerPosition.BOTTOM);
    
    See table below for details about our supported standard banner sizes:
    IronSourceBannerSize Description Dimensions (WxH) (points in iOS, dp in Android)
    BANNER Standard Banner 320 x 50
    LARGE Large Banner 320 x 90
    RECTANGLE Medium Rectangular (MREC) 300 x 250
    SMART
    Smart Banner
    (Automatically renders ads to adjust size and orientation for mobile & tablets)
    iOS:
    If (iPhone) 320 x 50
    If (iPad) 728 x 90
    Android:
    If (screen width ≤ 720) 320 x 50
    If (screen width > 720) 728 x 90

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

    IronSourceBannerPosition Description
    TOP Banner will be positioned at the top center of the screen
    BOTTOM Banner will be positioned at the bottom center of the screen
  • Another option is initiating the banner with Custom size, using this signature (WxH) (points in iOS, dp in Android):
    IronSource.Agent.loadBanner(new IronSourceBannerSize(320, 50), IronSourceBannerPosition.BOTTOM);

You will receive the onBannerAdLoadedEvent and the banner will show on your app.

Hide & Display Banner – Optional

In order to provide maximum flexibility in the ad experience, you now have the ability to hide and present banners on your app.

Using hideBanner and displayBanner APIs, you can control whether banners can be loaded and destroyed while in the background.

Once you’ve loaded and served a banner, you can choose to hide this banner and re-show it at a later point in your app.

To hide the banner, call this function:

IronSource.Agent.hideBanner();

To then show this same banner again, call this function:

IronSource.Agent.displayBanner();

    Step 2. Implement the Banner Events

    The ironSource Unity Plugin fires several events to inform you of ad availability and activity. Under IronSource/Assets/Prefabs, you’ll find the IronSourceEventsPrefab. Add it to your project to receive these events.

    //Add AdInfo Banner Events
    IronSourceBannerEvents.onAdLoadedEvent += BannerOnAdLoadedEvent;
    IronSourceBannerEvents.onAdLoadFailedEvent += BannerOnAdLoadFailedEvent;
    IronSourceBannerEvents.onAdClickedEvent += BannerOnAdClickedEvent;
    IronSourceBannerEvents.onAdScreenPresentedEvent += BannerOnAdScreenPresentedEvent;
    IronSourceBannerEvents.onAdScreenDismissedEvent += BannerOnAdScreenDismissedEvent;
    IronSourceBannerEvents.onAdLeftApplicationEvent += BannerOnAdLeftApplicationEvent;

    The Plugin will notify the Listener of all possible events listed below:

    /************* Banner AdInfo Delegates *************/
    //Invoked once the banner has loaded
    void BannerOnAdLoadedEvent(IronSourceAdInfo adInfo) 
    {
    }
    //Invoked when the banner loading process has failed.
    void BannerOnAdLoadFailedEvent(IronSourceError ironSourceError) 
    {
    }
    // Invoked when end user clicks on the banner ad
    void BannerOnAdClickedEvent(IronSourceAdInfo adInfo) 
    {
    }
    //Notifies the presentation of a full screen content following user click
    void BannerOnAdScreenPresentedEvent(IronSourceAdInfo adInfo) 
    {
    }
    //Notifies the presented screen has been dismissed
    void BannerOnAdScreenDismissedEvent(IronSourceAdInfo adInfo) 
    {
    }
    //Invoked when the user leaves the app
    void BannerOnAdLeftApplicationEvent(IronSourceAdInfo adInfo) 
    {
    }

    Step 3. Additional Load Settings

    We support placements, as well as capping and pacing for Banners on the LevelPlay dashboard. Learn how to set up placements, capping and pacing for Banners to optimize your app’s user experience here.

    If you’ve set up placements for your Banner, call the following method to serve a Banner ad in a specific location:

    IronSource.Agent.loadBanner(IronSourceBannerSize.BANNER, IronSourceBannerPosition.BOTTOM, (string) "YOUR_PLACEMENT_NAME");

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

    Step 4. Destroy the Banner Ad

    To destroy a banner, call the following method:

    IronSource.Agent.destroyBanner();

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

    Step 5.  Integrate a Banner Provider

    Next, integrate the ad network adapters to serve Banners through LevelPlay Mediation.

    You can find the supported networks below, and bannerSize behaviour for each network, as defined for relevant platform: 

    iOS Banner Support 

    Android Banner Support 

    Step 6.  Adaptive banners

    The adaptive banner feature will allow you to receive the optimal banner height , based on a predefined ad-width. 

    While using this feature, networks that support adaptive banners (Currently AdMob and Ad Manager only) will return ads with best-fit-height based on the container width you defined. All other networks will continue to deliver banners according to the specified default ad size.  

    In this implementation (Supported from ironSource SDK 7.8.0+) the container defines the boundaries of the banner for all networks, whether they support adaptive banners or not. This ensures a consistent experience across each refresh during the same load session.

    1. Set the banner default size. 
    2. Define adaptive banner parameters – 
      • Width: the banner width you would like to display. Use either fix size, or getDeviceScreenWidth API
      • Height: use getMaximalAdaptiveHeight API to get the recommended banner height for the width you defined in the previous step. 
    3. Create a container, using the parameter sizes defined in step #1 
    4. Set the adaptive flag to true. 
    5. Load the banner

    Define a container

    You can either create a manual container with specific sizes or implement an automatic fetch of the screen size. 

    Manual Container

    This example defines a manual container with a width of 360.

    IronSourceBannerSize ironSourceBannerSize = IronSourceBannerSize.BANNER;
    float Width = 360;
    float Height = IronSource.Agent.getMaximalAdaptiveHeight(Width);
    ISContainerParams isContainerParams = new ISContainerParams{ Width = Width, Height = Height };
    ironSourceBannerSize.setBannerContainerParams(isContainerParams);
    ironSourceBannerSize.SetAdaptive(true);
    IronSource.Agent.loadBanner(ironSourceBannerSize, IronSourceBannerPosition.BOTTOM);

    Fetch automatic screen size

    IronSourceBannerSize ironSourceBannerSize = IronSourceBannerSize.BANNER;
    float Width = IronSource.Agent.getDeviceScreenWidth();
    float Height = IronSource.Agent.getMaximalAdaptiveHeight(Width);
    ISContainerParams isContainerParams = new ISContainerParams{ Width = Width, Height = Height };
    ironSourceBannerSize.setBannerContainerParams(isContainerParams);
    ironSourceBannerSize.SetAdaptive(true);
    IronSource.Agent.loadBanner(ironSourceBannerSize, IronSourceBannerPosition.BOTTOM);
    • The getDeviceScreenWidth method provides the full screen size while considering the safe area in iOS, and returns the width based on the device orientation.
    • The getMaximalAdaptiveHeight method provides the maximum height for a given width in adaptive banner supported networks. If there are no networks that support adaptive banners, the returned value will be -1.

    Done!

    You are now all set up to serve Banners in your application. Verify your integration with our Integration Helper.


    What’s Next? 

    Follow our integration guides to integrate additional ad units:

    Interested in integrating more mediation adapters? Check out our supported Mediation Networks.