fuse.show()

Type Function
Return value none
Revision Release 2024.3703
Keywords ads, advertising, monetization, fuse, show
See also fuse.load()
fuse.checkLoaded()
fuse.*

Overview

Shows a Fuse ad of the specified zone, assuming one has been loaded/cached. If no zone is specified, the default zone will be used. To check whether an ad of the specific zone exists in the cache, call fuse.checkLoaded().

For rewarded videos, you may specify additional parameters pertaining to user interaction.

This function will call the listener function specified by fuse.init() with an event.phase value of "shown" if the ad has been successfully shown.

Syntax

fuse.show( [params] )
params (optional)

Table. A table of key-value pairs which specifies properties for the ad — see the next section for details.

Parameter Reference

Valid keys for the params table include:

Examples

Simple
local fuse = require( "plugin.fuse" )

-- Event listener function
local function adListener( event )

    if ( event.isError ) then
        print( "Fuse error: " .. event.response )
    else
        if ( event.phase == "init" ) then
            -- Fuse system initialized

        elseif ( event.phase == "shown" ) then
            -- An ad finished showing

        elseif ( event.phase == "completed" ) then
            -- User accepted an offer or completed a task for a reward
            -- The event.payload table contains details about the reward
        end
    end
end

-- Initialize the Fuse service
fuse.init( adListener )

-- Sometime later, show an ad from the default zone
fuse.show()
Specific Zone
local fuse = require( "plugin.fuse" )

-- Preset a zone
local zone = "1a2b3c4d"

-- Event listener function
local function adListener( event )

    if ( event.isError ) then
        print( "Fuse error: " .. event.response )
    else
        if ( event.phase == "init" ) then
            -- Fuse system initialized; load/cache a zone-specific ad
            fuse.load( { zone=zone } )

        elseif ( event.phase == "shown" ) then
            -- An ad finished showing

        elseif ( event.phase == "completed" ) then
            -- User accepted an offer or completed a task for a reward
            -- The event.payload table contains details about the reward
        end
    end
end

-- Initialize the Fuse service
fuse.init( adListener )

-- Sometime later, show the ad
local isLoaded = fuse.checkLoaded( { zone=zone } )
if ( isLoaded == true ) then
    fuse.show( { zone=zone } )
end