adSense.init()

Type Function
Return value none
Revision Release 2022.3683
Keywords AdSense, Google Ads, Google AdSense, init
See also adSense.show()
adSense.*

Overview

Initalizes the Google AdSense plugin. This step is mandatory before any other features or methods can be used.

Syntax

adSense.init( listener, parameters )
listener (required)

Listener. Listener function that will receive adsRequest events.

parameters (required)

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

Parameter Reference

The params table includes parameters for Ad Sense initialization.

clientId (required)

String. Also the data-ad-client in code and should look like ca-pub-xxxxxxxxxxxxxxxx

Example

local adSense = require( "plugin.adSense" )

-- AdSense Ads listener function
local function adListener( event )

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

    end
end
-- Initialize AdSense
adSense.init(adListener, {clientId="ca-pub-xxxxxxxxxxxxxxxx"} )