A banner is a rectangular ad format with predefined sizes, typically displayed at the bottom of the screen, within content, or in a content feed. Follow the steps below to integrate and manage banner ads in Unity.
First, import the SDK into your Unity class:
using Plugins.RtbStackSDK;
To load and display a banner ad, call the following method:
int [,] sizes = {{300, 250}};
RtbStackSDK.LoadBanner("ENDPOINT_REQUEST_URL", "TAG_ID", sizes, RtbStackSDK.BannerPosition.BOTTOM);
Details:
TOP
, CENTER
, BOTTOM
).Subscribe to banner events to track loading, errors, and clicks:
RtbStackSDK.onBannerAdLoadedEvent += onBannerAdLoaded;
RtbStackSDK.onBannerAdFailedToLoadEvent += onBannerAdFailedToLoad;
RtbStackSDK.onBannerAdClickedEvent += onBannerAdClicked;
void onBannerAdLoaded(string tagID) {
// Handle banner loaded
}
void onBannerAdFailedToLoad(string tagID, string error) {
// Handle banner load failure
}
void onBannerAdClicked(string tagID, string url) {
// Handle banner click
}
When the banner ad is no longer needed, destroy it to free up resources:
RtbStackSDK.DestroyBanner("TAG_ID");
The RTB-Stack SDK allows you to configure the following banner options:
Set the click action for the banner:
RtbStackSDK.SetBannerClickThroughAction("TAG_ID", RtbStackSDK.ClickThroughAction.OPEN_DEVICE_BROWSER);
The available click actions are:
OPEN_SDK_BROWSER
OPEN_DEVICE_BROWSER
RETURN_URL
You can enable or disable auto-refresh for the banner:
// Enable auto-refresh
RtbStackSDK.SetBannerAutoRefreshEnabled("TAG_ID", true);
// Disable auto-refresh
RtbStackSDK.SetBannerAutoRefreshEnabled("TAG_ID", false);
SetBannerAutoRefreshEnabled
before the LoadBanner
method. If you call SetBannerAutoRefreshEnabled
after LoadBanner
, it will cause an additional ad request.