Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to Integrate Appodeal?
Started by Chaiman Oct 13 2017 12:57 PM

1 reply to this topic
appodeal integration ads

Best Answer Rob Miracle , 14 October 2017 - 07:11 AM

local appodeal = require( "plugin.appodeal" )

Put this line in every .lua file where you will call the appodeal.* API's including main.lua and in your example menu.lua.

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- maybe set a flag that you can see in all scenes to know that initialization is complete

    elseif ( event.phase == "failed" ) then  -- The ad failed to load
        print( event.type )
        print( event.isError )
        print( event.response )
    end
end

-- Initialize the Appodeal plugin
appodeal.init( adListener, 
    { appKey="YOUR_APP_KEY",
    locationTracking = false,
	supportedAdTypes = {"banner", "interstitial"},
        childDirectedTreatment = true,
	bannerAnimation = true,
	testMode = true } )

This goes in main.lua.

 

Then in menu.lua  you would call appodeal.show() with the necessary parameters to show your banner.

 

Rob

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Chaiman

[GLOBAL: userInfoPane.html]
Chaiman
  • Observer

  • 12 posts
  • Corona SDK

Let me preface this by letting you know that I am still new at all of this (if you couldn't tell). So I've tried looking at the documentation and video tutorials (the one supplied by Dr. Brian Burton is old and uses CoronaAds) and what not, but I'm just not understanding this integration process. Here's how my game is structured: 1) main.lua - which all it has is:

local composer = require( "composer" )

-- Hide status bar
display.setStatusBar( display.HiddenStatusBar )

-- Go to the menu screen
composer.gotoScene( "menu" )

So, okay it leads me to the 2) menu.lua which contains my menu items such as the play button that will bring my to the game screen aka 3) game.lua. In addition there's the button that leads me to the highscores screen aka the 4) highScores.lua. 

 

What I'm trying to accomplish: On the menu screen there should be a banner ad at the top, but when the player leaves the screen to go the the game, it disappears. In addition, I'd like an interstitial that goes from the highscore to the menu screen.

 

The problem: How do I do this? Looking at the documentation, changing the build.settings to add the plugin and bypass the ATS was easy enough. But afterwards for initialization, I have no idea where I should be putting it? I tried putting this:

local appodeal = require( "plugin.appodeal" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- Show a banner ad
        appodeal.show( "banner", {yAlign="top", placement="testPlacement"} )
        appodeal.show( "interstitial")
    elseif ( event.phase == "failed" ) then  -- The ad failed to load
        print( event.type )
        print( event.isError )
        print( event.response )
    end
end

-- Initialize the Appodeal plugin
appodeal.init( adListener, 
    { appKey="YOUR_APP_KEY",
    locationTracking = false,
	supportedAdTypes = {"banner", "interstitial"},
        childDirectedTreatment = true,
	bannerAnimation = true,
	testMode = true 

in the menu and got a bunch of whatever errors and so I'm just very lost. Help would be appreciated, please don't just refer me to the documentation. Thank you in advance!



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 22,748 posts
  • Corona Staff

  Best Answer

local appodeal = require( "plugin.appodeal" )

Put this line in every .lua file where you will call the appodeal.* API's including main.lua and in your example menu.lua.

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        -- maybe set a flag that you can see in all scenes to know that initialization is complete

    elseif ( event.phase == "failed" ) then  -- The ad failed to load
        print( event.type )
        print( event.isError )
        print( event.response )
    end
end

-- Initialize the Appodeal plugin
appodeal.init( adListener, 
    { appKey="YOUR_APP_KEY",
    locationTracking = false,
	supportedAdTypes = {"banner", "interstitial"},
        childDirectedTreatment = true,
	bannerAnimation = true,
	testMode = true } )

This goes in main.lua.

 

Then in menu.lua  you would call appodeal.show() with the necessary parameters to show your banner.

 

Rob




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: appodeal, integration, ads