iADs and admob

I set up iAds 

[lua]–this is a comment

local ads = require “ads”

local function adListener( event )

local msg = event.response

if event.isError then

– Failed to receive an ad, we print the error message returned from the library.

print(msg)

end

end

ads.init( “iads”, “myAppId”, adListener )–I put in “myAppID” my iOS bundle.

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

[/lua]

It works, but I would like to place admob when iAds si not available in a country.

—******************************************------------

[lua]

I put the admob , I would like to know if this code works.

local ads = require “ads”

local function adListener( event )

local msg = event.response

if event.isError then

– Failed to receive an ad, we print the error message returned from the library.

print(msg)

local provider = “admob”

local BannerAppID = “cfsfwffwfwfwfwfwfwfwfwfwfwfwfwf” 

ads.init( “admob”, BannerAppID, adListener)

ads.show( “banner”, { appID= BannerAppID,x=0,y=0,testMode = false} )

end

end

ads.init( “iads”, “myAppId”, adListener )–I put in “myAppID” my iOS bundle.

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

[/lua]

There are a couple of ways to approach this.  One is to detect the country code returned by the devices localization and then if it matches a list of known iAd supported countries, use iAds else AdMob.  The other option is to go ahead and call iAds and in the event listener, if you get an error, call AdMob. 

We did a tutorial a while back on doing something similar.  http://coronalabs.com/blog/2013/11/19/tutorial-using-multiple-ad-networks/

Rob

I  read the tutorial. It is an example about iOS and android.

But, I would like to set up iADs and admob with iOS.

I change the code .

I dont know if it will work.

[lua]

local ads = require “ads”  

local provider = “admob”

local function adListenerAdMob( event )

local msg = event.response

if event.isError then

– Failed to receive an ad, we print the error message returned from the library.

print(msg)

ads:setCurrentProvider( “iAds” )

 end

end  

local BannerAppID = “cfsfwffwfwfwfwfwfwfwfwfwfwfwfwf” 

ads.init( “admob”, BannerAppID, adListenerAdMob)

ads:setCurrentProvider( “iAds” )

local function adListener( event )

local msg = event.response

if event.isError then

– Failed to receive an ad, we print the error message returned from the library.

print(msg)

 ads:setCurrentProvider( “admob” )

end

end

ads.init( “iads”, “myAppId”, adListener )–I put in “myAppID” my iOS bundle.

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

ads.show( “banner”, { appID= BannerAppID,x=0,y=0,testMode = false} )

[/lua]

Tutorials not not really designed to give you drop-in code to work with but to present you with concepts so you can see how to do it.  You have to adapt it to your specific needs.   If you want both AdMob and iAds in the same app, leave out the “supportedPlatforms” line for the AdMob platform.

Then call iAds first (where the tutorial does Vungle) and in the call back, fail over to AdMob.

There are a couple of ways to approach this.  One is to detect the country code returned by the devices localization and then if it matches a list of known iAd supported countries, use iAds else AdMob.  The other option is to go ahead and call iAds and in the event listener, if you get an error, call AdMob. 

We did a tutorial a while back on doing something similar.  http://coronalabs.com/blog/2013/11/19/tutorial-using-multiple-ad-networks/

Rob

I  read the tutorial. It is an example about iOS and android.

But, I would like to set up iADs and admob with iOS.

I change the code .

I dont know if it will work.

[lua]

local ads = require “ads”  

local provider = “admob”

local function adListenerAdMob( event )

local msg = event.response

if event.isError then

– Failed to receive an ad, we print the error message returned from the library.

print(msg)

ads:setCurrentProvider( “iAds” )

 end

end  

local BannerAppID = “cfsfwffwfwfwfwfwfwfwfwfwfwfwfwf” 

ads.init( “admob”, BannerAppID, adListenerAdMob)

ads:setCurrentProvider( “iAds” )

local function adListener( event )

local msg = event.response

if event.isError then

– Failed to receive an ad, we print the error message returned from the library.

print(msg)

 ads:setCurrentProvider( “admob” )

end

end

ads.init( “iads”, “myAppId”, adListener )–I put in “myAppID” my iOS bundle.

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

ads.show( “banner”, { appID= BannerAppID,x=0,y=0,testMode = false} )

[/lua]

Tutorials not not really designed to give you drop-in code to work with but to present you with concepts so you can see how to do it.  You have to adapt it to your specific needs.   If you want both AdMob and iAds in the same app, leave out the “supportedPlatforms” line for the AdMob platform.

Then call iAds first (where the tutorial does Vungle) and in the call back, fail over to AdMob.