admob.init()

Type Function
Return value none
Revision 2017.3060
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.

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" } )