Hello there, Im trying to use admob interstitial ad in a scene dedicated for that matter. when Im testing on device the game freezes when entering the scene ( interAd.lua ) until the app get closed manualy. cant figure out whats the problem tryed many things but non of them worked… help would be apreciated
build.settings:
plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", }, }, }
main.lua:
local ads = require( "ads" ) if ( system.getInfo( "platformName" ) == "Android" ) then bannerAppID = "ca-app-pub-4025623736156768/5774085732" --for your Android banner interstitialAppID = "ca-app-pub-4025623736156768/2640332533" --for your Android interstitial end local adProvider = "admob" local function adListener( event ) -- The 'event' table includes: -- event.name: string value of "adsRequest" -- event.response: message from the ad provider about the status of this request -- event.phase: string value of "loaded", "shown", or "refresh" -- event.type: string value of "banner" or "interstitial" -- event.isError: boolean true or false local msg = event.response -- Quick debug message regarding the response from the library print( "Message from the ads library: ", msg ) if ( event.isError ) then print( "Error, no ad received", msg ) elseif ( event.type == "interstitial" ) then if ( event.phase == "loaded" ) then print( " ad is ready to be shown" ); -- an ad was preloaded elseif ( event.phase == "shown" ) then print( "gameOver" ); composer.gotoScene( "gameOver" ); end else print( "Ah ha! Got one!" ) end end ads.init( adProvider, interstitialAppID, adListener )
game.lua:
composer.gotoScene( "interAd", { effect = "fade", time = 400 } );
interAd.lua:
local ads = require( "ads" )
interAd: function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then if ( ads.isLoaded( "interstitial" ) ) then ads.show( "interstitial", { appId = interstitialAppID, testMode = true } ) else print( "gameOver" ); composer.gotoScene( "gameOver" ); end end end
in gameOver.lua Im loading the interstitial ad every time when play button tapped