Hi,
After test and deploy code into ios device, i notice that when we call ads.load( “interstitial”) and then follow by
ads.show( “banner”), we can not catch loaded event from listener. And i think after banner load, ads.isLoaded(“interstitial”) return false . I had search google and our forum and see some thread tell about ads.isLoaded(“interstitial”) not works in ios, and maybe it is because ads.show( “banner”) or ads.hide(“banner”) will remove that flag?
So how can we load interstitial and get notify load done while we show banner ads to user?
[lua]display.setStatusBar( display.HiddenStatusBar )
–
– main.lua
_G.MINX = display.screenOriginX;
_G.MINY = display.screenOriginY;
_G.MAXX = display.contentWidth - display.screenOriginX
_G.MAXY = display.contentHeight - display.screenOriginY
_G.W = _G.MAXX - _G.MINX;
_G.H = _G.MAXY - _G.MINY;
_G.CX = _G.MINX + _G.W/2
_G.CY = _G.MINY + _G.H/2
local interstitial_id = “ca-app-pub-8692884682865005/1494522774”
local banner_id = “ca-app-pub-8692884682865005/9017789578”
local self = {};
local ads = require( “ads” )
local function adListener(event)
print( “event.phase:”…event.phase…",event.type: “…event.type…”,ads_isLoaded_interstitial:",ads.isLoaded(“interstitial”) )
if ( event.isError ) then
–Failed to receive an ad
print( “interstitial: Failed to receive an ad” )
elseif event.phase == “loaded” and event.type == “interstitial” then
self.l2 = system.getTimer( );
self.load_time = self.l2 - self.l1;
print( "Load interstitial done in: "…self.load_time)
elseif event.phase ==“shown” and event.type == “interstitial” then
self.s2 = system.getTimer( );
self.show_time = self.s2 - self.s1;
elseif event.phase ==“shown” and event.type == “banner” then
print( “banner show done”)
end
end
ads.init( “admob”, interstitial_id,adListener)
self.l1 = system.getTimer( );
ads.load( “interstitial”, { appId=interstitial_id, testMode=false })
– if we comment line bellow, loaded event still fired
ads.show( “banner”, { x=MINX, y=MAXY, appId=banner_id } )[/lua]