Skip to content

Conversation

@Tobertet
Copy link

On Android 15, the banners are being shown on top of the navigation bar and the status bar due to the edge-to-edge.

With this pull request, a new container has been added over the View that makes the ads fit into the actual webview. Also, on Landscape, the ad will be aligned to the left (the same way it was happening on android 14)

@distante distante requested a review from Copilot September 30, 2025 17:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes banner positioning issues on Android 15 by implementing proper edge-to-edge display handling. The banners were previously appearing on top of the navigation bar and status bar due to Android 15's edge-to-edge changes.

  • Implements window inset handling to properly position banners within the safe area
  • Adds landscape-specific positioning that aligns banners to the left instead of centering
  • Refactors the banner container creation and attachment logic for better edge-to-edge compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


if (mAdView != null) {
updateExistingAdView(adOptions);
call.resolve();
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call.resolve() is executed before the ad loading completes when updating an existing ad view. This may cause timing issues as the method returns success before the ad update is actually processed.

Copilot uses AI. Check for mistakes.
Comment on lines 242 to 253
// Add the AdView to the container
mAdViewLayout.addView(mAdView);

// Add container above WebView and request insets now that it's attached
mViewGroup.addView(mAdViewLayout);
mAdViewLayout.bringToFront();
ViewCompat.requestApplyInsets(mAdViewLayout);

// Start loading the ad.
mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The banner container is added to the view hierarchy before the ad loading starts, which could cause layout issues if the ad fails to load. Consider moving these operations inside the onAdLoaded callback to ensure proper cleanup on failure.

Copilot uses AI. Check for mistakes.
@luisbytes
Copy link
Contributor

@distante Could we merge this?

At this time, it's impossible to use the banner with Capacitor v7 due to the safe area set in Android 15 by default. The solution found in the prerelease (fa4c1b5) is half-finished because it fixes the safe area in Android 15, but it affects versions 14 and below (#362)

@distante
Copy link
Contributor

distante commented Oct 2, 2025

as per your comment on #363 (comment) , this is now deprecated. Correct?

(I am currently without of time due work)

@luisbytes
Copy link
Contributor

as per your comment on #363 (comment) , this is now deprecated. Correct?

(I am currently without of time due work)

Hello, not my comment on #363 refers to an error with the interstitial ads.

They are two different things This PR is solving the problem of banners with the Safe Area by Android 15+ default

@distante
Copy link
Contributor

distante commented Oct 4, 2025

@Tobertet can you please update the tests?

@distante
Copy link
Contributor

distante commented Oct 5, 2025

Please rebase. The existing tests are now enabled

@Tobertet
Copy link
Author

Tobertet commented Oct 8, 2025

Hey @distante, sorry I couldn't do it earlier. I rebased and also ran the fmt command. There are other files affected by this format. What do you mean by updating the tests?

@luisbytes
Copy link
Contributor

@Tobertet I’ve tested the changes and they work well on Android 15+ and Android 14 or lower.
Unfortunately, this refactor only considers the BOTTOM_CENTER position.

The TOP_CENTER and CENTER positions are still missing, as described in the documentation:
https://github.com/capacitor-community/admob?tab=readme-ov-file#banneradposition

Also, I think @distante was referring to updating the unit tests as well.

@distante, while this refactor is still in progress, it might be a good idea to merge my PR #379, which only includes the fix for Android 15+, without affecting the code currently published on npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants