Type Function Return value none Revision 2017.3060 Keywords ads, advertising, Facebook Audience Network, fbAudienceNetwork, show See also fbAudienceNetwork.hide() fbAudienceNetwork.init() fbAudienceNetwork.load() fbAudienceNetwork.isLoaded() fbAudienceNetwork.*
Shows a Facebook ad which was previously loaded via fbAudienceNetwork.load().
fbAudienceNetwork.show( adUnitType, params )
String. The type of ad according to your Facebook placement ID. Supported values are "banner"
or "interstitial"
.
Table. Table containing additional parameters for the specified ad type — see the next section for details.
The params
table includes parameters for the specified ad type.
String. The placement ID for this ad, retrieved from the Facebook Developer Portal.
String or Number. Only applies to banner ads, specifying the banner's y position on the screen. If you supply a string, valid position values are "top"
, "center"
and "bottom"
. Alternatively, you can set a custom y position by specifying a number in content coodinates where 0
indicates the top edge of the screen or where a negative value specifies an offset from the bottom edge of the screen to the bottom edge of the banner. Default is "bottom"
.
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_320_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 ) -- Sometime later, check if the ad is loaded and display it if ( fbAudienceNetwork.isLoaded( myPlacementID ) ) then fbAudienceNetwork.show( "banner", { placementId=myPlacementID, y="center" } ) end