Implimenting ads using composer?

I’ve been looking at this tutorial https://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/ which has helped me out a lot with ads, but I just can’t get them to show for me. Where exactly should I set everything up using composer? this is what my code look likes now and it just wont show…  Could someone help me out with what I’m dong wrong?

local composer = require "composer" local scene = composer.newScene() local GGData = require "GGData" local loadsave = require "loadsave" local ads = require( "ads" ) local bannerAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnnn" --for your iOS banner local interstitialAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnn" --for your iOS interstitial if ( system.getInfo( "platformName" ) == "Android" ) then bannerAppID = "ca-app-pub-4268482669933469/3951033837" --for your Android banner interstitialAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnnn" --for your Android interstitial end local adProvider = "admob" local function adListener( event ) end ads.init( adProvider, appID, adListener ) local box = GGData:new("sample") box:set("message", "hello world") box.anotherValue = 0 box:load() local function play(event) composer.gotoScene("gamescene") end local function mainmenu(event) composer.gotoScene("mainmenu") end function scene:create(event) local sceneGroup = self.view myTable = loadsave.loadTable("myTable.json") local bg = display.newImage("bg.png") sceneGroup:insert(bg) bg:translate(-70, 40) ads.show( "banner", { x=0, y=0, appId=bannerAppID } ) ads.show( "interstitial", { appId=interstitialAppID } ) local options = { width = 250, height = 100, numFrames = 1, sheetContentWidth = 250, sheetContentHeight = 100, } local imageSheet = graphics.newImageSheet( "image4154.png", options ) local gameoverimage = display.newImage( imageSheet, 1 ) gameoverimage:translate(160, 70) sceneGroup:insert(gameoverimage) local youscored = display.newText("Score", 160, 150, native.systemFont, 30) sceneGroup:insert(youscored) youscored:setFillColor(0,0,0) local scorenumber = display.newText(\_G.score, 160, 190, native.systemFont, 30) sceneGroup:insert(scorenumber) scorenumber:setFillColor(0,0,0) local best = display.newText("Best", 160, 240, native.systemFont, 30) best:setFillColor(0,0,0) sceneGroup:insert(best) local highscore = display.newText(box.anotherValue, 160, 270, native.systemFont, 30) highscore:setFillColor(0,0,0) sceneGroup:insert(highscore) local playagain = display.newText("Play Again", 160, 360, native.systemFont, 30) playagain:addEventListener("tap", play) sceneGroup:insert(playagain) playagain:setFillColor(0,0,0) local endgame = display.newText("End Game", 160, 400, native.systemFontBold, 30) sceneGroup:insert(endgame) endgame:addEventListener("tap", mainmenu) endgame:setFillColor(0,0,0) end function scene:show( event ) local phase = event.phase ads.show( "banner", { x=0, y=0, appId=bannerAppID } ) ads.show( "interstitial", { appId=interstitialAppID } ) if "did" == phase then ads.show( "banner", { x=0, y=0, appId=bannerAppID } ) ads.show( "interstitial", { appId=interstitialAppID } ) print( "2: show event, phase did" ) -- remove previous scene's view composer.removeScene( "gamescene" ) end end scene:addEventListener("show", scene) scene:addEventListener("create", scene) return scene

I have the same problem! :frowning:

>:(

It must be doing something wrong with Admob, because I set up a different ad provider perfectly fine.

same question.  The tutorial clearly states what to put in build.settings but I’m not sure where to put the other items.

Also, if I want the interstitial ad to only appear at the end of the game where to I put the code?

Thanks,

Lori

Let me try to simplify this.

These are the basic steps (and files) to implement ads:

  1. In build.settings, include the plugin code.

  2. In main.lua require the ads plugin.

  3. In main.lua assign your various ad ID’s to variables. You may also need to do this in scenes, if you’re implementing multiple providers.

  4. In main.lua write your ad call back listener function

  5. In main.lua call ads.init()

  6. In the scene where you want to show the ad, call ads.show() in the scene:show()'s “did” phase.

6a. in the scene’s scene:hide() function (“will” phase) call ads.hide() if you want them hidden in the next scene.

Rob

Thanks Rob

If I want the ad to show when the player hits the End Game button or when the game ends because the player completed the level, do I need to ad a “scene” that the game goes to in order for the ad to show?

Thanks

Lori

What I would do is goto whatever scene you would normally goto when those events happen.  It sounds like you have or need an “endgame” scene and possibly a “nextlevel” scene.  Just put the ad.show() in the scene:show() function for those scenes.

Rob

I have the same problem! :frowning:

>:(

It must be doing something wrong with Admob, because I set up a different ad provider perfectly fine.

same question.  The tutorial clearly states what to put in build.settings but I’m not sure where to put the other items.

Also, if I want the interstitial ad to only appear at the end of the game where to I put the code?

Thanks,

Lori

Let me try to simplify this.

These are the basic steps (and files) to implement ads:

  1. In build.settings, include the plugin code.

  2. In main.lua require the ads plugin.

  3. In main.lua assign your various ad ID’s to variables. You may also need to do this in scenes, if you’re implementing multiple providers.

  4. In main.lua write your ad call back listener function

  5. In main.lua call ads.init()

  6. In the scene where you want to show the ad, call ads.show() in the scene:show()'s “did” phase.

6a. in the scene’s scene:hide() function (“will” phase) call ads.hide() if you want them hidden in the next scene.

Rob

Thanks Rob

If I want the ad to show when the player hits the End Game button or when the game ends because the player completed the level, do I need to ad a “scene” that the game goes to in order for the ad to show?

Thanks

Lori

What I would do is goto whatever scene you would normally goto when those events happen.  It sounds like you have or need an “endgame” scene and possibly a “nextlevel” scene.  Just put the ad.show() in the scene:show() function for those scenes.

Rob