superawesome.load()

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

Overview

Preloads a SuperAwesome ad. You can also call superawesome.isLoaded() to verify that the ad has been loaded and superawesome.show() to show it.

Syntax

superawesome.load( adUnitType, params )
adUnitType (required)

String. The type of ad according to the SuperAwesome placement ID. Supported values are "banner", "interstitial", or "video".

params (required)

Table. Table containing customization parameters for the specified ad type — see the next section for details.

Parameter Reference

The params table containing customization parameters for the specified ad type.

placementId (required)

String. The placement ID for the ad to be loaded, retrieved from the SuperAwesome dashboard.

bannerSize (optional)

String. The size of the banner ad. Valid options include "BANNER_50", "BANNER_90", and "BANNER_250". Default is "BANNER_50".

bannerTransparency (optional)

Boolean. Specifies if the banner background should be transparent. Default is false.

Example

local superawesome = require( "plugin.superawesome" )

-- Pre-declare a placement ID
local myPlacementID = "YOUR_PLACEMENT_ID"

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- Load a banner ad
        superawesome.load( "banner", { placementId=myPlacementID } )

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

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

-- Initialize the SuperAwesome plugin
superawesome.init( adListener, { testMode=true } )