Skip to content

Banner & MREC Ads

The following sections show you how to load and then show and hide a banner or MREC ad.

Loading a Banner or MREC

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

"android" : "«Android-banner-ad-unit-ID»",
"ios" : "«iOS-banner-ad-unit-ID»"
func initializeBannerAds:
var platform = OS.get_name().to_lower() # "android", "ios", etc.
var ad_unit_id = adUnitsDict.get(platform)
# MAX automatically sizes banners to 320×50 on phones and 728×90 on tablets
AppLovinMAX.create_banner(ad_unit_id, AppLovinMAX.BannerPosition.BOTTOM_CENTER)

Displaying a Banner or MREC

To show a banner or MREC, make the following call:


To hide a banner or MREC, make the following call:


Adaptive Banners

Adaptive banners are responsive banners with heights that derive from the device type and the width of the banner. To disable adaptive banners, set the adaptive_banner flag, as in this example:

AppLovinMAX.set_banner_extra_parameter(«ad-unit-ID», "adaptive_banner", "false")

Call AppLovinMAX.get_adaptive_banner_height_for_width(«width») to get the banner height, and then adjust your content accordingly.

Stopping and Starting Auto-Refresh

You may want to stop auto-refresh for an ad. This may be the case when you hide an ad or you want to manually refresh. Stop auto-refresh with the following call:


Start auto-refresh for an ad with the following call: