ADMOB, integrate both banner and interstitual issue

We don’t have an ETA on a new public build yet.

Rob

The issue that I seem to have is that when using both ad types you can’t pass your appId as a variable; it must be a string within the ads.show() method. However, showing only one adtype in an app works fine. 

This does not work:

ads.show( adType, { x=params.x, y=params.y, appId=params.appId, testMode=params.testMode } )

While this does:

ads.show( adType, {x=params.x, y=params.y, appId = "ca-app-pub-XXXXXXXXXXX/XXXXXXXX", testMode=params.testMode})

I believe this is a bug, can anyone concur?

There shouldn’t be any difference between the two unless for some reason params.appId isn’t a string. 

Rob

Hi,

I just trying to integrate both ad types: banners and interstitials with android and admob v2. I am using the daily built 2014.2373. The problem is that when I initialized with a banner Id I can only show banner ads and viceversa. Any help?

Thanks

That works OK

[lua]

local ads = require “ads”

display.setStatusBar(display.HiddenStatusBar)

– Admob configuration ----------------------------------------------------------------------

local provider = “admob”

local BannerAppID = “ca-app-pub-XXXXXXXXX/YYYY” --Banner

local InterstitialAppID = “ca-app-pub-XXXXXXXXX/YYYY”–Interstitial

– Initialize the ‘ads’ library

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

–ads.show( “banner”, { x=display.screenOriginX, y=display.contentHeight-display.screenOriginY-120,appID=BannerAppID } )

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

ads.show( “interstitial”, { appID=InterstitialAppID } )

[/lua]

That to:

[lua]

local ads = require “ads”

display.setStatusBar(display.HiddenStatusBar)

– Admob configuration ----------------------------------------------------------------------

local provider = “admob”

local BannerAppID = “ca-app-pub-XXXXXXXXX/YYYY” --Banner

local InterstitialAppID = “ca-app-pub-XXXXXXXXX/YYYY”–Interstitial

– Initialize the ‘ads’ library

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

ads.show( “interstitial”, { appID=InterstitialAppID } )

[/lua]

But here is the problem:

[lua]

local ads = require “ads”

display.setStatusBar(display.HiddenStatusBar)

– Admob configuration ----------------------------------------------------------------------

local provider = “admob”

local BannerAppID = “ca-app-pub-XXXXXXXXX/YYYY” --Banner

local InterstitialAppID = “ca-app-pub-XXXXXXXXX/YYYY”–Interstitial

– Initialize the ‘ads’ library

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

ads.show( “interstitial”, { appID=InterstitialAppID } )

[/lua]

have you tried showing at least one banner first?

Sorry Rob. I’ve copied twice the same code.

Yes I can show banners if only I use an appId for banners. Here is the code:

[lua]

local ads = require “ads”

local provider = “admob”

local BannerAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY1” --Banner

local InterstitialAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY2” --Interstitial

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

ads.show( “banner”, { appID= BannerAppID } )

[/lua]

I can also show intertitital ads:

[lua]

local ads = require “ads”

local provider = “admob”

local BannerAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY1” --Banner

local InterstitialAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY2” --Interstitial

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

ads.show( “interstitial”, { appID=InterstitialAppID } )

[/lua]

The problem is if I use an appId for banners and in the ads.show function, I use an appId for intertitials. In this example, no ads are shown.

[lua]

local ads = require “ads”

local provider = “admob”

local BannerAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY1” --Banner

local InterstitialAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY2” –-Interstitial

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

ads.show( “interstitial”, { appID=InterstitialAppID } )

[/lua]

And viceversa.

I also failed showing both types. For example, the following code only shows banner ads.

[lua]

local ads = require “ads”

local provider = “admob”

local BannerAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY1” --Banner

local InterstitialAppID = “ca-app-pub-XXXXXXX/YYYYYYYYYY2” –Interstitial

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

ads.show( “banner”, { appID= BannerAppID }  --works ok for banners

local function myad()  ads.show( “interstitial”, { appID=InterstitialAppID });end

timer.performWithDelay(7000, myad, 1)

[/lua]

Are you getting any errors in your console log of your device?

Jodie try to hard code the appId into each ads.show call. I had the same issue, looks like it won’t accept a variable as a parameter. ads.show( “interstitial”, { appID=“ca-app-pub-XXXXXXX/YYYYYYYYYY2” })

I would just like to add that

[lua]
event.type: string value of “banner” or “interstitial”
[/lua]

wasn’t available before (I have asked for it long time ago).

Will test this today to see if this really works…

i cant acquire ads library because i get this error

error msg:

 

Runtime error

        F:\Android app development\The Red Airship\main.lua:22: module ‘ads’ not

 found:resource (ads.lu) does not exist in archive

        no field package.preload[‘ads’]

        no file ‘F:\Android app development\The Red Airship\ads.lua’

        no file 'G:\Program FRuntime error: F:\Android app development\The Red A

irship\main.lua:22: module ‘ads’ not found:resource (ads.lu) does not exist in archive

 

 

I cant find ads.lua file anywhere.Please help me getting it. Thanks in advance 

Here is the example and the console log. Still same problem:

[lua]

– require controller module

local ads = require “ads”

– Admob configuration

local BannerAppID = “ca-app-pub-4703317686453462/XXXXXX” --Banner

local InterstitialAppID = “ca-app-pub-4703317686453462/YYYYYYYY” --Interstitial

print ("-- Starting …")

– Set up ad listener.

local function adListener( event )  

        print ("-- adListener:", event.type)

end

– Initialize the ‘ads’ library with the provider you wish to use.

print ("-- Showing banner")

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

ads.show( “banner”, { x=display.screenOriginX, y=display.contentHeight-display.screenOriginY-120,appID=“ca-app-pub-4703317686453462/XXXXXXXXX” } )

local function showInterstitial()  

    print("-- showInterstitial function")

    ads.show( “interstitial”, { appID=“ca-app-pub-4703317686453462/YYYYYYYY” } )

end

timer.performWithDelay(5000, showInterstitial, 1)

[/lua]

Console log(with a WARNING):

V/Corona  (31018): > Class.forName: network.LuaLoader
V/Corona  (31018): < Class.forName: network.LuaLoader
V/Corona  (31018): Loading via reflection: network.LuaLoader
I/Corona  (31018): Platform: GT-I9100P / ARM Neon / 4.1.2 / Mali-400 MP / OpenGL ES 2.0 / 2014.2373
V/Corona  (31018): > Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  (31018): < Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  (31018): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
I/Corona  (31018): – Starting …
I/Corona  (31018): – Showing banner
V/Corona  (31018): > Class.forName: CoronaProvider.ads.admob.LuaLoader
V/Corona  (31018): < Class.forName: CoronaProvider.ads.admob.LuaLoader
V/Corona  (31018): Loading via reflection: CoronaProvider.ads.admob.LuaLoader
I/Corona  (31018): [Lua::RuntimeDispatchEvent()] WARNING: This function is deprecated. Use Lua::DispatchRuntimeEvent() instead.
I/Corona  (31018): – showInterstitial function
I/Corona  (31018): – adListener:       interstitial
I/Corona  (31018): – adListener:       banner
I/Corona  (31018): – adListener:       banner

That looks to me like it’s working.  Your banner ads are probably set to cycle every so often.  You might want to call ads.hide() before you call the interstitial.

Rob

I’ve had lots of problems with this, it works then stops working, and is very flakey.  The problem is there is no callback for when the interstitial has been closed.

Right now the ads are very unreliable on device when trying to use both.  Sometimes they both work, sometimes one works but not the other, sometimes neither, sometimes one works then disappears for minutes before it comes back even though you refreshed it a few times in that period.

If you run either alone, it’s mostly fine, but together it’s a disaster.

There is a call back when the ad closes.  See:  http://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/

Rob

Was this recently added?  I struggled with admob with Corona for a while, and did switch to v2 and was too inconsistent.  Been wanting to add ads to my old corona apps but want to show both.  I didn’t see a callback for it before.  I skimmed that page and I see there is a callback for when shown and I’ll give that a try.  I pocketed your recent article on v2 Admob, just never got around to reading it as I am mostly using Unity now.

By the way, Thanks!  That will allow me to revisit this and knock them out if it works well.

Yes, it was recently added.

Here is how i finally managed to show both ads (banner and intertitial):

I have initialized the ads.show function with the following number: “ca-app-pub-4703317686453462/X” (literally), that is: ads.init( “admob”, “ca-app-pub-4703317686453462/X”,adListener )

and I have used my different codes for banner an interstitial as follows:

[lua]

local ads = require "ads"

    – Admob configuration

    local BannerAppID = “ca-app-pub-4703317686453462/3275893837” --Banner

    local InterstitialAppID = “ca-app-pub-4703317686453462/4752627031” --Interstitial

    print ("-- Starting …")

    

    local splashScreen=display.newImage (“imagen.jpg”)

    splashScreen.x=display.contentWidth/2

    splashScreen.y=display.contentHeight/2

    

    – Set up ad listener.

    local function adListener( event ) 

            print ("-- adListener:", event.type)

    end

    – Initialize the ‘ads’ library with the provider you wish to use.

    print ("-- Showing banner")

    ads.init( “admob”, “ca-app-pub-4703317686453462/X”,adListener )

    ads.show( “banner”, { x=display.screenOriginX, y=display.contentHeight-display.screenOriginY-60,appID=“ca-app-pub-4703317686453462/3275893837” } )

    

    local function showInterstitial() 

        print("-- showInterstitial function")

        ads.show( “interstitial”, { appID=“ca-app-pub-4703317686453462/4752627031” } )

    end

    timer.performWithDelay(1000, showInterstitial, 1)

[/lua]

 

From my personal point of view there is a mistake in the init function of the admob plugin.

 

I’ve also noticed the interstitial ad is shown after the banner ad is loaded and usually takes a long time the first time, so I suspect that that can be improved.

It doesn’t work.  
If fires for both banner (just showing a banner causes it to fire) and closing interstitial.

If you are just doing interstitial it works fine, but when doing both the banner ad causes it to fire too.

It would be really nice if this can actually get fixed.

Is it a problem that you get a call back when a banner ad shows?

[quote name=“Rob Miracle” post=“258652” timestamp=“1406943822”]Is it a problem that you get a call back when a banner ad shows?[/quote] Yes