Corona Ads with composer - how show new banner page composer page?

Hi,

This might be a newbie question, but I’m building an app using composer, and I haven’t been able to yet figure out where I would put this block of code that the docs mention are needed:

local coronaAds = require( “plugin.coronaAds” )

– Substitute your own placement IDs when generated
local bannerPlacement = “top-banner-320x50”
–local interstitialPlacement = “interstitial-1”

– Corona Ads listener function
local function adListener( event )

    – Successful initialization of Corona Ads
    if ( event.phase == “init” ) then
        – Show an ad
        coronaAds.show( bannerPlacement, false )
        --coronaAds.show( interstitialPlacement, true )
    end
end

– Initialize Corona Ads (substitute your own API key when generated)
coronaAds.init( “5223c2c3-cf81-4c43-ae41-2d4ed16552bc”, adListener )

Does that entire block go in the main.lua?  Or does it go in each of the composer files? And if it goes in each of the composer files, in which function? Would it all go in the “function scene: show ( event )” section?  

I’m hoping to be able to show a new banner ad each time I do a composer.gotoScene(), but when I have the above block of code in each lua file at the very top (before any composer code), it seems to be initializing much more than perhaps is needed.  The first time I composer:goToScene to a page, I see in the console " WARNING: The ‘plugin.coronaads’ library is not available on this platform.".  The second time I see that warning comes up 2 times in a row, the 3rd time it comes up 4 times in a row, etc, etc, (exponentially), so my guess is I’m initializing where I shouldn’t be.

Thanks in advance for any help!

Hi @jc2010,

The following chapter in our “Getting Started” guide outlines a good way to implement Corona Ads when using Composer, i.e. how to set up Corona Ads, where to initialize it, and then where (in main.lua and other scenes) to put the code to load/show ads.

https://docs.coronalabs.com/guide/programming/08/index.html

Hope this helps,

Brent

Oh great, thanks so much! I only saw the ‘quick start’ link at https://coronalabs.com/corona-ads/, I didn’t realize there was info in the ‘getting started’ guide. This helps a lot! Thank you.

Hi @jc2010,

The following chapter in our “Getting Started” guide outlines a good way to implement Corona Ads when using Composer, i.e. how to set up Corona Ads, where to initialize it, and then where (in main.lua and other scenes) to put the code to load/show ads.

https://docs.coronalabs.com/guide/programming/08/index.html

Hope this helps,

Brent

Oh great, thanks so much! I only saw the ‘quick start’ link at https://coronalabs.com/corona-ads/, I didn’t realize there was info in the ‘getting started’ guide. This helps a lot! Thank you.