fbAudienceNetwork.load()

Type Function
Return value none
Revision 2018.3321
Keywords ads, advertising, Facebook Audience Network, fbAudienceNetwork, load
See also fbAudienceNetwork.show()
fbAudienceNetwork.isLoaded()
fbAudienceNetwork.*

Overview

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

Syntax

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

String. The type of ad according to your Facebook placement ID. Supported values are "banner" or "interstitial".

params (required)

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

Parameter Reference

The params table includes parameters for the specified ad type.

placementId (required)

String. The placement ID for this ad, retrieved from the Facebook Developer Portal.

bannerSize (optional)

String. The banner ad size to load (does not apply to interstitial ads). Supported values include:

  • "BANNER_HEIGHT_50"
  • "BANNER_HEIGHT_90"
  • "BANNER_320_50"
  • "RECTANGLE_HEIGHT_250"

Example

local fbAudienceNetwork = require( "plugin.fbAudienceNetwork" )

-- 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
        fbAudienceNetwork.load( "banner", { placementId=myPlacementID, bannerSize="BANNER_HEIGHT_50" } )

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

-- Initialize the Facebook Audience Network
fbAudienceNetwork.init( adListener )