Unity Plugin - Banner ads
Banner ads are rectangular ads that take up a small part of your app's layout, usually anchored to the top or bottom of the screen. They stay visible while users interact with your app, so they can earn revenue without interrupting the experience.
Before you start, install and initialize the plugin.
Banner refresh
Caution
MDN11 does not currently support banner auto-refresh, so you need to refresh banners manually. Call load periodically, and call show when the banner has loaded.
Refresh only while the banner is on screen. Stop refreshing when the app goes to the background or the user navigates to a screen without the banner, so you don’t request ads nobody sees.
If your current mediation platform (for example MAX, LevelPlay or AdMob) has banner auto-refresh enabled, you have two options: switch to manual refresh as described above, or keep using that platform’s SDK directly for banners until MDN11 supports auto-refresh. Other ad types can still be used via MDN11 in both cases.
1. Subscribe to events
Subscribe to the banner events before calling LoadBanner, so you don't miss any. Unsubscribe when the object is disabled.
void OnEnable()
{
A11MediationSDK.OnBannerLoaded += OnLoaded;
A11MediationSDK.OnBannerLoadFailed += OnLoadFailed;
A11MediationSDK.OnBannerShown += OnShown;
A11MediationSDK.OnBannerShowFailed += OnShowFailed;
A11MediationSDK.OnBannerClicked += OnClicked;
A11MediationSDK.OnBannerClosed += OnClosed; // Not currently raised on Android or iOS
A11MediationSDK.OnBannerRevenue += OnRevenue;
}
void OnDisable()
{
A11MediationSDK.OnBannerLoaded -= OnLoaded;
A11MediationSDK.OnBannerLoadFailed -= OnLoadFailed;
A11MediationSDK.OnBannerShown -= OnShown;
A11MediationSDK.OnBannerShowFailed -= OnShowFailed;
A11MediationSDK.OnBannerClicked -= OnClicked;
A11MediationSDK.OnBannerClosed -= OnClosed;
A11MediationSDK.OnBannerRevenue -= OnRevenue;
}
2. Load the banner
Pass a position and a size. position defaults to A11BannerPosition.Bottom, and you can also use A11BannerPosition.Top. size defaults to A11BannerSize.Standard. See Banner sizes.
3. Show the banner
When OnBannerLoaded fires, call ShowBanner to display the banner.
4. Hide or destroy the banner
The banner stays on screen until you hide or destroy it. HideBanner hides it without destroying it, so you can call ShowBanner again without reloading. DestroyBanner removes it and frees its resources. To show it again after that, call LoadBanner.
A11MediationSDK.HideBanner(AdUnitId); // Hide, keep loaded
A11MediationSDK.ShowBanner(AdUnitId); // Show again
A11MediationSDK.DestroyBanner(AdUnitId); // Remove, for example in OnDestroy()
Full example
using UnityEngine;
using Aurion11.A11Mediation;
public class BannerExample : MonoBehaviour
{
private const string AdUnitId = "your_banner_ad_unit";
void OnEnable()
{
A11MediationSDK.OnBannerLoaded += OnLoaded;
A11MediationSDK.OnBannerLoadFailed += OnLoadFailed;
A11MediationSDK.OnBannerShown += OnShown;
A11MediationSDK.OnBannerShowFailed += OnShowFailed;
A11MediationSDK.OnBannerClicked += OnClicked;
A11MediationSDK.OnBannerClosed += OnClosed; // Not currently raised on Android or iOS
A11MediationSDK.OnBannerRevenue += OnRevenue;
}
void OnDisable()
{
A11MediationSDK.OnBannerLoaded -= OnLoaded;
A11MediationSDK.OnBannerLoadFailed -= OnLoadFailed;
A11MediationSDK.OnBannerShown -= OnShown;
A11MediationSDK.OnBannerShowFailed -= OnShowFailed;
A11MediationSDK.OnBannerClicked -= OnClicked;
A11MediationSDK.OnBannerClosed -= OnClosed;
A11MediationSDK.OnBannerRevenue -= OnRevenue;
}
public void Load() => A11MediationSDK.LoadBanner(AdUnitId, A11BannerPosition.Bottom, A11BannerSize.Standard);
public void Hide() => A11MediationSDK.HideBanner(AdUnitId);
public void Show() => A11MediationSDK.ShowBanner(AdUnitId);
void OnDestroy() => A11MediationSDK.DestroyBanner(AdUnitId);
private void OnLoaded(string id, A11AdInfo info) => A11MediationSDK.ShowBanner(id);
private void OnLoadFailed(string id, A11AdLoadError e) => Debug.LogWarning($"Banner load failed: {e}");
private void OnShown(string id, A11AdInfo info) { }
private void OnShowFailed(string id, A11AdInfo info, A11AdShowError e) => Debug.LogWarning($"Banner show failed: {e}");
private void OnClicked(string id, A11AdInfo info) { }
private void OnClosed(string id, A11AdInfo info) { }
private void OnRevenue(string id, A11AdInfo info) => Debug.Log($"Banner revenue: {info.Revenue} {info.RevenueCurrency}");
}
Banner sizes
The banner size sets how much space the ad takes up on screen and how its height is calculated. A11BannerSize mirrors the size options of the native Android and iOS SDKs. Pass one to LoadBanner. If you omit it, the banner uses the Standard size.
Adaptive sizes only work with ad networks that support them. See Adaptive banner support.
On iOS, both adaptive sizes load an adaptive banner, and widthDp and maxHeightDp are ignored.
| Size | Factory | Description |
|---|---|---|
| Standard (default) | A11BannerSize.Standard |
Classic fixed-size banner, 320×50 (dp on Android, pt on iOS). The same size on every device, so it's easy to reserve space for. |
| Anchored adaptive | A11BannerSize.AnchoredAdaptive(int? widthDp = null) |
For a banner you place at the top or bottom of the screen, usually full width. The ad network calculates the height from the banner width. Pass null to use the width of the screen. |
| Inline adaptive | A11BannerSize.InlineAdaptive(int? widthDp = null, int? maxHeightDp = null) |
Placed inside scrolling content, such as a list or feed. The height varies from ad to ad, and maxHeightDp caps it. Pass null to let the network decide the height. |
Adaptive banner support
Which ad networks support the adaptive banner sizes. For SDK and adapter versions, see Supported ad networks.
| Ad Network | Platform | Adaptive Banner |
|---|---|---|
| AdMob mediation |
iOS | |
| Android | ||
| Google Ad Manager mediation |
iOS | |
| Android | ||
| AppLovin mediation - MAX |
iOS | |
| Android | ||
| LevelPlay mediation |
Android |