Ask for consent before showing an ad in the Lite app - #136
Draft
andiwand wants to merge 1 commit into
Draft
Conversation
The Lite app serves ads to EEA, UK and Swiss users with no consent management platform in front of them. ATT is not a substitute: it is Apple's question about the IDFA, and it neither covers the ePrivacy rule on storing and reading identifiers on the device nor satisfies Google's EU user consent policy, which has required a certified CMP integrated with IAB TCF since January 2024. The Android app has had one since f6b942b6; this side never got it. Add Google's UMP SDK, already resolving transitively as a dependency of GoogleMobileAds and now linked explicitly, and gather consent before the banner loads. Whether an ad may be loaded is canRequestAds() and nothing else - never whether the consent calls came back clean - because the SDK caches the decision, so a form that fails to present or an update that times out offline still leaves an earlier consent standing, and outside the regions where a form is required at all there is no decision to fail. Who is asked is decided by UMP, not here: the messages are geo-targeted in AdMob under Privacy & messaging and the SDK resolves the region server-side, so users outside a configured region see no form and get canRequestAds() == true, as today. Move the ad setup to viewDidAppear. The form is presented modally and viewWillAppear is too early for that, since the controller is not in the window hierarchy yet. ATT now follows the consent form rather than replacing it, and is only asked of users who will actually see an ad. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PafKp4GDZk7AYPbSNLTiti
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.
Draft — the code builds, but the consent messages still have to be configured in AdMob before this can ship. See Before merging.
The gap
The Lite app serves ads to EEA, UK and Swiss users with no consent management platform in front of them. Today
DocumentViewControllerasks for ATT and then loads the banner regardless of the answer.ATT is not a substitute. It is Apple's question about the IDFA and cross-app tracking; it does not cover the ePrivacy rule on storing and reading identifiers on the device, and it does not satisfy Google's EU user consent policy, which has required a Google-certified CMP integrated with IAB TCF v2.2 since 16 January 2024.
The Android app has had exactly this since
f6b942b6(Dec 2023). This side never got it.What changed
Package.resolvedtoday); this makes the dependency explicit so the product can be imported.ConsentManager, deliberately shaped like the AndroidAdManagerconsent flow.viewWillAppeartoviewDidAppear— the form is presented modally, andviewWillAppearis too early because the controller is not yet in the window hierarchy. Guarded so the ask happens once per controller.Whether an ad may be loaded is
canRequestAdsand nothing else — never whether the consent calls came back clean. The SDK caches the decision, so a form that fails to present, or an update that times out offline, still leaves an earlier consent standing; and outside the regions where a form is required there is no decision to fail in the first place. This is the same mistake fixed on Android in opendocument-app/OpenDocument.droid#569.Who actually gets asked
Decided by UMP, not by this code: messages are geo-targeted in AdMob under Privacy & messaging, and the SDK resolves the user's region server-side. Users outside a configured region see no form and get
canRequestAds == true, exactly as today.Before merging
ConsentInformation.shared.reset()in a debug menu, or a privacy-settings entry point). GDPR expects consent to be withdrawable, and there is currently no path back to the form.printlogging is the right channel, or route it throughCrashManageras Android does.canRequestAdsis false.Testing
Both schemes build clean:
Not yet run on a device or simulator, and the form has never been displayed because no message is published yet. Worth checking once it is:
ConsentDebugSettingswithDEBUG_GEOGRAPHY_EEAplus a test device id) → form appears before ATT, banner loads after acceptingWhy it matters commercially
iOS is now about a third of ad revenue, and it is the half of the estate with no CMP — so the exposure sits on the growing side. Expect the Android pattern to follow once the form is live: fill rate drops as some users decline or accept only non-personalised ads. That is the cost of doing this correctly, and it is already priced into the Android numbers.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PafKp4GDZk7AYPbSNLTiti