Banner
Banner ads are classic static banners, which are usually located at the bottom or top of the screen.
Appodeal supports traditional 320x50 banners, tablet 728x90 ones, and adaptive banners (for Admob only) that adjust to the size and orientation of the device.
You can use our demo app as a reference project.
Demo App
Fixed Positioned Banner
Display
Banner ads are refreshed every 15 seconds automatically by default. To display banner, you need to call one of the following methods:
- UPM Distribution
- Manual Distribution
// Display banner at the bottom of the screen
Appodeal.Show(AppodealShowStyle.BannerBottom);
// Display banner at the top of the screen
Appodeal.Show(AppodealShowStyle.BannerTop);
// Display banner at the left of the screen
Appodeal.Show(AppodealShowStyle.BannerLeft);
// Display banner at the right of the screen
Appodeal.Show(AppodealShowStyle.BannerRight);
// Display banner at the bottom of the screen
Appodeal.show(Appodeal.BANNER_BOTTOM);
// Display banner at the top of the screen
Appodeal.show(Appodeal.BANNER_TOP);
// Display banner at the left of the screen
Appodeal.show(Appodeal.BANNER_LEFT);
// Display banner at the right of the screen
Appodeal.show(Appodeal.BANNER_RIGHT);
Hide Banner
To hide a banner that was shown via Appodeal.Show()
method use the following method:
- UPM Distribution
- Manual Distribution
Appodeal.Hide(AppodealAdType.Banner);
Appodeal.hide(Appodeal.BANNER);
Check If Ad Is Loaded
You can check whether or not an ad is loaded at a certain moment. This method returns a boolean value, representing the banner ad loading status.
- UPM Distribution
- Manual Distribution
Appodeal.IsLoaded(AppodealAdType.Banner);
Appodeal.isLoaded(Appodeal.BANNER);
The Appodeal.Show()
method for banners can be called at any moment. If there is no ad available,
we will cache one and show it right away.
Callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. Follow the steps below to implement them:
- UPM Distribution
- Manual Distribution
Subscribe to the desired banner event using one of the options from this guide. (you can subscribe to any number of events you want)
AppodealCallbacks.Banner.OnLoaded += (sender, args) => { };
You will find all existing banner events in the example below:
public void SomeMethod()
{
AppodealCallbacks.Banner.OnLoaded += OnBannerLoaded;
AppodealCallbacks.Banner.OnFailedToLoad += OnBannerFailedToLoad;
AppodealCallbacks.Banner.OnShown += OnBannerShown;
AppodealCallbacks.Banner.OnShowFailed += OnBannerShowFailed;
AppodealCallbacks.Banner.OnClicked += OnBannerClicked;
AppodealCallbacks.Banner.OnExpired += OnBannerExpired;
}
#region BannerAd Callbacks
// Called when a banner is loaded (height arg shows banner's height, precache arg shows if the loaded ad is precache
private void OnBannerLoaded(object sender, BannerLoadedEventArgs e)
{
Debug.Log("Banner loaded");
}
// Called when banner failed to load
private void OnBannerFailedToLoad(object sender, EventArgs e)
{
Debug.Log("Banner failed to load");
}
// Called when banner failed to show
private void OnBannerShowFailed(object sender, EventArgs e)
{
Debug.Log("Banner show failed");
}
// Called when banner is shown
private void OnBannerShown(object sender, EventArgs e)
{
Debug.Log("Banner shown");
}
// Called when banner is clicked
private void OnBannerClicked(object sender, EventArgs e)
{
Debug.Log("Banner clicked");
}
// Called when banner is expired and can not be shown
private void OnBannerExpired(object sender, EventArgs e)
{
Debug.Log("Banner expired");
}
#endregion
- Extend your class with
IBannerAdListener
interface:
class SomeClassName : IBannerAdListener {}
- Implement all required callback methods:
#region Banner callback handlers
// Called when a banner is loaded (height arg shows banner's height, precache arg shows if the loaded ad is precache
public void onBannerLoaded(int height, bool precache)
{
Debug.Log("Banner loaded");
}
// Called when banner failed to load
public void onBannerFailedToLoad()
{
Debug.Log("Banner failed to load");
}
// Called when banner is shown
public void onBannerShown()
{
Debug.Log("Banner shown");
}
// Called when banner failed to show
public void onBannerShowFailed()
{
Debug.Log("Banner show failed");
}
// Called when banner is clicked
public void onBannerClicked()
{
Debug.Log("Banner clicked");
}
// Called when banner is expired and can not be shown
public void onBannerExpired()
{
Debug.Log("Banner expired");
}
#endregion
- Call the following method:
Appodeal.setBannerCallbacks(this);
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.
Custom Positioned Banner
Displaying Banner At Custom Position
- UPM Distribution
- Manual Distribution
Banner ad can be moved along the axis to the desired position.
To show Banner at Custom Position use the following method:
Appodeal.ShowBannerView(yPosition, xPosition, "placementName");
Use int value or one of the constants below for yPosition
:
AppodealViewPosition.VerticalTop
— to align a banner to the top of the screen.AppodealViewPosition.VerticalBottom
— to align a banner to the bottom of the screen.
Use int value or one of the constants below for xPosition
:
AppodealViewPosition.HorizontalSmart
— to use the full-screen width.AppodealViewPosition.HorizontalCenter
— to center a banner horizontally.AppodealViewPosition.HorizontalRight
— to align a banner to the right.AppodealViewPosition.HorizontalLeft
— to align a banner to the left.
Banner ad can be moved along the axis to the desired position.
To show Banner at Custom Position use the following method:
Appodeal.showBannerView(yPosition, xPosition, "placementName");
Use int value or one of the constants below for yPosition
:
Appodeal.BANNER_TOP
— to align a banner to the top of the screen.Appodeal.BANNER_BOTTOM
— to align a banner to the bottom of the screen.
Use int value or one of the constants below for xPosition
:
Appodeal.BANNER_HORIZONTAL_SMART
— to use the full-screen width.Appodeal.BANNER_HORIZONTAL_CENTER
— to center a banner horizontally.Appodeal.BANNER_HORIZONTAL_RIGHT
— to align a banner to the right.Appodeal.BANNER_HORIZONTAL_LEFT
— to align a banner to the left.
Hide Banner
To hide a banner that was shown via Appodeal.ShowBannerView()
method use the following method:
- UPM Distribution
- Manual Distribution
Appodeal.HideBannerView();
Appodeal.hideBannerView();
Advanced
Placements
Appodeal SDK allows you to tag each impression with different placement. To use placements, you need to create placements in Appodeal Dashboard. Read more about placements.
To show an ad with placement, you have to call show method with specifying placement's name:
- UPM Distribution
- Manual Distribution
Appodeal.Show(AppodealShowStyle.BannerTop, "placementName");
Appodeal.show(Appodeal.BANNER_TOP, "placementName");
Destroy Hidden Banner
To free memory from hidden banner call the code below:
- UPM Distribution
- Manual Distribution
Appodeal.Destroy(AppodealAdType.Banner);
Appodeal.destroy(Appodeal.BANNER);
Get Predicted eCPM
This method returns expected eCPM for a currently cached advertisement. The amount is calculated based on historical data for the current ad unit.
- UPM Distribution
- Manual Distribution
Appodeal.GetPredictedEcpm(AppodealAdType.Banner);
Appodeal.getPredictedEcpm(Appodeal.BANNER);
Enable 728x90 Banners
To enable 728*90 banner use the following method before initialization:
- UPM Distribution
- Manual Distribution
Appodeal.SetTabletBanners(true);
Appodeal.setTabletBanners(true);
Disable Banner Refresh Animation
To disable banner refresh animation use the following method before initialization:
- UPM Distribution
- Manual Distribution
Appodeal.SetBannerAnimation(false);
Appodeal.setBannerAnimation(false);
Smart Banners
Smart banners are the banner ads which automatically fit the screen size. Using them helps to deal with the increasing fragmentation of the screen sizes on different devices. In the Appodeal SDK the smart banners are enabled by default. To disable them, use the following method before initialization:
- UPM Distribution
- Manual Distribution
Appodeal.SetSmartBanners(false);
Appodeal.setSmartBanners(false);