·8 min read

No ViewController: AdMob consent form on iOS

In @capacitor-community/admob 8.1.0 the iOS consent form failed with "No ViewController" until initialize() ran. The cause, the fix, and the upgrade.

admobcapacitorprivacyfirebase

Contents

My games ship on Android only, but the shared ads package behind them is written for both platforms, so when I added Google's consent form to it I tested both: an Android tablet emulator and the iOS simulator. Android worked the first time. On iOS the form never appeared, and the only error anywhere was two words: No ViewController.

This post is that error, its cause, and the other surprise the same day: once a player taps Consent, Firebase Analytics does not apply the answer by itself. Publishing the consent message in AdMob, which a real app ID needs before any of this works, is in AdMob no ads to show: publish a consent message and I will not repeat it here.

The setup: ASMR Logo Craft Block, a Capacitor 8.5 game, @capacitor-community/admob 8.1.0, Google's User Messaging Platform (UMP) for the form, on an iOS 26.1 simulator and an Android 16 tablet emulator.

The order Google asks for

Google's UMP guidance is: ask for the consent status, show the form if it is required, and only start the Mobile Ads SDK once canRequestAds is true. With the plugin that looks like this (a simplified example, not my package's code):

import { AdMob, AdmobConsentStatus } from '@capacitor-community/admob';

let info = await AdMob.requestConsentInfo();
if (info.isConsentFormAvailable && info.status === AdmobConsentStatus.REQUIRED) {
  info = await AdMob.showConsentForm();
}
if (info.canRequestAds) {
  await AdMob.initialize();
  // only now load banners, interstitials, rewarded
}

On Android this ran as written. The form came up over the splash on first launch, I tapped Consent, and the plugin calls that followed were initialize, prepareInterstitial, prepareRewardVideoAd and showBanner.

Why showConsentForm said No ViewController

On the iOS simulator the game launched to its home screen with no form and no banner. No banner was the right outcome: without an answer, my package requests no ads. No form was not.

I called the plugin directly from the page. The status call was fine:

{"isConsentFormAvailable":true,"status":"REQUIRED","canRequestAds":false,
 "privacyOptionsRequirementStatus":"REQUIRED"}

So UMP knew a form was needed and had one ready. Asking it to show the form came back with:

ERR No ViewController

That string lives in the plugin's ConsentExecutor.swift. The form needs a view controller to present itself over, and the executor finds one through a weak reference back to the plugin:

weak var plugin: AdMobPlugin?
// ...
func showConsentForm(_ call: CAPPluginCall) {
    if let rootViewController = plugin?.getRootVC() {
        // load and present the form
    } else {
        call.reject("No ViewController")
    }
}

In 8.1.0 that reference was set in exactly one place, inside initialize():

@objc func initialize(_ call: CAPPluginCall) {
    self.bannerExecutor.plugin = self
    // ...
    self.consentExecutor.plugin = self
    self.setRequestConfiguration(call)
    MobileAds.shared.start(completionHandler: nil)

Before initialize(), plugin is nil, so plugin?.getRootVC() is nil, and the plugin reports a missing view controller even though the app has one. The game's root view controller was fine; the plugin simply had not been told about itself yet. requestConsentInfo worked because it needs no screen. showConsentForm and showPrivacyOptionsForm both do.

So on iOS, Google's order and this plugin's internals were in direct conflict. Two earlier reports of the same error, #291 and #277, had been closed as not planned, with the advice to call initialize() first.

The workaround on 8.1.0

I took that advice on iOS only, and kept Google's order on Android. Again simplified:

if (Capacitor.getPlatform() === 'ios') {
  // 8.1.0 connects the consent form to the screen only inside initialize().
  await AdMob.initialize();
}
// ...then the same requestConsentInfo / showConsentForm flow as above.
// No ad is prepared or shown until canRequestAds is true.

My package calls initialize() once even if consent is gathered twice, and a unit test checks that it runs before requestConsentInfo on iOS, never on Android, and that no ad is prepared by it.

On the next iOS launch the form came up over the splash. I tapped Consent and asked UMP again:

{"canRequestAds":true,"privacyOptionsRequirementStatus":"REQUIRED",
 "isConsentFormAvailable":true,"status":"OBTAINED"}

The cost is plain from the Swift above: initialize() calls MobileAds.shared.start, so on iOS the ads SDK started a moment before the player answered. No ad was requested in that moment, but it is still not the order Google describes.

The real fix: plugin 8.2.0

I filed the iOS order problem upstream as a feature request, pointing at the line that sets the reference and suggesting it move to the plugin's load(). It was fixed in 8.2.0, released three days later: "iOS showConsentForm() and showPrivacyOptionsForm() no longer require an earlier AdMob.initialize() call." In 8.2.1, which I moved to, the consent executor's reference is set in load().

With the workaround removed and a fresh install on an iPad simulator, the native calls were:

To Native ->  AdMob addListener
To Native ->  AdMob requestConsentInfo
To Native ->  AdMob showConsentForm

No initialize before the form, and the form on screen. My ads package now requires 8.2.1 or later, so the old version cannot creep back in. If you are on 8.1.x and see No ViewController from showConsentForm, upgrade the plugin before you reach for the workaround.

What Firebase does with the answer

I had assumed that once UMP wrote the player's choices, Firebase Analytics would pick them up. Half of that is true. After tapping Consent on Android, Firebase logged that it saw the new TCF string:

V FA      : IABTCF_TCString change picked up in listener.

and on the next launch, still with every purpose consented:

V FA      : Setting storage consent(FE): source=MANIFEST,ad_storage=denied,analytics_storage=denied
V FA      : Tcf preferences read: Version=2;...;gdprApplies=1;EnableAdvertiserConsentMode=0;...
W FA      : Analytics storage consent denied; will not get app instance id

Analytics read the answer and stayed denied, on the defaults from the manifest. The setting that connects the two is AdMob's consent mode, turned on from the settings icon of the European regulations card in Privacy & messaging. Google's iOS and Android pages both list it as a prerequisite, along with initializing Firebase before UMP starts. That EnableAdvertiserConsentMode=0 in the log is the switch being off.

What I have not seen is the other half. These runs used Google's sample app ID, whose demo message is not mine to configure, so I could not turn consent mode on and watch Analytics flip to granted. The behaviour above, denied after Consent with consent mode off, is what I measured. That it becomes granted with consent mode on is what Google's documentation says.

A UMP version claim I got wrong

The same afternoon I noticed the plugin pins Google's UMP SDK to ~> 3.1 on iOS (3.1.0 is what resolved), while Android gets 4.0.0. The consent mode page I had read asked for UMP 3.2.0 or higher, so I filed a second issue saying consent mode could not work on iOS with this plugin.

The maintainer replied with the right correction: the page I read was the Android one. The iOS consent mode guide asks for "UMP SDK version 3.0.0 or higher", and 3.1.0 meets it. They also asked how I had checked that Analytics stayed denied on iOS, and the honest answer is that I had not; the denied state I logged was on Android, with consent mode off, which proves nothing about the version. So there may be no iOS gap at all. I do not know yet, and I am not going to claim one until I have run it with consent mode on.

Analytics before an answer, and outside the EU

Until a player answers, Analytics should collect nothing that needs consent. That is four defaults on each platform, all set to false. In AndroidManifest.xml:

<meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_storage" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="false" />

and in Info.plist the same four as Booleans: GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE, _AD_STORAGE, _AD_USER_DATA and _AD_PERSONALIZATION_SIGNALS.

That leaves players who never see the form, because their region needs none. For them my package calls setConsent with granted for all four types. I tested that path on Android by passing a debug geography of OTHER (4 in the plugin's AdmobConsentDebugGeography), which UMP honours only on simulators and registered test devices. No form, four setConsent calls, and Firebase moved from source=MANIFEST denied to source=API granted.

A Privacy choices row for EU players only

A player who answered has to be able to change their mind. UMP says when that entry point is needed: privacyOptionsRequirementStatus is REQUIRED for players in the EU, EEA and UK. My settings screen shows a "Privacy choices" row only in that case, and its Manage button calls showPrivacyOptionsForm().

On the Android emulator, as an EU player, the row was there, Manage opened Google's privacy options form, and Do not consent rewrote the stored choices:

D UserMessagingPlatform: Writing to storage: [IABTCF_PurposeConsents] 00000000000

Every purpose refused, where the earlier Consent had written 11111111111. I did not check what kind of ads came back after that. That the row stays hidden outside the EU is covered by unit tests, not a device run.

What I ran, and where

Path Android emulator iOS simulator
First launch in the EU: form shown yes yes, after the fix
Consent: ads start, answer stored yes yes
Before any answer: Analytics denied yes, in the log same plist defaults, log not read
Privacy choices, then Do not consent yes not run
Outside the EU: no form, Analytics granted yes not run

The form is testable without a published message of your own: on Google's sample app ID it came up on both platforms with nothing configured in the AdMob console.

Takeaway

On @capacitor-community/admob 8.1.x, No ViewController from showConsentForm on iOS means initialize() has not run yet, not that your app lacks a view controller. Upgrade to 8.2.0 or later and keep Google's order. Set the four Analytics defaults to denied, and turn on consent mode in AdMob; without it, Firebase reads the player's Consent and ignores it.

More posts

New writing when there is something worth saying. By email or by RSS, whichever you prefer.