AdMob: wrong ads.height() for some iOS devices

Hi,

it is my first time that i use AdMob and i found 2 issues.

  1. ads.height() returns wrong values (to low) for iPhone5 and iPhone 6, 6plus (tested on the xcode Simulator). For iPhone 4 and iPads the values are fine. No issues on Android.

  2. Also on iOS: When i close an Interstitial ad (tapping on the X) also the banner ad will be closed. When i close a banner ad with ads.hide() and show a Interstitial ad immediately afterwards the ad will not be shown. On Android there are no issues.

Will this be fixed soon? Especially the wrong values from ads.height() are very frustrating. 

Can anybody confirm this issues?

thanks

Hi @toga,

For #1, can you post what your config.lua looks like?

For #2, you should probably wait at least a short amount of time (via a timer or so forth) between hiding one ad and immediately showing another.

Brent

Hi Brent,

here is my config.lua:

application = { content = { width = 800, height = 1200, scale = "letterBox", fps = 60, imageSuffix = { ["@2x"] = 1.3, }, }, }

I want to place my start button above my bottom banner ad. Something like this:

local bottomY = display.contentHeight - display.screenOriginY

startButton.y = bottomY - startButton.contentHeight*0.5 - ads.height()

Thats working perfect for all devices exept iPhone 5,6,6+. For this devices ads.height() should be about + 20 pixels.

Here are some values which i get:  startButton.contentHeight*0.5 is always 75

iPad:  ads.height(): 105, bottomY: 1200 (i get a 90er banner from AdMob). height is perfect 

iPhone5: ads.height(): 105, bottomY: 1310 (i get a 50er banner from AdMob) 

iPhone6: ads.height(): 89,9, bottomY: 1311 (i get a 50er banner from AdMob) 

iPhone6+: ads.height(): 81, bottomY: 1311 (i get a 50er banner from AdMob) 

Samsung Galaxy TabS: 90, bottomY: 1240 (i get a 90er banner from AdMob). height is perfect

Nexus4:  104, bottomY: 1216 (i get a 50 er banner from AdMob). height is perfect   (as for all tested Android devices)

Perhaps it has something to do with the banner height which AdMob returns? iPhone 5,6,6+ is only tested on the xcode simulator.

Hope this helps,

Thomas

if i use no scaling or “zoomEven” or “zoomStretch” everything is fine.

Perhaps my calculation is wrong?

local bottomY = display.contentHeight - display.screenOriginY

startButton.y = bottomY - startButton.contentHeight*0.5 - ads.height()

pics say more than 1000 words:-)

screen1: scale = “letterbox”,
screen2: no scaling in config.lua. button position is perfect.

On Android everything is fine also with scale=“letterbox” . If you want to have a look you can download it on Google Play.  

Hi @toga,

Shouldn’t you be adding “display.screenOriginY” to the content height, thus getting the very bottom of the screen edge in all cases? Then, subtract the ad height from that, and then set the Y anchor on the bottom of the start button and position it at that Y value?

Brent

Hi Brent,

i have exactly done that:

l ocal bottomY = display.contentHeight - display.screenOriginY

startButton.y = bottomY - startButton.contentHeight*0.5 - ads.height()

 

that is an equivalent to your suggestion (which i also tried with the same wrong result):

startButton.y = display.contentHeight - display.screenOriginY - ads.height()

startButton.anchorY = 1

 

and again on Android the same code works perfect on all devices!!! ads.height() is wrong for some iOS devices in letterbox scaling!!!

Hi @toga,

Your math is subtracting the “letterbox bar height”, not adding it.

Your method:

1200 - 80 = 1120

1120 - 75 - 81 = 964

My suggestion:

1200 + 80 = 1280

1280 - 75 - 81 = 1124

 I think there’s some misunderstanding in how letterbox works. With your content area setup (800x1200), let’s consider only the 1200 value, because we’re talking about Y/height here. On “tall” devices like the iPhone5, you’re going to get some positive value for “math.abs(screenOriginY)” which basically equals the height of the letterbox bar. So, you need to add that to the content height, not subtract it, to determine the very bottom edge of the screen on devices like iPhone5 and likely 6/6+. Then, you need to move the start button up from that edge based on the height of the ad.

Best regards,

Brent

Hi Brent,

display.screenOriginY gives me a negative value. Lets assume display.screenOriginY has the value of -80 then my math is:

1200-(-80) = 1280

Thats the same as your math:

1200+math.abs(-80) = 1280

I think my math is correct. I have the same math for Android and there everything is fine.

Perhaps this http://forums.coronalabs.com/topic/53236-admob-v2-using-sdk-version-680 is the reason for the wrong values on iOS?

Best regards,

Thomas

Hi Thomas,

I’ll ask the engineers if the SDK might be returning the wrong height…

Brent

I am building a new app with “Adaptive” mode,

and ads.height() always returns 0…  (ads.show() is called & the banner ad is actually showing on the screen).

could Corona check “Adaptive mode” too?

Hi @joe528,

This is probably a bug. Could I ask you to submit it simple bug report for this, so we have it logged in our system?

Thanks,

Brent

Bug #37781 for ads.height() returning 0 in Adaptive mode.

Hi @toga,

For #1, can you post what your config.lua looks like?

For #2, you should probably wait at least a short amount of time (via a timer or so forth) between hiding one ad and immediately showing another.

Brent

Hi Brent,

here is my config.lua:

application = { content = { width = 800, height = 1200, scale = "letterBox", fps = 60, imageSuffix = { ["@2x"] = 1.3, }, }, }

I want to place my start button above my bottom banner ad. Something like this:

local bottomY = display.contentHeight - display.screenOriginY

startButton.y = bottomY - startButton.contentHeight*0.5 - ads.height()

Thats working perfect for all devices exept iPhone 5,6,6+. For this devices ads.height() should be about + 20 pixels.

Here are some values which i get:  startButton.contentHeight*0.5 is always 75

iPad:  ads.height(): 105, bottomY: 1200 (i get a 90er banner from AdMob). height is perfect 

iPhone5: ads.height(): 105, bottomY: 1310 (i get a 50er banner from AdMob) 

iPhone6: ads.height(): 89,9, bottomY: 1311 (i get a 50er banner from AdMob) 

iPhone6+: ads.height(): 81, bottomY: 1311 (i get a 50er banner from AdMob) 

Samsung Galaxy TabS: 90, bottomY: 1240 (i get a 90er banner from AdMob). height is perfect

Nexus4:  104, bottomY: 1216 (i get a 50 er banner from AdMob). height is perfect   (as for all tested Android devices)

Perhaps it has something to do with the banner height which AdMob returns? iPhone 5,6,6+ is only tested on the xcode simulator.

Hope this helps,

Thomas

if i use no scaling or “zoomEven” or “zoomStretch” everything is fine.

Perhaps my calculation is wrong?

local bottomY = display.contentHeight - display.screenOriginY

startButton.y = bottomY - startButton.contentHeight*0.5 - ads.height()

pics say more than 1000 words:-)

screen1: scale = “letterbox”,
screen2: no scaling in config.lua. button position is perfect.

On Android everything is fine also with scale=“letterbox” . If you want to have a look you can download it on Google Play.  

Hi @toga,

Shouldn’t you be adding “display.screenOriginY” to the content height, thus getting the very bottom of the screen edge in all cases? Then, subtract the ad height from that, and then set the Y anchor on the bottom of the start button and position it at that Y value?

Brent

Hi Brent,

i have exactly done that:

l ocal bottomY = display.contentHeight - display.screenOriginY

startButton.y = bottomY - startButton.contentHeight*0.5 - ads.height()

 

that is an equivalent to your suggestion (which i also tried with the same wrong result):

startButton.y = display.contentHeight - display.screenOriginY - ads.height()

startButton.anchorY = 1

 

and again on Android the same code works perfect on all devices!!! ads.height() is wrong for some iOS devices in letterbox scaling!!!

Hi @toga,

Your math is subtracting the “letterbox bar height”, not adding it.

Your method:

1200 - 80 = 1120

1120 - 75 - 81 = 964

My suggestion:

1200 + 80 = 1280

1280 - 75 - 81 = 1124

 I think there’s some misunderstanding in how letterbox works. With your content area setup (800x1200), let’s consider only the 1200 value, because we’re talking about Y/height here. On “tall” devices like the iPhone5, you’re going to get some positive value for “math.abs(screenOriginY)” which basically equals the height of the letterbox bar. So, you need to add that to the content height, not subtract it, to determine the very bottom edge of the screen on devices like iPhone5 and likely 6/6+. Then, you need to move the start button up from that edge based on the height of the ad.

Best regards,

Brent