Switch from iAd to Admob when there is no Ad Inventory

Dear fellow Corona users,

I have a problem related to Banner Ad, when I read the guide about how to use multiple Ad network, I implemented my iAd Listener as below:

local function iAdsListener( event ) print(event.response); if ( event.type == "adStart" and event.isError ) then ads:setCurrentProvider( "admob" ); ads.show( "banner", { x=0, y=0 } ); elseif ( event.type == "adEnd" ) then -- Ad was successfully shown and ended -- Do nothing else print( "Received event", event.type ); end return true end

The iAd was shown successfully in my app but unfortunately iAd is only available in some countries, for all the countries that iAd has not supported yet, Admob ad never shown up.

So my question is, how to detect when iAd is not available?

Here is the response I got from event.response when iAd is not available:

The operation couldn’t be completed. Ad inventory unavailable

Based on the event.response, can I do something like this in my iAd listener? 

local function iAdsListener( event ) if (string.find(event.response, "Ad inventory unavailable") ~= nil) then ads:setCurrentProvider( "admob" ); ads.show( "banner", { x=0, y=0 } ); end return true end

Thanks and regards,

Tran

Perhaps this tutorial will help:

http://coronalabs.com/blog/2013/11/19/tutorial-using-multiple-ad-networks/

Thanks Rob, I think I know where did I make the mistake, I just want to confirm once again, will the event.isError return “true” when iAd is not available in that country? 

Thanks and regards

I can’t say with 100% certainty, but it should.  You get that error when no inventory is available and I would think being in the wrong country would generate the same.

Rob

Perhaps this tutorial will help:

http://coronalabs.com/blog/2013/11/19/tutorial-using-multiple-ad-networks/

Thanks Rob, I think I know where did I make the mistake, I just want to confirm once again, will the event.isError return “true” when iAd is not available in that country? 

Thanks and regards

I can’t say with 100% certainty, but it should.  You get that error when no inventory is available and I would think being in the wrong country would generate the same.

Rob