How to use another adnetwork if event error?

I was just reading the blog about iads and it said “call another network if that one fail” (or something like that).

So please correct me, do I just init another adnetwork in my iads listener that uses its own listener?

So if that second adnetwork fail too, do I just call a third in that listener?

If my first choice is iads and that fail to deliver, inneractive gets called but what if iads suddenly have ads for me, does my inneractive ads get cancelled automatic once iads can deliver?

Can someone please show “how to”?
Happy coding everyone!! [import]uid: 65840 topic_id: 35662 reply_id: 335662[/import]

tried this and it will cause a crash if iAds can’t deliver, it also gets confused with what banner to pick to…

[code]

function inMobiListener(event)
local msg = event.response
if event.isError == true then

print(" INMOBI Error Message: ", msg)
else

print(" INMOBI init success Message: ", msg)
end
end

function innerListener(event)
local msg = event.response
if event.isError == true then
ads.init(“inmobi”, inMobiID, inMobiListener)
print("INNERACTIVE Error Message: ", msg)
else

print(" INNERACTIVE init success Message: ", msg)
end
end

function iAdListener(event)
local msg = event.response
if event.isError == true then
ads.init(“inneractive”, innerID, innerListener)
print(" IADS Error Message: ", msg)
else

print(" IADS init success Message: ", msg)
end
end
ads.init(“iads”, iadsID, iAdListener)
[/code] [import]uid: 65840 topic_id: 35662 reply_id: 141832[/import]

I added a flag that takes care of the banner confusions and crash but how do I make the code less bulky and make it go back and always check if iAds is available?

Here the flag is global, should I write that to a file and check that way or keep it global?

I’m using storyboard btw if it makes a difference on the implementation…

main.lua

currentnetwork = "iads"  
  
function inMobiListener(event)  
 local msg = event.response  
 if event.isError == true then  
 currentnetwork = "iads"  
 print(" INMOBI Error Message: ", msg)  
 else  
   
 print(" INMOBI init success Message: ", msg)  
 end  
end  
   
function innerListener(event)  
 local msg = event.response  
 if event.isError == true then  
 currentnetwork = "inmobi"  
 ads.init("inmobi", inMobiID, inMobiListener)  
 print("INNERACTIVE Error Message: ", msg)  
 else  
   
 print(" INNERACTIVE init success Message: ", msg)  
 end  
end  
   
function iAdListener(event)  
 local msg = event.response  
 if event.isError == true then  
 currentnetwork = "inneractive"  
 ads.init("inneractive", innerID, innerListener)  
 print(" IADS Error Message: ", msg)  
 else  
   
 print(" IADS init success Message: ", msg)  
 end  
end  
   
   
ads.init("iads", iadsID, iAdListener)  

[import]uid: 65840 topic_id: 35662 reply_id: 141838[/import]

tried this and it will cause a crash if iAds can’t deliver, it also gets confused with what banner to pick to…

[code]

function inMobiListener(event)
local msg = event.response
if event.isError == true then

print(" INMOBI Error Message: ", msg)
else

print(" INMOBI init success Message: ", msg)
end
end

function innerListener(event)
local msg = event.response
if event.isError == true then
ads.init(“inmobi”, inMobiID, inMobiListener)
print("INNERACTIVE Error Message: ", msg)
else

print(" INNERACTIVE init success Message: ", msg)
end
end

function iAdListener(event)
local msg = event.response
if event.isError == true then
ads.init(“inneractive”, innerID, innerListener)
print(" IADS Error Message: ", msg)
else

print(" IADS init success Message: ", msg)
end
end
ads.init(“iads”, iadsID, iAdListener)
[/code] [import]uid: 65840 topic_id: 35662 reply_id: 141832[/import]

I added a flag that takes care of the banner confusions and crash but how do I make the code less bulky and make it go back and always check if iAds is available?

Here the flag is global, should I write that to a file and check that way or keep it global?

I’m using storyboard btw if it makes a difference on the implementation…

main.lua

currentnetwork = "iads"  
  
function inMobiListener(event)  
 local msg = event.response  
 if event.isError == true then  
 currentnetwork = "iads"  
 print(" INMOBI Error Message: ", msg)  
 else  
   
 print(" INMOBI init success Message: ", msg)  
 end  
end  
   
function innerListener(event)  
 local msg = event.response  
 if event.isError == true then  
 currentnetwork = "inmobi"  
 ads.init("inmobi", inMobiID, inMobiListener)  
 print("INNERACTIVE Error Message: ", msg)  
 else  
   
 print(" INNERACTIVE init success Message: ", msg)  
 end  
end  
   
function iAdListener(event)  
 local msg = event.response  
 if event.isError == true then  
 currentnetwork = "inneractive"  
 ads.init("inneractive", innerID, innerListener)  
 print(" IADS Error Message: ", msg)  
 else  
   
 print(" IADS init success Message: ", msg)  
 end  
end  
   
   
ads.init("iads", iadsID, iAdListener)  

[import]uid: 65840 topic_id: 35662 reply_id: 141838[/import]