AppLovinMax_Unity_Banners - imobile/app-mediation GitHub Wiki

Note: Banners from some networks may have heights that exceed 50 points now, as adaptive banners are the default in the latest AppLovin MAX Unity Plugin versions. The height will never be more than 15% of the device’s current orientation height, and never less than 50 points. See Adaptive Banners below for details.

Banners

Related Content: “Why mobile banners ads persist in a video and playable world” from AppLovin’s Blog.

Loading a Banner

To load a banner, call the following using your Ad Unit ID and desired banner position:

string bannerAdUnitId = "YOUR_BANNER_AD_UNIT_ID"; // Retrieve the ID from your account

public void InitializeBannerAds()
{
    // Banners are automatically sized to 320×50 on phones and 728×90 on tablets
    // You may call the utility method MaxSdkUtils.isTablet() to help with view sizing adjustments
    MaxSdk.CreateBanner(bannerAdUnitId, MaxSdkBase.BannerPosition.BottomCenter);

    // Set background or background color for banners to be fully functional
    MaxSdk.SetBannerBackgroundColor(bannerAdUnitId, <YOUR_BANNER_BACKGROUND_COLOR>);
}

The above example creates a banner at the bottom-center of the display ( BottomCenter ). The complete list of position options are TopLeft , TopCenter , TopRight , Centered , CenterLeft , CenterRight , BottomLeft , BottomCenter , and BottomRight .

Set your banner background color to a #-prefixed hexadecimal RGB string, for example '#000000' (black) or '#fff200' (yellow).:

Showing a Banner

To show a banner, call ShowBanner() :

MaxSdk.ShowBanner(bannerAdUnitId);

Hiding a Banner

To hide a banner, call HideBanner() :

MaxSdk.HideBanner(bannerAdUnitId);

Adaptive Banners

Note: The latest MAX Unity plugin (versions 4.3.1 and above) enables adaptive banners automatically on AdMob and Google Ad Manager. This helps you to increase revenue. AppLovin recommends that you run tests to ensure that adaptive banners create the best experience for your users. Follow the instructions below if you want to disable adaptive banners.

Adaptive banners are responsive banners with heights that derive from the device type and width of the banner. To create an adaptive banner, refer to the following instructions based on your AppLovin MAX Unity Plugin version:

AppLovin MAX Unity Plugin < 3.2.2

Adaptive banners are not available for versions of the MAX Unity Plugin before 3.2.2.

AppLovin MAX Unity Plugin 3.2.2–4.3.0

To create an adaptive banner, set the banner extra parameter adaptive_banner to true when you create the banner, as in the following example:

string bannerAdUnitId = "YOUR_BANNER_AD_UNIT_ID"; // Retrieve the ID from your account

public void InitializeBannerAds()
{
    // Adaptive banners are sized based on device width for positions that stretch full width (TopCenter and BottomCenter).
    // You may use the utility method `MaxSdkUtils.GetAdaptiveBannerHeight()` to help with view sizing adjustments
    MaxSdk.CreateBanner(bannerAdUnitId, MaxSdkBase.BannerPosition.BottomCenter);
    MaxSdk.SetBannerExtraParameter(bannerAdUnitId, "adaptive_banner", "true");

    // Set background or background color for banners to be fully functional
    MaxSdk.SetBannerBackgroundColor(bannerAdUnitId, <YOUR_BANNER_BACKGROUND_COLOR>);
}

Call MaxSdkUtils.GetAdaptiveBannerHeight() to get the banner height, and then adjust your content accordingly.

AppLovin MAX Unity Plugin 4.3.1+

Banners from ad networks that support adaptive banners are adaptive by default. If you want to disable adaptive banners, set the banner extra parameter adaptive_banner to false when you create the banner, as in the following example:

string bannerAdUnitId = "YOUR_BANNER_AD_UNIT_ID"; // Retrieve the Id from your account

public void InitializeBannerAds()
{
    MaxSdk.CreateBanner(bannerAdUnitId, MaxSdkBase.BannerPosition.BottomCenter);
    MaxSdk.SetBannerExtraParameter(bannerAdUnitId, "adaptive_banner", "false");

    // Set background or background color for banners to be fully functional
    MaxSdk.SetBannerBackgroundColor(bannerAdUnitId, <YOUR_BANNER_BACKGROUND_COLOR>);
}

Call MaxSdkUtils.GetAdaptiveBannerHeight() to get the banner height, and then adjust your content accordingly.

Note: TopCenter and BottomCenter banner positions span the full width of the screen. For other positions, the width is 320 (on phones) or 728 (on tablets). So, the MaxSdkUtils.GetAdaptiveBannerHeight(width) function also takes a width parameter and returns the appropriate adaptive height for the given banner width.