banner height?

hi, how can I calculate for the device app is running on, what max height of banner can be? 

I found somewhere this code: 

if(common.w \>= 728) then admob\_height = 90 elseif(common.w \>= 468) then admob\_height = 60 else admob\_height = 50 end

but it doesn’t work on my device (android, oneplus 3t) 

This code probably works on landscape mode, but what about portrait with bigger devices?

I set for now 90 for all devices, but it’s not very nice solution.

AFAIK, the Appodeal plugin doesn’t have way to determine banner heights.

https://docs.coronalabs.com/plugin/appodeal/index.html

Ads are standard sizes as defined by the IAB (Internet Advertising Bureau). Mobile banners are 320x50. Though they could come in as 300x50. If you’re on a tablet, you will get likely get a “leaderboard” which is 768x90. I guess it’s possible if you’re on a device that’s not going to accommodate a 768px wide leaderboard, but your device is in the 600 point range, an advertiser could send a 468x60, but the fill rate on those is quite low. 

As for your code, I don’t know how your determining common.w, but if that’s something like display.contentWidth, then that value will be determined by your config.lua, but that doesn’t map to your device’s point size. This is another reason why we recommend a 320x480 content area. Let me try and explain. If you say have a config.lua of 640 wide and 960 high and you use your code, you’re going to expect to get a 468x60 ad, but if you’re on a phone, you’re going to get a 320x50 banner ad. 

A more appropriate test is to determine if you’re on a phone or tablet.  For iOS, this is pretty strait forward, you can simply get the device type an see if the string “iPad” is in the description or not. For Android, it’s a bit tricker. You could use the system.getInfo() API and get the androidDisplayWidthInInches and see if you’re on a 6" or larger screen (or 5", etc.).  See:

https://docs.coronalabs.com/api/library/system/getInfo.html#androiddisplaywidthininches

Rob

AFAIK, the Appodeal plugin doesn’t have way to determine banner heights.

https://docs.coronalabs.com/plugin/appodeal/index.html

Ads are standard sizes as defined by the IAB (Internet Advertising Bureau). Mobile banners are 320x50. Though they could come in as 300x50. If you’re on a tablet, you will get likely get a “leaderboard” which is 768x90. I guess it’s possible if you’re on a device that’s not going to accommodate a 768px wide leaderboard, but your device is in the 600 point range, an advertiser could send a 468x60, but the fill rate on those is quite low. 

As for your code, I don’t know how your determining common.w, but if that’s something like display.contentWidth, then that value will be determined by your config.lua, but that doesn’t map to your device’s point size. This is another reason why we recommend a 320x480 content area. Let me try and explain. If you say have a config.lua of 640 wide and 960 high and you use your code, you’re going to expect to get a 468x60 ad, but if you’re on a phone, you’re going to get a 320x50 banner ad. 

A more appropriate test is to determine if you’re on a phone or tablet.  For iOS, this is pretty strait forward, you can simply get the device type an see if the string “iPad” is in the description or not. For Android, it’s a bit tricker. You could use the system.getInfo() API and get the androidDisplayWidthInInches and see if you’re on a 6" or larger screen (or 5", etc.).  See:

https://docs.coronalabs.com/api/library/system/getInfo.html#androiddisplaywidthininches

Rob