Admob bug

I have discovered a strange bug with admob banner ads on iOS. I have not tried it on Android.

In my app I have several screens and some of them have a banner ad and some do not.

This is my code to show:

[lua]A.showTop = function()

     if not validateNoAd() then

          if (system.getInfo(“platformName”) == “Android”) then

               ads:setCurrentProvider( “admob” )

               if store.target == “amazon” then

                    ads.show(“banner”, {[“x”]=0, [“y”]=0, appId = amazonAdmobID})

               else

                    ads.show(“banner”, {[“x”]=0, [“y”]=0, appId = googleAdmobID})

               end

          else

               ads:setCurrentProvider( “iads” )

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

          end

          return true

     end

end[/lua]

This is my code to hide:

[lua]ads.hide()[/lua]

So, pretty straight forward implementation.

Here is what I am seeing. It works as you would hope based on the above code until you minimize the app. If you minimize the app while an android ad is showing, then bring it back up, the android ad that had been displaying gets stuck in memory. The ads appear to cycle normally with navigation until I call ads.hide() then the active ad disappears and the jammed ad appears.

This is mainly a problem because it is showing an ad on a page where ads were removed due to space constraints, in my case it’s over the “close window” button since it is at the top. This jammed ad has no click effect, I can click through it and push the “close window” button.

Any advice on how to work around this bug? I’m almost ready to ship and this is holding me up.

Mark,

I don’t have a great answer for you, but regardless of whether this is a bug or not, you can probably avoid it for now by adding code that hides any ads when you suspend.  

Also, I noticed you’re working too hard when writing tables.

{["x"]=0, ["y"]=0} -- is the same same as this: { x = 0, y = 0 } -- simpler to type

Hey.  I also noticed you seem to be displaying two ads at the same time?  This should not work and even if it does, I’m pretty sure it’s not guaranteed.

(Minor complaint: Can you go back and edit that code post to re-indent?  You lost all your indentation and its kind hard to track.)

Ah, never mind on that last, I misread the code.  Here is a slight cleanup for future readers:

A.showTop = function( ) if not validateNoAd() then if (system.getInfo("platformName") == "Android") then ads:setCurrentProvider( "admob" ) ads.show("banner", { x = 0, y = 0, appId = (store.target == "amazon") and amazonAdmobID or googleAdmobID } ) else ads:setCurrentProvider( "iads" ) ads.show("banner", {["x"]=0, ["y"]=0}) end return true end return false end
local function hideAdsOnSuspend( event ) if(event.type == "applicationSuspend") then ads.hide() end end Runtime:addEventListener( "system", hideAdsOnSuspend )

Thanks for the quick reply! That is a good idea, I will try it tomorrow morning and post if it fixes the problem.

Thanks again for the advice, your work around solved my problem.

Hi Mark,

I tried to duplicate your issue but I wasn’t able to.  AdMob banners are behaving normally for me after suspending the app while a banner is displayed and then resuming the app (after a few second pause).  I’m not seeing a “stuck” banner or banner that does not respond to taps.

Out of curiosity, what iOS version and Corona version were you using, and what device were you testing on?  My test was on an iPhone 5, iOS 8.3, Corona SDK 2646.

  • Andrew

iOS version 8.3

corona version 2014.2511

iPhone 5

Because of your prompt I checked and noticed that there is a newer public build. I will upgrade to that but I will probably leave the code to hide the ad when the app is minimized. There is no reason not to do that and I don’t have to lay awake at night wondering if people can close windows. :wink:

Mark,

I don’t have a great answer for you, but regardless of whether this is a bug or not, you can probably avoid it for now by adding code that hides any ads when you suspend.  

Also, I noticed you’re working too hard when writing tables.

{["x"]=0, ["y"]=0} -- is the same same as this: { x = 0, y = 0 } -- simpler to type

Hey.  I also noticed you seem to be displaying two ads at the same time?  This should not work and even if it does, I’m pretty sure it’s not guaranteed.

(Minor complaint: Can you go back and edit that code post to re-indent?  You lost all your indentation and its kind hard to track.)

Ah, never mind on that last, I misread the code.  Here is a slight cleanup for future readers:

A.showTop = function( ) if not validateNoAd() then if (system.getInfo("platformName") == "Android") then ads:setCurrentProvider( "admob" ) ads.show("banner", { x = 0, y = 0, appId = (store.target == "amazon") and amazonAdmobID or googleAdmobID } ) else ads:setCurrentProvider( "iads" ) ads.show("banner", {["x"]=0, ["y"]=0}) end return true end return false end
local function hideAdsOnSuspend( event ) if(event.type == "applicationSuspend") then ads.hide() end end Runtime:addEventListener( "system", hideAdsOnSuspend )

Thanks for the quick reply! That is a good idea, I will try it tomorrow morning and post if it fixes the problem.

Thanks again for the advice, your work around solved my problem.

Hi Mark,

I tried to duplicate your issue but I wasn’t able to.  AdMob banners are behaving normally for me after suspending the app while a banner is displayed and then resuming the app (after a few second pause).  I’m not seeing a “stuck” banner or banner that does not respond to taps.

Out of curiosity, what iOS version and Corona version were you using, and what device were you testing on?  My test was on an iPhone 5, iOS 8.3, Corona SDK 2646.

  • Andrew

iOS version 8.3

corona version 2014.2511

iPhone 5

Because of your prompt I checked and noticed that there is a newer public build. I will upgrade to that but I will probably leave the code to hide the ad when the app is minimized. There is no reason not to do that and I don’t have to lay awake at night wondering if people can close windows. :wink: