fbAudienceNetwork.getSize()

Type Function
Return value Numbers
Revision 2017.3060
Keywords ads, advertising, Facebook Audience Network, fbAudienceNetwork, getSize
See also fbAudienceNetwork.show()
fbAudienceNetwork.*

Overview

Returns the width and height of a banner ad loaded via fbAudienceNetwork.load(). Does not apply to interstitial ads.

Syntax

fbAudienceNetwork.getSize( placementID )
placementID (required)

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

Example

local fbAudienceNetwork = require( "plugin.fbAudienceNetwork" )

-- Pre-declare a placement ID
local myPlacementID = "YOUR_BANNER_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 )

-- Sometime later, get the banner ad width and height
local bWidth, bHeight = fbAudienceNetwork.getSize( myPlacementID )
print( bWidth, bHeight )