Table of Contents

Class AdMobModule

Namespace
Titipi.MocaLib2

Wraps the Google Mobile Ads (AdMob) Unity SDK for Banner, Interstitial, and Rewarded ad formats. Supported on Android, iOS, and the Unity Editor; on any other platform every method logs its entry and no-ops, returning its default value.

public static class AdMobModule
Inheritance
AdMobModule
Inherited Members

Properties

Config

The config used to initialize this module.

IsInitialized

Whether the AdMob SDK has been initialized successfully.

Initialization

InitializeAsync(AdMobModuleConfig)

Initializes the Google Mobile Ads SDK and wires ad callbacks. Call RequestBannerAd(), RequestInterstitialAd(), and RequestRewardedAd() after this completes to begin loading each format. Honors the Remote Config kill-switch: when Enabled is false, returns false without starting the SDK — callers never need to check it.

Methods

EnableTestAds(List<TestDevice>)

Opts this session into test ads. Call before InitializeAsync(AdMobModuleConfig) in development builds only. Remove this call before shipping.

GetBannerHeight(Canvas)

Returns the banner height in pixels (or in canvas units when canvas is provided). Returns a fixed editor-only value of 168px in the Editor.

HideBannerAd()

Hides the banner ad without destroying it. Subsequent calls to ShowBannerAd() will restore it instantly.

IsInterstitialAdReady()

Returns true if an interstitial ad is loaded and ready to display.

IsRewardedAdReady()

Returns true if a rewarded ad is loaded and ready to display.

RequestBannerAd()

Creates and starts loading the banner ad without showing it. Returns immediately; the ad loads asynchronously and raises OnBannerAdLoaded when ready. Call once after InitializeAsync(AdMobModuleConfig) completes. The banner stays hidden until ShowBannerAd() is called.

RequestInterstitialAd()

Starts loading the interstitial ad. Returns immediately; the ad loads asynchronously and raises OnInterstitialAdLoaded when ready. On load failure it retries with a delayed exponential backoff (Google discourages immediate in-callback retries). Call once after InitializeAsync(AdMobModuleConfig) completes; reloads automatically after each show.

RequestRewardedAd()

Starts loading the rewarded ad. Returns immediately; the ad loads asynchronously and raises OnRewardedAdLoaded when ready. On load failure it retries with a delayed exponential backoff (Google discourages immediate in-callback retries). Call once after InitializeAsync(AdMobModuleConfig) completes; reloads automatically after each show.

ShowBannerAd()

Shows the banner ad at the bottom-center position. Remembers visibility so the banner is restored after app resume.

ShowInterstitialAdAsync()

Shows the interstitial ad. Returns true when the ad was shown and closed normally, or false when not shown due to no ready ad or a display failure.

ShowRewardedAdAsync()

Shows the rewarded ad. In the Editor, always returns true so game flow can be tested without a real device. Returns true when the user completes the ad and earns the reward, or false otherwise.

UseSampleAdUnits()

Replaces all ad unit IDs with Google's public sample IDs so any device can load test ads, without needing real ad unit IDs or device registration. Call before InitializeAsync(AdMobModuleConfig) in development builds only. Remove before shipping.

Events

OnAdRevenuePaid

Fired for every ad impression revenue event. Wire this to AppsFlyerModule.LogAdRevenue or FirebaseModule.LogAdRevenue.

OnBannerAdClicked

Fired when the user clicks a Banner ad.

OnBannerAdLoadFailed

Fired when a Banner ad fails to load. The banner is not retried automatically.

OnBannerAdLoaded

Fired when a Banner ad has loaded.

OnInterstitialAdClicked

Fired when the user clicks an Interstitial ad.

OnInterstitialAdClosed

Fired when an Interstitial ad is dismissed by the user.

OnInterstitialAdDisplayed

Fired when an Interstitial ad appears on screen. Use this to mute audio and pause gameplay.

OnInterstitialAdLoadFailed

Fired when an Interstitial ad fails to load. A capped exponential-backoff retry is already scheduled, so this may fire repeatedly while the ad remains unavailable — it is transient, not terminal.

OnInterstitialAdLoaded

Fired when an Interstitial ad has loaded and is ready to show.

OnRewardedAdClicked

Fired when the user clicks a Rewarded ad.

OnRewardedAdClosed

Fired when a Rewarded ad is dismissed by the user. This says the ad went away — not that the reward was earned. Await ShowRewardedAdAsync() for that.

OnRewardedAdDisplayed

Fired when a Rewarded ad appears on screen. Use this to mute audio and pause gameplay.

OnRewardedAdLoadFailed

Fired when a Rewarded ad fails to load. A capped exponential-backoff retry is already scheduled, so this may fire repeatedly while the ad remains unavailable — it is transient, not terminal.

OnRewardedAdLoaded

Fired when a Rewarded ad has loaded and is ready to show.