Show the banner when consent is cached but the consent call fails - #569
Open
andiwand wants to merge 1 commit into
Open
Show the banner when consent is cached but the consent call fails#569andiwand wants to merge 1 commit into
andiwand wants to merge 1 commit into
Conversation
The consent flow decided whether an ad may be requested from whether the UMP call came back clean, rather than from canRequestAds(). Both error paths hid the banner outright: - requestConsentInfoUpdate failing hid it and returned. Its own comment notes this fires for the mundane offline case, when a device that was asleep times out against fundingchoicesmessages.google.com. - a non-null FormError from loadAndShowConsentFormIfRequired hid it even when canRequestAds() was true. Neither is a refusal. The SDK caches the user's decision, so a form that fails to show or an update that times out still leaves an earlier consent standing, and outside the regions where a form is required at all there is no decision to fail in the first place. A single timeout therefore blanked the banner for the whole session, for users who had already said yes and for users who were never going to be asked. Decide on canRequestAds() alone in both callbacks, and keep logging the errors as breadcrumbs rather than acting on them. showGoogleAds() runs at billing setup and again on every onConfigurationChanged, so this path is hit on every launch and every rotation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PafKp4GDZk7AYPbSNLTiti
5 tasks
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.
The consent flow decides whether an ad may be requested from whether the UMP call came back clean, rather than from
canRequestAds(). Both error paths hide the banner outright, and neither error is a refusal.{ requestConsentError -> crashManager.log("consent info update failed: " + describe(requestConsentError)) hideGoogleAds() // <- no canRequestAds() check },The SDK caches the user's decision, so a form that fails to show — or an update that times out because the device is offline — still leaves an earlier consent standing. Outside the regions where a form is required at all, there is no decision to fail in the first place. The existing comment already names the common case:
showGoogleAds()runs at billing setup and again on everyonConfigurationChanged, so one timeout blanks the banner for the rest of the session — for users who had already consented, and for users outside the EEA who were never going to be asked.What changed
Both callbacks now decide on
canRequestAds()alone, via a sharedshowAdsIfConsented(). Errors are still logged as breadcrumbs, but are no longer acted on. This matches Google's documented pattern, which checkscanRequestAds()in the success and failure callbacks.A genuine refusal is unaffected:
canRequestAds()returns false, the banner stays hidden, and no ad is requested.Why it is worth fixing
Android match rate — the share of ad requests Google fills — since the consent form shipped in
f6b942b6(Dec 2023):Show rate over the same period improved to ~92%, so this is not a rendering problem. Most of that gap is expected and correct — non-personalised requests are simply filled less often. This change does not address that; it only stops the app discarding inventory it was entitled to serve.
Testing
Not built or run — I have no Java runtime available, so
spotlessCheckand the build were not executed. Formatting was matched to ktfmt kotlinlangStyle by hand (4-space indents, under 100 columns); please let CI confirm.Worth verifying on device:
ConsentDebugSettingswithoutDEBUG_GEOGRAPHY_EEA) → banner appears as beforeThe logging added in #516 should show
consent info update failedfollowed by a banner, rather than by silence.🤖 Generated with Claude Code
https://claude.ai/code/session_01PafKp4GDZk7AYPbSNLTiti