admob.init()

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

Overview

admob.init() initializes the AdMob plugin. This call is required and must be executed before making other AdMob calls such as admob.load().

Syntax

admob.init( listener, params )
listener (required)

Listener. Listener function that will receive adsRequest events.

params (required)

Table. Table containing AdMob initialization values — see the next section for details.

Parameter Reference

The params table includes parameters for AdMob initialization.

appId (required)

String. The app ID for your app, gathered from the AdMob dashboard.

testMode (optional)

Boolean. Set this value to true to enable test ads. Default is false.

videoAdVolume (optional)

Number. Set desired volume for video ads. Valid values are in the range 0.0 - 1.0. 0.0 for muting ads completely. Default is 1.0.

Important

Video ads that are ineligible to be shown with muted audio are not returned for ad requests made when the app volume is reported as muted or set to a value of 0. This may restrict a subset of the broader video ads pool from serving.

You should always use test ads during development (testMode = true). If you do not, Google may suspend your AdMob account if they detect that live ads have been interacted with during development.

Example

local admob = require( "plugin.admob" )

-- AdMob listener function
local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.provider )
    end
end

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