If your app shows ads, the first minute after install usually comes with legal paperwork. Users in some regions need to see a consent form. On iOS you also have to decide whether to show Apple's App Tracking Transparency (ATT) prompt. Both are easy to get wrong in the same few ways: the prompts appear in the wrong order, the ad SDK starts before consent is known, the ATT dialog never shows, or users have no way to change their choice later.
This post walks through a sequence that works for a small app using Google's AdMob and its User Messaging Platform (UMP) SDK. The same ideas apply if you use a different consent management platform (CMP).
Two different questions
It helps to keep the two prompts apart in your head, because they answer different questions.
- Consent under privacy regulations (GDPR in the EEA and UK, plus various US state laws). The question is whether you may process this user's personal data for advertising purposes, and for which purposes and vendors. The answer is stored as a standardized consent string that ad SDKs read.
- ATT on iOS. The question is whether your app may track this user across other companies' apps and websites, which includes access to the advertising identifier (IDFA). The answer is stored by the operating system, and the system dialog can only ever be shown once per install.
A user can say yes to one and no to the other. Your code has to handle all four combinations, and the ad SDKs will mostly handle the details for you as long as you don't start them too early.
The order of operations
The flow most apps should use looks like this:
- On every launch, ask the consent SDK to refresh the consent status. This is a quick network call.
- If a form is required (for example, a new user in the EEA), show it.
- On iOS, once that's done, show your own short explainer screen if you want one, then the ATT system prompt.
- Only then initialize the Mobile Ads SDK and start loading ads.
- Put a permanent "Privacy choices" entry in your settings screen so users can change their answers.
Consent goes before ATT because the consent form is where users in regulated regions make their detailed choices, and asking about tracking before they have agreed to any processing gets things backwards. UMP can also show an IDFA explainer message just before the ATT prompt if you set one up in the AdMob console, which saves you building your own.
Android: gathering consent before ads
class ConsentManager(private val activity: Activity) {
private val consentInfo =
UserMessagingPlatform.getConsentInformation(activity)
fun gather(onReady: () -> Unit) {
val params = ConsentRequestParameters.Builder().build()
consentInfo.requestConsentInfoUpdate(
activity,
params,
{
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) { formError ->
formError?.let { Log.w("Consent", it.message) }
if (consentInfo.canRequestAds()) onReady()
}
},
{ requestError ->
Log.w("Consent", requestError.message)
// Fall back to whatever status was stored last time.
if (consentInfo.canRequestAds()) onReady()
}
)
// A returning user may already be cleared to request ads.
if (consentInfo.canRequestAds()) onReady()
}
}onReady can fire twice in that code: once right away for a returning user, and once after the update finishes. Make your ads setup safe to call more than once, for example with an AtomicBoolean guard around MobileAds.initialize.
iOS: consent, then ATT, then ads
The Swift API names in UMP have changed between major versions, so check them against the version you install. The structure doesn't change:
func gatherConsentThenStartAds(from vc: UIViewController) {
let params = RequestParameters()
ConsentInformation.shared.requestConsentInfoUpdate(with: params) { error in
ConsentForm.loadAndPresentIfRequired(from: vc) { formError in
requestTrackingIfNeeded {
if ConsentInformation.shared.canRequestAds {
startAdsOnce()
}
}
}
}
}
func requestTrackingIfNeeded(_ done: @escaping () -> Void) {
guard ATTrackingManager.trackingAuthorizationStatus == .notDetermined else {
done(); return
}
ATTrackingManager.requestTrackingAuthorization { _ in
DispatchQueue.main.async { done() }
}
}You also need an NSUserTrackingUsageDescription string in Info.plist. Without it, the request call does nothing useful and your app can be rejected in review.
ATT timing pitfalls
The most common ATT bug is a prompt that never appears. Usually that's because the request ran while the app wasn't fully active, for example straight from application(_:didFinishLaunchingWithOptions:) or while another system alert was on screen. The status stays .notDetermined and the callback returns without showing anything. Two habits avoid this:
- Request authorization in response to the app becoming active, or after your first screen has appeared, not during launch.
- Don't stack it on top of another system prompt, such as notification permission. Space them out, or ask for notifications later when there's a reason to.
Then there are the policy rules. You may explain why you're asking, but you may not offer a reward for allowing tracking, block features until the user allows it, or design a fake pre-prompt that sends a "no" tap to the real dialog anyway. A short, honest explainer is fine: one screen that says ads keep the app free and that more relevant ads support the developer, with a single "Continue" button that leads to the system prompt.
Don't start the ad SDK early
Initializing the Mobile Ads SDK or mediation adapters before consent is known can send requests based on stale or missing consent. It's tempting to do this anyway, because initialization takes time and you want the first ad ready quickly. A better compromise:
- Start the consent update as early as possible, in parallel with your other startup work.
- For returning users, check
canRequestAdsright away. If it's already true from the last session, initialize at once. - Don't show a full-screen ad in the first moments of a first session anyway. That gives the consent flow time to finish before any ad matters.
If startup time is already a concern, the approach in Reducing App Startup Time on iOS and Android helps: measure what initializing the ad SDK really costs before deciding where it goes.
Give users a way back
Regulations generally require that withdrawing consent be as easy as giving it. In practice that means a permanent entry in your settings. UMP tells you whether one is required:
val required = consentInfo.privacyOptionsRequirementStatus ==
ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
privacyRow.isVisible = required
privacyRow.setOnClickListener {
UserMessagingPlatform.showPrivacyOptionsForm(activity) { error ->
error?.let { Log.w("Consent", it.message) }
}
}You can't trigger ATT a second time. If an iOS user wants to change their tracking choice, the best you can do is explain that it lives in the system Settings app under Privacy, and link to your app's settings page with UIApplication.openSettingsURLString.
Testing the flow
Testing consent flows is awkward because the state sticks around. Set up a repeatable routine:
- Force the geography. UMP's debug settings let you pretend the device is in the EEA or in a regulated US state. Register your device's hashed test ID, which the SDK prints in the logs, and set the debug geography in a debug-only build.
- Reset between runs. Call
reset()on the consent information in a hidden debug menu. Never ship that call in a release path. - Reset ATT. Deleting and reinstalling the app resets ATT status. On a test device, also check that the system setting allowing apps to request tracking is turned on. If it's off, the prompt never appears and the status reads as denied.
- Walk all combinations. Consent accepted or rejected, ATT allowed or denied, and offline at launch. In each case, confirm that the app doesn't hang, ads either load or quietly don't, and the privacy options row shows when it should.
Measure what happens, don't guess
Consent and ATT outcomes affect revenue, but how much depends on your audience, region mix and ad formats. Instead of relying on published averages, log your own anonymous, aggregate events: consent form shown, consent outcome category, ATT status after the prompt, and whether the first ad request succeeded. Compare eCPM and fill by region in your ad network reports before and after any change to the flow. If fill drops sharply in one region after a consent change, the steps in Diagnosing Low Fill Rates in Your App's Ads help narrow down the cause. Check whether you're mostly serving non-personalized or limited ads there before blaming the network.
Treat the explainer screen as something you can change. If you rewrite the copy, ship it to a slice of users and compare ATT allow rates in your own analytics. Keep it honest either way. A wording that wins by misleading people is a review problem waiting to happen.
Wrapping up
Getting consent and ATT right is mostly about sequence and discipline, not clever UI:
- Refresh consent status on every launch and show the form only when required.
- On iOS, show ATT after consent, once the app is active, with at most one honest explainer screen.
- Initialize ads only when
canRequestAdsis true, and make that setup safe to call more than once. - Keep a privacy choices entry in settings for as long as it's required.
- Test with forced geographies and reset state, and measure outcomes with your own data.
Done this way, the flow takes a few seconds the first time someone opens the app. After that it stays out of the way, and you have a straightforward answer when a reviewer or a user asks how you handle their data.