applovin.show()

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

Overview

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

Ad types/preferences are configured per-app within the AppLovin developer portal.

Syntax

applovin.show( [isRewarded] )
isRewarded (optional)

Boolean. Set this to true if you want to show a rewarded video. Default is false. Note that you must enable "Rewarded Video" in the AppLovin developer portal to receive rewarded videos in your app.

Gotchas

Rewarded video offers can be limited to a certain amount in a given day, defined under "frequency capping" in the AppLovin developer portal. If you are using frequency capping, we recommend that you check for an event.phase value of "validationExceededQuota" to determine if the limit has been reached. When this occurs, you may consider loading/showing a static interstitial or video interstitial ad instead.

Example

local applovin = require( "plugin.applovin" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.isError )
        -- Load an AppLovin ad
        applovin.load()

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

    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
applovin.init( adListener, { sdkKey="YOUR_SDK_KEY" } )