adcolony.init()

Type Function
Return value none
Revision Release 2022.3683
Keywords ads, advertising, AdColony, init
See also adcolony.load()
adcolony.show()

Overview

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

Syntax

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

Listener. Listener function that will receive adsRequest events.

params (required)

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

Parameter Reference

The params table includes parameters for the AdColony initialization.

Note

For developers migrating from the Corona Ads incarnation of the AdColony plugin, the following parameters have been removed from this new plugin:

  • apiKey (replaced by appId)
  • testMode; this is now set per-app in the AdColony dashboard
appId (required)

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

adZones (required)

Table. A table of key-value pairs containing your zones, as defined in the AdColony dashboard. Keys are user-defined, however it's recommended to use meaningful names like interstitial and rewardedVideo since these names are what you'll use in calls to other functions within this plugin. The value for each key-value pair is a string with the zone ID taken from the zones configured in the AdColony dashboard. You can configure as many zones as you want, but you must specify at least one.

adOrientation (optional)

String. The preferred orientation in which you want the ads to be displayed. Valid values are "portrait" and "landscape". Default is "landscape".

userId (optional)

String. A unique user ID to be given to the current user.

debugLogging (optional)

Boolean. If true, turns on debug logging which displays extra debugging information in the device log. Default is false.

privacyFrameworks (required)

Table. A table of key-value pairs containing used privacy regulations as keys and boolean values (true if used) as values. Set only those which are valid for current user. Choices are as follows:

privacyFrameworks = { gdpr=true, coppa=true, ccpa=true },
privacyConsents (required)

Table. A table of key-value pairs containing consent values for privacy frameworks. Set only those which are valid for current user.

privacyConsents = { gdpr=true, coppa=true, ccpa=true },

Deprecated

##### hasUserConsent (optional) Boolean. If set to false, AdColony will enable GDPR data collection restrictions, set to true for opposite.

Example

local adcolony = require( "plugin.adcolony" )

-- AdColony listener function
local function adListener( event )

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

-- Initialize the AdColony plugin
adcolony.init( adListener,
    {
        appId = "YOUR_ADCOLONY_APP_ID",
        adZones = {
            interstitial = "YOUR_ADCOLONY_ZONE_ID_1",
            rewardedVideo = "YOUR_ADCOLONY_ZONE_ID_2"
        }
    })