appodeal.init()

Type Function
Return value none
Revision 2017.3060
Keywords ads, advertising, Appodeal, init
See also appodeal.show()
appodeal.*

Overview

appodeal.init() initializes the Appodeal plugin.

Once initialized, you can show an ad using appodeal.show().

Syntax

appodeal.init( adListener, params )
adListener (required)

Listener. Listener function that will receive adsRequest events.

params (required)

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

Parameter Reference

The params table includes initialization properties for the Appodeal plugin.

appKey (required)

String. Your Appodeal app key. You can find this ID in the Appodeal developer portal, located under your app's name as "Application Key."

testMode (optional)

Boolean. Test mode enables verbose logging to help with debugging and it also serves test ads from networks that support them. To enable test mode, set this value to true. Default is false.

autoCacheAds (optional)

Boolean. By default, Appodeal automatically caches ads in the background. Set this value to false to turn it off. Default is true. If you turn automatic caching off, you must use appodeal.load() to manually load ads.

smartBanners (optional)

Boolean. Smart banners will automatically adjust their width and height to the device. By default, smart banners are enabled. Set this value to false to disable them.

bannerAnimation (optional)

Boolean. Set to true to animate banner transitions (cross-fade when switching banners). Default is false.

customRules (optional)

Table. Set custom rules to be used with placements. Placements are an advanced feature used together with "Segments" as defined in the Appodeal dashboard. This is a table with key-value pairs of data. You can choose key names freely as there are no pre-defined key names. Valid value types are strings, booleans, or numbers.

supportedAdTypes (optional)

Array. Limits the type of ads you want Appodeal to serve. By default, banner, static interstitial, video, and rewarded video ads will be served. You can limit the type of ads to load by specifying which types to support inside this table array. Valid values include "banner", "interstitial", "video" and "rewardedVideo".

Example

local appodeal = require( "plugin.appodeal" )

local function adListener( event )

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

-- Initialize the Appodeal plugin
appodeal.init( adListener, { appKey="YOUR_APP_KEY" } )