how can you swap between a admob banner and interstitial?
if i load the banner on my first scene and hide it when i go to my next scene and want to load a interstitial ad it shows me a banner. and if i don’t load the banner and only the “interstitial ad scene” it loads the interstitial ad
Banner scene:
local provider = "admob" local appID = "ca-app-pub-\*\*\*\*" local ads = require "ads" local screenGroup = self.view local statusText = display.newText( "", 0, 0, native.systemFontBold, 22 ) statusText:setTextColor( 255 ) statusText:setReferencePoint( display.CenterReferencePoint ) statusText.x, statusText.y = display.contentWidth \* 0.5, 160 local showAd local function adListener( event ) local msg = event.response print("Message received from the ads library: ", msg) if event.isError then statusText:setTextColor( 255, 0, 0 ) statusText.text = "Error Loading Ad" statusText.x = display.contentWidth \* 0.5 local screenGroup = self.view showAd( "banner" ) else end end if appID then ads.init( provider, appID, adListener ) end local sysModel = system.getInfo("model") local sysEnv = system.getInfo("environment") local screenGroup = self.view showAd = function( adType ) local screenGroup = self.view local adX, adY = display.screenOriginX, 400 statusText.text = "" ads.show( adType, { x=adX, y=adY } ) end if sysEnv == "simulator" then else local screenGroup = self.view ads.show( "banner", { x=display.screenOriginX, y=400 } ) end
interstitial scene:
local provider = "admob" local appID = "ca-app-pub-\*\*\*" local ads = require "ads" local screenGroup = self.view local statusText = display.newText( "", 0, 0, native.systemFontBold, 22 ) statusText:setTextColor( 255 ) statusText:setReferencePoint( display.CenterReferencePoint ) statusText.x, statusText.y = display.contentWidth \* 0.5, 160 local showAd -- Set up ad listener. local function adListener( event ) local msg = event.response print("Message received from the ads library: ", msg) if event.isError then statusText:setTextColor( 255, 0, 0 ) statusText.text = "Error Loading Ad" statusText.x = display.contentWidth \* 0.5 local screenGroup = self.view showAd( "banner" ) else end end if appID then ads.init( provider, appID, adListener ) end showAd = function( adType ) local screenGroup = self.view local adX, adY = display.screenOriginX, display.screenOriginY statusText.text = "" ads.show( adType, { x=adX, y=adY } ) end -- if on simulator, let user know they must build for device if sysEnv == "simulator" then else local screenGroup = self.view ads.show( "interstitial", { x=0, y=0 } ) end