# How To Switch Between Supported Corona Ad Networks?

**URL:** <https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568>\
**Category:** Monetization (in-app purchases, ads, etc.)\
**Created:** [March 17, 2013, 6:53pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568 "2013-03-17T18:53:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Screaming\_Leaf](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@Screaming\_Leaf](https://forums.solar2d.com/u/Screaming_Leaf)\
**Post date:** [March 17, 2013, 6:53pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/1 "2013-03-17T18:53:38Z")

</div>

I think this was a topic somewhere before the new forum, but i can’t find it.

&nbsp;

Is it possible to switch between the different ad networks in an app? For example, if one network fails to load an ad, I want to try getting an ad from another ad network.

&nbsp;

If so what are the steps?

Do I have to use ads.init() every time that I want to switch networks? Do I need to use ads.hide() before I do that? Any guidance would be great. Again, if this is possible.

&nbsp;

Also I am not concerned with people’s opinion’s of the ad networks (iAds,inneractive and inmobi) or trying any of the 3rd party solutions that are floating around. I was just curious how to do this specifically.

---

<div class="post-metadata">

**Author:** ![Naomi](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@Naomi](https://forums.solar2d.com/u/Naomi)\
**Post date:** [March 17, 2013, 7:03pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/2 "2013-03-17T19:03:21Z")

</div>

Hey, Screaming Leaf, check alexf’s responses in this thread (page 3, and repeat of page 3 in page 4). &nbsp;Somewhere in the middle, he answers your question:

&nbsp;

[http://forums.coronalabs.com/topic/28563-iads/page-3](http://forums.coronalabs.com/topic/28563-iads/page-3)

[http://forums.coronalabs.com/topic/28563-iads/page-4](http://forums.coronalabs.com/topic/28563-iads/page-4)

&nbsp;

Naomi

---

<div class="post-metadata">

**Author:** ![Screaming\_Leaf](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@Screaming\_Leaf](https://forums.solar2d.com/u/Screaming_Leaf)\
**Post date:** [March 17, 2013, 7:14pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/3 "2013-03-17T19:14:14Z")

</div>

There it is!

&nbsp;

Thanks Naomi!

&nbsp;

For posterity, this was alexf’s related response:

&nbsp;

1. first init all the providers you want to use, all at the same time:

ads.init( “iads”, appID, adListener )  
ads.init( “inmobi”, appID, adListener )

&nbsp;

1. then switch the current provider as fitting the logic of your code, for example if the iAds network fails to deliver:

– if iads failed  
ads:setCurrentProvider(“inmobi”)

---

<div class="post-metadata">

**Author:** ![Screaming\_Leaf](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@Screaming\_Leaf](https://forums.solar2d.com/u/Screaming_Leaf)\
**Post date:** [March 17, 2013, 9:26pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/4 "2013-03-17T21:26:49Z")

</div>

Okay so that actually doesn’t seem to work. I am using the latest Daily Build 1056 and testing on an iPad3.

&nbsp;

iAds seems to work perfectly.

inneractive ads show up, but the adListener event is never called.

inMobi, nothing really happens. I see an inmobi ad request, but the adListener is never called and an ad never shows up.

&nbsp;

And after a little while the app crashes.

&nbsp;

This was a test, so all I had was a main.lua file with this:

&nbsp;

[lua]

local ads = require( “ads” )

&nbsp;

local function adListener(event)

&nbsp; &nbsp; print("--------------------AD RESPONSE")

&nbsp; &nbsp; print("event.response = " … tostring(event.response))

&nbsp; &nbsp; print("event.provider = " … tostring(event.provider))

&nbsp; &nbsp; print("event.isError = " … tostring(event.isError))

&nbsp; &nbsp; print("-------------------------------")

end

&nbsp;

local adProv = {“iads”,“inneractive”,“inmobi”}

local adIndex = 1

&nbsp;

ads.init( “iads”, “my iads id”, adListener )

ads.init( “inneractive”, “my inneractive id”, adListener )

ads.init( “inmobi”, “my inmobi id”, adListener )

ads:setCurrentProvider(“iads”)

ads.show( “banner”, { x=0, y=0, interval=60 } )

&nbsp;

local function switchAds()

&nbsp; &nbsp; ads.hide()

&nbsp; &nbsp; adIndex = adIndex + 1

&nbsp;

&nbsp; &nbsp; if adIndex \> #adProv then

&nbsp; &nbsp; &nbsp; &nbsp; adIndex = 1

&nbsp; &nbsp; end

&nbsp;

&nbsp; &nbsp; print("\>\> SWITCH TO "…tostring(adProv[adIndex]))

&nbsp;

&nbsp; &nbsp; ads:setCurrentProvider(adProv[adIndex])

&nbsp;

&nbsp; &nbsp; if adProv[adIndex] == “inmobi” then

&nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner320x48”, { x=0, y=100 } )

&nbsp; &nbsp; else

&nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner”, { x=0, y=100 } )

&nbsp; &nbsp; end  
end

&nbsp;

timer.performWithDelay( 15000, switchAds,0)

[/lua]

---

<div class="post-metadata">

**Author:** ![ubj3d.android](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/u/f0a364/32.png) [@ubj3d.android](https://forums.solar2d.com/u/ubj3d.android)\
**Post date:** [March 21, 2013, 11:07am UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/5 "2013-03-21T11:07:32Z")

</div>

> [@Screaming\\\_Leaf](#):
>
> Okay so that actually doesn’t seem to work. I am using the latest Daily Build 1056 and testing on an iPad3.
> 
> &nbsp;
> 
> iAds seems to work perfectly.
> 
> inneractive ads show up, but the adListener event is never called.
> 
> inMobi, nothing really happens. I see an inmobi ad request, but the adListener is never called and an ad never shows up.
> 
> &nbsp;
> 
> And after a little while the app crashes.
> 
> &nbsp;
> 
> This was a test, so all I had was a main.lua file with this:
> 
> &nbsp;
> 
> [lua]
> 
> local ads = require( “ads” )
> 
> &nbsp;
> 
> local function adListener(event)
> 
> &nbsp; &nbsp; print(“--------------------AD RESPONSE”)
> 
> &nbsp; &nbsp; print("event.response = " .. tostring(event.response))
> 
> &nbsp; &nbsp; print("event.provider = " .. tostring(event.provider))
> 
> &nbsp; &nbsp; print("event.isError = " .. tostring(event.isError))
> 
> &nbsp; &nbsp; print(“-------------------------------”)
> 
> end
> 
> &nbsp;
> 
> local adProv = {“iads”,“inneractive”,“inmobi”}
> 
> local adIndex = 1
> 
> &nbsp;
> 
> ads.init( “iads”, “my iads id”, adListener )
> 
> ads.init( “inneractive”, “my inneractive id”, adListener )
> 
> ads.init( “inmobi”, “my inmobi id”, adListener )
> 
> ads:setCurrentProvider(“iads”)
> 
> ads.show( “banner”, { x=0, y=0, interval=60 } )
> 
> &nbsp;
> 
> local function switchAds()
> 
> &nbsp; &nbsp; ads.hide()
> 
> &nbsp; &nbsp; adIndex = adIndex + 1
> 
> &nbsp;
> 
> &nbsp; &nbsp; if adIndex \> #adProv then
> 
> &nbsp; &nbsp; &nbsp; &nbsp; adIndex = 1
> 
> &nbsp; &nbsp; end
> 
> &nbsp;
> 
> &nbsp; &nbsp; print("\>\> SWITCH TO "..tostring(adProv[adIndex]))
> 
> &nbsp;
> 
> &nbsp; &nbsp; ads:setCurrentProvider(adProv[adIndex])
> 
> &nbsp;
> 
> &nbsp; &nbsp; if adProv[adIndex] == “inmobi” then
> 
> &nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner320x48”, { x=0, y=100 } )
> 
> &nbsp; &nbsp; else
> 
> &nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner”, { x=0, y=100 } )
> 
> &nbsp; &nbsp; end  
> end
> 
> &nbsp;
> 
> timer.performWithDelay( 15000, switchAds,0)
> 
> [/lua]

&nbsp;

I can confirm this.

&nbsp;

And inneractive is never refreshing (after displaying the first ad, never get another one, no error, no event trigger…)

---

<div class="post-metadata">

**Author:** ![Naomi](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@Naomi](https://forums.solar2d.com/u/Naomi)\
**Post date:** [March 21, 2013, 3:52pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/6 "2013-03-21T15:52:24Z")

</div>

Yeah, @Screaming Leaf and @ubj3d.android,&nbsp;I filed the bug case #21361.

&nbsp;

Naomi

&nbsp;

Edit: &nbsp;Alexf mentions that they’re in the process of fixing these issues: &nbsp;[http://forums.coronalabs.com/topic/28563-iads/page-4](http://forums.coronalabs.com/topic/28563-iads/page-4)

---

<div class="post-metadata">

**Author:** ![Naomi](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@Naomi](https://forums.solar2d.com/u/Naomi)\
**Post date:** [March 17, 2013, 7:03pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/7 "2013-03-17T19:03:21Z")

</div>

Hey, Screaming Leaf, check alexf’s responses in this thread (page 3, and repeat of page 3 in page 4). &nbsp;Somewhere in the middle, he answers your question:

&nbsp;

[http://forums.coronalabs.com/topic/28563-iads/page-3](http://forums.coronalabs.com/topic/28563-iads/page-3)

[http://forums.coronalabs.com/topic/28563-iads/page-4](http://forums.coronalabs.com/topic/28563-iads/page-4)

&nbsp;

Naomi

---

<div class="post-metadata">

**Author:** ![Screaming\_Leaf](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@Screaming\_Leaf](https://forums.solar2d.com/u/Screaming_Leaf)\
**Post date:** [March 17, 2013, 7:14pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/8 "2013-03-17T19:14:14Z")

</div>

There it is!

&nbsp;

Thanks Naomi!

&nbsp;

For posterity, this was alexf’s related response:

&nbsp;

1. first init all the providers you want to use, all at the same time:

ads.init( “iads”, appID, adListener )  
ads.init( “inmobi”, appID, adListener )

&nbsp;

1. then switch the current provider as fitting the logic of your code, for example if the iAds network fails to deliver:

– if iads failed  
ads:setCurrentProvider(“inmobi”)

---

<div class="post-metadata">

**Author:** ![Screaming\_Leaf](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@Screaming\_Leaf](https://forums.solar2d.com/u/Screaming_Leaf)\
**Post date:** [March 17, 2013, 9:26pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/9 "2013-03-17T21:26:49Z")

</div>

Okay so that actually doesn’t seem to work. I am using the latest Daily Build 1056 and testing on an iPad3.

&nbsp;

iAds seems to work perfectly.

inneractive ads show up, but the adListener event is never called.

inMobi, nothing really happens. I see an inmobi ad request, but the adListener is never called and an ad never shows up.

&nbsp;

And after a little while the app crashes.

&nbsp;

This was a test, so all I had was a main.lua file with this:

&nbsp;

[lua]

local ads = require( “ads” )

&nbsp;

local function adListener(event)

&nbsp; &nbsp; print("--------------------AD RESPONSE")

&nbsp; &nbsp; print("event.response = " … tostring(event.response))

&nbsp; &nbsp; print("event.provider = " … tostring(event.provider))

&nbsp; &nbsp; print("event.isError = " … tostring(event.isError))

&nbsp; &nbsp; print("-------------------------------")

end

&nbsp;

local adProv = {“iads”,“inneractive”,“inmobi”}

local adIndex = 1

&nbsp;

ads.init( “iads”, “my iads id”, adListener )

ads.init( “inneractive”, “my inneractive id”, adListener )

ads.init( “inmobi”, “my inmobi id”, adListener )

ads:setCurrentProvider(“iads”)

ads.show( “banner”, { x=0, y=0, interval=60 } )

&nbsp;

local function switchAds()

&nbsp; &nbsp; ads.hide()

&nbsp; &nbsp; adIndex = adIndex + 1

&nbsp;

&nbsp; &nbsp; if adIndex \> #adProv then

&nbsp; &nbsp; &nbsp; &nbsp; adIndex = 1

&nbsp; &nbsp; end

&nbsp;

&nbsp; &nbsp; print("\>\> SWITCH TO "…tostring(adProv[adIndex]))

&nbsp;

&nbsp; &nbsp; ads:setCurrentProvider(adProv[adIndex])

&nbsp;

&nbsp; &nbsp; if adProv[adIndex] == “inmobi” then

&nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner320x48”, { x=0, y=100 } )

&nbsp; &nbsp; else

&nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner”, { x=0, y=100 } )

&nbsp; &nbsp; end  
end

&nbsp;

timer.performWithDelay( 15000, switchAds,0)

[/lua]

---

<div class="post-metadata">

**Author:** ![ubj3d.android](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/u/f0a364/32.png) [@ubj3d.android](https://forums.solar2d.com/u/ubj3d.android)\
**Post date:** [March 21, 2013, 11:07am UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/10 "2013-03-21T11:07:32Z")

</div>

> [@Screaming\\\_Leaf](#):
>
> Okay so that actually doesn’t seem to work. I am using the latest Daily Build 1056 and testing on an iPad3.
> 
> &nbsp;
> 
> iAds seems to work perfectly.
> 
> inneractive ads show up, but the adListener event is never called.
> 
> inMobi, nothing really happens. I see an inmobi ad request, but the adListener is never called and an ad never shows up.
> 
> &nbsp;
> 
> And after a little while the app crashes.
> 
> &nbsp;
> 
> This was a test, so all I had was a main.lua file with this:
> 
> &nbsp;
> 
> [lua]
> 
> local ads = require( “ads” )
> 
> &nbsp;
> 
> local function adListener(event)
> 
> &nbsp; &nbsp; print(“--------------------AD RESPONSE”)
> 
> &nbsp; &nbsp; print("event.response = " .. tostring(event.response))
> 
> &nbsp; &nbsp; print("event.provider = " .. tostring(event.provider))
> 
> &nbsp; &nbsp; print("event.isError = " .. tostring(event.isError))
> 
> &nbsp; &nbsp; print(“-------------------------------”)
> 
> end
> 
> &nbsp;
> 
> local adProv = {“iads”,“inneractive”,“inmobi”}
> 
> local adIndex = 1
> 
> &nbsp;
> 
> ads.init( “iads”, “my iads id”, adListener )
> 
> ads.init( “inneractive”, “my inneractive id”, adListener )
> 
> ads.init( “inmobi”, “my inmobi id”, adListener )
> 
> ads:setCurrentProvider(“iads”)
> 
> ads.show( “banner”, { x=0, y=0, interval=60 } )
> 
> &nbsp;
> 
> local function switchAds()
> 
> &nbsp; &nbsp; ads.hide()
> 
> &nbsp; &nbsp; adIndex = adIndex + 1
> 
> &nbsp;
> 
> &nbsp; &nbsp; if adIndex \> #adProv then
> 
> &nbsp; &nbsp; &nbsp; &nbsp; adIndex = 1
> 
> &nbsp; &nbsp; end
> 
> &nbsp;
> 
> &nbsp; &nbsp; print("\>\> SWITCH TO "..tostring(adProv[adIndex]))
> 
> &nbsp;
> 
> &nbsp; &nbsp; ads:setCurrentProvider(adProv[adIndex])
> 
> &nbsp;
> 
> &nbsp; &nbsp; if adProv[adIndex] == “inmobi” then
> 
> &nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner320x48”, { x=0, y=100 } )
> 
> &nbsp; &nbsp; else
> 
> &nbsp; &nbsp; &nbsp; &nbsp; ads.show( “banner”, { x=0, y=100 } )
> 
> &nbsp; &nbsp; end  
> end
> 
> &nbsp;
> 
> timer.performWithDelay( 15000, switchAds,0)
> 
> [/lua]

&nbsp;

I can confirm this.

&nbsp;

And inneractive is never refreshing (after displaying the first ad, never get another one, no error, no event trigger…)

---

<div class="post-metadata">

**Author:** ![Naomi](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/n/ee59a6/32.png) [@Naomi](https://forums.solar2d.com/u/Naomi)\
**Post date:** [March 21, 2013, 3:52pm UTC](https://forums.solar2d.com/t/how-to-switch-between-supported-corona-ad-networks/311568/11 "2013-03-21T15:52:24Z")

</div>

Yeah, @Screaming Leaf and @ubj3d.android,&nbsp;I filed the bug case #21361.

&nbsp;

Naomi

&nbsp;

Edit: &nbsp;Alexf mentions that they’re in the process of fixing these issues: &nbsp;[http://forums.coronalabs.com/topic/28563-iads/page-4](http://forums.coronalabs.com/topic/28563-iads/page-4)
