applovinMax.show()

Type Function
Return value none
Revision Release 2024.3703
Keywords ads, advertising, AppLovin, show
See also applovinMax.init()
applovinMax.load()
applovinMax.isLoaded()
applovinMax.*

Overview

Shows a AppLovin ad which was previously loaded via applovinMax.load().

Syntax

applovinMax.show( adType [, placement] )
adType (required)

String. One of the following values:

  • "banner"
  • "interstitial"
  • "rewardedVideo"
params (optiional)

Table. Table containing AppLovin ad loading options.

Parameter Reference

The params table includes parameters for the AppLovin ad loading.

placement (optional)

String. The placement to be used. This must be identical to one of the placements defined for the app in the AppLovin developer portal.

y (optional)

String. Only applicable for banner ads. Valid values: "top", "center" and "bottom". Default is "top".

Notes
  • When you use "interstitial", both static interstitial ads and video interstitial ads may be shown. You configure the type of ads to be used in the AppLovin developer portal.

  • You must enable "Rewarded Video" in the AppLovin developer portal to receive rewarded videos in your app.

  • Rewarded video offers can be limited to a certain amount in a given day, defined under "frequency capping" in the AppLovin developer portal.

Example

local applovinMax = require( "plugin.applovinMax" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.isError )
        -- Load an AppLovin ad
        applovinMax.load( "interstitial", {iOSUnitId ="replace with your own", androidUnitId="replace with your own"} )

    elseif ( event.phase == "loaded" ) then  -- The ad was successfully loaded
        print( event.type )

    elseif ( event.phase == "failed" ) then  -- The ad failed to load
        print( event.type )
        print( event.isError )
        print( event.response )

    elseif ( event.phase == "displayed" or event.phase == "playbackBegan" ) then  -- The ad was displayed/played
        print( event.type )

    elseif ( event.phase == "hidden" or event.phase == "playbackEnded" ) then  -- The ad was closed/hidden
        print( event.type )

    elseif ( event.phase == "clicked" ) then  -- The ad was clicked/tapped
        print( event.type )
    end
end

-- Initialize the AppLovin plugin
applovinMax.init( adListener)

-- Sometime later, show the ad
local isAdLoaded = applovinMax.isLoaded( "interstitial" )
if ( isAdLoaded == true ) then
    applovinMax.show( "interstitial" )
end