admob.load()

Type Function
Return value none
Revision Current Public Release (2018.3326)
Keywords ads, advertising, AdMob, load
See also admob.show()
admob.isLoaded()
admob.*

Overview

Pre-loads an AdMob interstitial, banner, or rewarded video ad for instant display upon a future call to admob.show().

Important

Before calling this function, you must call admob.init() and wait for the "init" event phase.

Rewarded video ads will not load when test mode is enabled. In this case, you will get a "failed" phase when trying to load a rewarded video. Please see admob.init() for instructions on how to enable/disable test mode.

Syntax

admob.load( adType, params )
adType (required)

String. One of the following ad type values:

  • "interstitial"  (includes both static interstitials and video interstitials)
  • "banner"
  • "rewardedVideo"
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.

adUnitId (required)

String. The ad unit ID for the specified ad type, gathered from the AdMob dashboard.

childSafe (optional)

Boolean. Set this to true to ensure that only COPPA-compliant ads will be loaded. Default is false.

designedForFamilies (optional)

Boolean. Only available on Android (ignored on iOS). When used together with the childSafe option, you can request ads that comply with Google's Designed for Families program. Essentially, upon seeing both designedForFamilies and childSafe set to true, AdMob will return program-compliant ads for the ad request. Note, however, that using these options together may restrict the fill rate of ads being served, especially in non-U.S. territories.

keywords (optional)

Array. An array of strings to be given to the AdMob request to use as keywords. Specifying keywords may increase your CTR.

hasUserConsent (optional)

Boolean. If set to false, Admob will enable GDPR data collection restrictions, set to true for opposite.

Example

local admob = require( "plugin.admob" )

-- AdMob listener function
local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- Load an AdMob interstitial ad
        admob.load( "interstitial", { adUnitId="YOUR_ADMOB_AD_UNIT_ID" } )
    end
end

-- Initialize the AdMob plugin
admob.init( adListener, { appId="YOUR_ADMOB_APP_ID" } )