supersonic.load()

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

Overview

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

Syntax

supersonic.load( adUnitType, userId )
adUnitType (required)

String. The type of ad you wish to load. Supported values are "offerWall", "interstitial", or "rewardedVideo".

userId (optional)

String. The user id for the current user of your app. This can be any string value, for instance "user123".

Example

local supersonic = require( "plugin.supersonic" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- Load an offer wall ad
        supersonic.load( "offerWall", "user2546" )

    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 )
    end
end

-- Initialize the Supersonic plugin
supersonic.init( adListener, { appKey="YOUR_APP_KEY" } )