capacitor-community / capacitor-community/admob

Wrong Height gets returned from Top BannerAdPluginEvents.SizeChanged

Open
#304 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
296
Forks
97
Avg merge
2d 6h
Merged PRs (30d)
7

Description

# TLDR:

NOTE: the height returned by BannerAdPluginEvents.SizeChanged is not actually the height of the ad only, but it also includes any ion-safe-area-bottom, i.e. the margin of the ad to the edge of the screen, if it has any. This is not stated in the documentation of BannerAdPluginEvents.SizeChanged but it is the case.

### Correct behaviour when banner at the bottom:
When the ad banner is at the bottom, then the height of the banner returned by BannerAdPluginEvents.SizeChanged is the height of the ad plus var(--ion-safe-area-bottom) (or whatever way you calculate this safe area, if not using ionic)

### Wrong behaviour when banner at the top:
When the ad banner is at the top, then the height of the banner returned by BannerAdPluginEvents.SizeChanged is NOT the height of the ad plus var(--ion-safe-area-top) (although it should be!). It is slightly smaller than that. This causes layout issues.

# Long description:

![7A0E9B85-9448-447B-9AD0-C13F7D2E4323_1_102_o](https://github.com/capacitor-community/admob/assets/81622754/213a2675-0775-48b5-9300-fd9cee7e095f)
as you can see on the picture, I was taking a screenshot on macos, and on the bottom right corner of the ad you can see some dimensions, specifially 374 x 63

obviously those are the correct dimensions of the admob ad:
393 x 60

however when you look at the background of my image, when you look into the XCode console, the returned dimensions of `BannerAdPluginEvents.SizeChanged` turn out to be 393 x 95

somehow a wrong height is returned. Why?

first I thought his might be due to ion-safe-area-top, but it is 47px so this does not quite add up either

are you guys aware of any bugs currently with the height implementation? How could it be that 95px is returned when looking at the image the height is clearly something around 60px ?

This messes up my layout.

Especially on other modes/devices (potrait/landscape or ipads) this error in height is there to, but on a different scale. Somehow the height returned from BannerAdPluginEvents.SizeChanged is never correct

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported BannerAdPluginEvents.SizeChanged values for banners at the top and bottom across the mentioned device orientations, using the Xcode console and the screenshot dimensions as references. Trace where the event height is calculated and compare it with the ad dimensions and safe-area insets; done means the reported height matches the documented behavior and no longer causes the described layout issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.