Class AdMobModule
Wraps the Google Mobile Ads (AdMob) Unity SDK for Banner, Interstitial, and Rewarded ad formats. Not supported on WebGL.
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.
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
canvasis 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
trueif an interstitial ad is loaded and ready to display.
- IsRewardedAdReady()
Returns
trueif 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
truewhen the ad was shown and closed normally, orfalsewhen not shown due to no ready ad or a display failure.
- ShowRewardedAdAsync()
Shows the rewarded ad. In the Editor, always returns
trueso game flow can be tested without a real device. Returnstruewhen the user completes the ad and earns the reward, orfalseotherwise.
- 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.LogAdRevenueorFirebaseModule.LogAdRevenue.
- OnBannerAdLoaded
Fired when a Banner ad has loaded.
- OnInterstitialAdClosed
Fired when an Interstitial ad is dismissed by the user.
- OnInterstitialAdLoaded
Fired when an Interstitial ad has loaded and is ready to show.
- OnRewardedAdClosed
Fired when a Rewarded ad is dismissed by the user.
- OnRewardedAdLoaded
Fired when a Rewarded ad has loaded and is ready to show.