Why not set a flag if you’re showing a banner or insterstitial and if you don’t care about the banner:
if adType == “banner” then
return true
end
Why not set a flag if you’re showing a banner or insterstitial and if you don’t care about the banner:
if adType == “banner” then
return true
end
[quote name=“Rob Miracle” post=“258655” timestamp=“1406944248”]Why not set a flag if you’re showing a banner or insterstitial and if you don’t care about the banner: if adType == “banner” then return true end[/quote] Cause it is only suppose to fire when it is an interstitial, so it should work without additional monkeying. There should be a reliable way to know if the interstitial is closed. I am trying to use both, I close the banner with hide before calling interstitial (I know it does this already just prefer explicit) and then call banner when it is closed. Been asking for a solution for over a year, when it is added it is bugged.
The adMob plugin has always triggered an adListener event when banner ads show (or not). Phases were added to separate loading and showing. It just so happens that “shown” is used to determine completion of the interstitial while it means you got a banner when doing banner ads.
Rob
The docs, tutorial, and forum post all imply it is for interstitials (which is what is most useful right now)
Just hide your banner ad before you show your interstitial ad. Then when your interstitial ad closes, reshow the banner ad. I do this and it all works perfectly.
[quote name=“spacewolf” post=“259038” timestamp=“1407225098”]Just hide your banner ad before you show your interstitial ad. Then when your interstitial ad closes, reshow the banner ad. I do this and it all works perfectly. [/quote] Or they can just fix it and make it work as they said it should.
Any updates? I’m only running Admob banners and would like to keep banners and interstitials all through Admob.
Not yet.
I manage to use AdMob banners and interstitials (risky as my AdMob a/c may get pulled anytime http://forums.coronalabs.com/topic/48788-google-play-account-terminated/)
Here’s my ad listener code:
local function AdCallback(event) --[[print("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*") print("event.response = " .. tostring(event.response)) print("event.provider = " .. tostring(event.provider)) print("event.isError = " .. tostring(event.isError)) print("event.type = " .. tostring(event.type)) print("event.name = " .. tostring(event.name)) print("loadRequested ", loadRequested) print("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*") --]] if event.provider == "AdMobProvider" then if interstitialRequested then interstitialRequested = false if not simulator then --timer.performWithDelay(1000, function() loadRequested = true ads.load("interstitial", {appId = "ca-app-pub-x/y", testMode = adMobTestMode}) --end, 1) end elseif loadRequested then loadRequested = false else -- Banner. if event.isError then --print("AdMob banner not successful") bannerVisible = false else --print("AdMob banner successful") bannerVisible = true end end else -- Vungle.
In conjunction with:
bannerVisible = false ads.hide()
and:
interstitialRequested = true ads.show("interstitial", {appId = "ca-app-pub-x/y", testMode = adMobTestMode})
and:
if not disableAds and not bannerVisible then ads.show("banner", {x = Screen.left, y = Screen.height, testMode = adMobTestMode}) end
I can easily mix AdMob banners and interstitials.
The only tricky part is the last bit of code shown immediately above. You’ll need a convenient “trigger” point in the app to perform the test. You could just go ahead and call ads,show(“banner” …) but that will, in my experience, result in a flicker as the banner is redisplayed.
Good luck!
MAS1
I no longer use this code - it’s deprecated.
I haven’t tested this yet but all I want is one interstitual right after the open of the app, then run a banner from then on. In the past I had a problem with the time it took for Admob interstituals to load. It could take 5-20 seconds to open and in the mean time, the user could have navigated to multilple places. Have the Admob interstituals gotten better with loading for you?
Yes - interstitials used to take an arbitrary time to display from a call to ads.show().
With ads.load() and ads.show() that problem is fixed. I’ve only used AdMob on Android so far.
Well, I got it figured out and it was easier then I thought. I think my solution was helped since I am using a storyboard setup. I have a spash/title screen that call the interstitial from.
[lua]local ads = require( “ads” )
–Ads
ads.init( “admob”, “ca-app-pub-xxxxx”, adListener )
ads.show( “interstitial”)[/lua]
Then on the page right after this, I used an ads.hide and another ad.show but not ads.init and put the appID in the new ads.show.
[lua]local ads = require( “ads” )
–Add Banner Ad
ads.hide()
ads.show( “banner”, {appId =“ca-app-pub-yyyy”, x = 0, y = 480 } )[/lua]
Admob intersitials are loading much faster now, 2-3 seconds it seems.
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…