Repository navigation
fix(android): emit banner refresh events on the nextgen backend - #927
Open
GonzaloSoftonic wants to merge 2 commits into
Open
GonzaloSoftonic wants to merge 2 commits into
GonzaloSoftonic wants to merge 2 commits into
Conversation
GonzaloSoftonic
force-pushed
the
fix/nextgen-banner-refresh-events
branch
from
October 30, 2026 07:47
db9ae9d to
866e2b4
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On the
nextgenAndroid backend, automatic banner refreshes emit no events. The classic backend'sAdListenerfiresonAdLoaded/onAdFailedToLoadon every refresh, so apps that track refreshes (or watch for refresh failures) see them onclassicand lose them after switching toandroidSdk: 'nextgen'.The cause: Next-Gen reports refreshes through a separate
BannerAdRefreshCallback(Google docs). The banner view manager setsBannerAdEventCallbackafter load but neverBannerAdRefreshCallback. It is still missing onmainand in 17.4.0.This PR sets it next to the event callback and maps:
onAdRefreshed→onAdLoaded, with the same payload as a first load (width,height,responseInfo).onAdFailedToRefresh→onAdFailedToLoad, with the same error map as a failed load.Details:
onAdLoaded, a refresh re-blocks hardware-BACK focus on the AdView ([🐛] App Closes On Back Button in Nested Stack Page with BannerAd Loaded (Android) #813) and kicksrefreshBannerPresentation()([🐛] Only half of the add is loading #711), since a same-size refresh causes no size or visibility change to do it.AdViewand emits nothing once thatAdViewis no longer hosted or the view is torn down.BannerAd, because the docs don't say whether a refresh swaps the instance. In 1.5.0 it doesn't (the publicBannerAdwraps the refreshed ad and the SDK moves the event callback to it), but if a later SDK hands back a newBannerAd, the event callback is set on it so clicks and paid events keep arriving.adLoadedPayload,loadAdErrorPayload), plus one for the currentBannerAd(currentBannerAd), so the tests can stub them likepaidEventPayload.No JS or TypeScript change: the events and their payloads are the ones
BannerAdalready handles.Related issues
None found.
Release Summary
Android (nextgen): banner auto-refreshes now emit
onAdLoaded/onAdFailedToLoad, as on the classic backend.Checklist
and followed the process outlined there for submitting PRs.
AndroidiOS(not applicable: the iOS SDK has no Next-Gen backend here)e2etests added or updated in__tests__e2e__jesttests added or updated in__tests__android/src/testNextgen(ReactNativeGoogleMobileAdsBannerAdRefreshCallbackTest)Test Plan
yarn tests:android:unit:nextgen: all pass, including 9 new cases: refresh →onAdLoadedwith the refreshed size and response; refresh into a taller size → AdView resized; fluid refresh → the host view's size; a swappedBannerAdkeeps click events, an unchanged one is left alone; refresh → presentation kick; failed refresh →onAdFailedToLoad; both callbacks queued before a reload or a teardown → nothing emitted. Removing the guard, the resize or the callback handoff each fails its test.yarn tests:android:unit(classic): all pass../gradlew ktlintCheck,git diff --check,yarn lint:spellcheck,yarn lint:docs-links: clean. Java formatted with google-java-format.TestingAVD-1(API 36 Play Store, arm64, local):yarn tests:appium:android:nextgen: shards a and b 18/18 passing, every banner format included. Shard c: every request loaded, then the session idled 5 min with no command and Appium's idle timeout closed it; no assertion failed.yarn tests:appium:android(classic, code untouched by this PR): 10/11 passing on two runs; Rewarded show-close never reachedclosedboth times. The classic build doesn't compile this PR'ssrc/nextgencode, and your x86_64 CI passed it onmain(23 Oct), so I read it as an arm64 emulator issue.nextgen).🔥