Banner Ads

Creating a Banner

The following code shows you how to load a banner by using your Ad Unit ID, desired banner position, and desired background color (MAX will size the ad for you automatically):

var BANNER_AD_UNIT_ID;
if ('IOS' === window.cordova.platformId.toUpperCase()) {
  BANNER_AD_UNIT_ID = 'ios_banner_ad_unit_ID';
} else {
  // Assume Android
  BANNER_AD_UNIT_ID = 'android_banner_ad_unit_ID';
}

function initializeBannerAds()
{
  // MAX automatically sizes banners to 320×50 on phones and 728×90 on tablets
  // Use the utility method AppLovinMAX.isTablet() to help with view-sizing adjustments
  AppLovinMAX.createBanner(BANNER_AD_UNIT_ID, AppLovinMAX.AdViewPosition.BOTTOM_CENTER);

  // Set background or background color for banners to be fully functional
  // The following call sets it to black - USE HEX STRINGS ONLY
  AppLovinMAX.setBannerBackgroundColor(BANNER_AD_UNIT_ID, '#000000');
}

Displaying a Banner

To show a banner, call showBanner():

AppLovinMAX.showBanner(bannerAdUnitId);

Hiding a Banner

To hide a banner, call hideBanner():

AppLovinMAX.hideBanner(bannerAdUnitId);