-
Notifications
You must be signed in to change notification settings - Fork 86
Fix banners on android 15 #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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(); |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
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.
| // 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() { |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
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.
|
@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) |
|
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 |
|
@Tobertet can you please update the tests? |
|
Please rebase. The existing tests are now enabled |
|
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? |
|
@Tobertet I’ve tested the changes and they work well on Android 15+ and Android 14 or lower. The TOP_CENTER and CENTER positions are still missing, as described in the documentation: 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. |
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)