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 display only one banner view on the screen.

Initialization

1. Import the namespaces:

using AppodealStack.Monetization.Api;
using AppodealStack.Monetization.Common;
2.  Add the following code within the  Start() method of your main scene’s MonoBehavior:  
Appodeal.Initialize("YOUR_APPODEAL_APP_KEY", AppodealAdType.Banner, this);
Initialization method requires 2 parameters:

  • appKey - appKey is generated when you add an application to Appodeal.
  • adType - Ad types can be combined using "|" operator. For example, AppodealAdType.Interstitial | AppodealAdType.Banner.

By default, auto caching is enabled: Appodeal SDK starts to load banner right away after the initialization method is called. The next banner ad starts to load after the previous one was shown.

Display

Banner ads are refreshed every 15 seconds automatically by default. To display banner, you need to call the following code:


Appodeal.Show(AppodealShowStyle.BannerBottom); // Display banner at the bottom of the screen
Appodeal.Show(AppodealShowStyle.BannerTop); // Display banner at the top of the screen
Appodeal.Show(AppodealShowStyle.BannerLeft); // Display banner at the left of the screen
Appodeal.Show(AppodealShowStyle.BannerRight); // Display banner at the right of the screen

Display Banner At Custom Position

Banner ad can be moved along the axis to the desired position.

To show Banner at Custom Position  use the following code:

Appodeal.ShowBannerView((int) yPosition, (int) xPosition, (string) placement);
For xPosition and yPosition use custom int value or constants:

  • AppodealViewPosition.HorizontalSmart — to use the full-screen width;
  • AppodealViewPosition.HorizontalCenter — to center a banner horizontally;
  • AppodealViewPosition.HotizontalRight — to align a banner to the right;
  • AppodealViewPosition.HorizontalLeft — to align a banner to the left;

For yPosition you can use custom int value or constants:

  • AppodealViewPosition.VerticalTop — to align a banner to the top of the screen;
  • AppodealViewPosition.VerticalBottom — to align a banner to the bottom of the screen.

The X coordinate (horizontal position) of the banner relative to the top left corner of the screen.

The Y coordinate (vertical position) of the banner relative to the top left corner of the screen.

To set your custom width and height, you can use the constants of The Unity’s Screen.width and Screen.height with a constant value.

To hide Banner that was shown at custom position useuse the following code:

Appodeal.HideBannerView();

Check If Ad Is Loaded

Appodeal.IsLoaded(AppodealAdType.Banner);

Hide Banner

Appodeal.Hide(AppodealAdType.Banner);

Destroy Hidden Banner

To free memory from hidden banner call the code below:


Appodeal.Destroy(AppodealAdType.Banner);

Placements

Appodeal SDK allows you to tag each impression with different placement. For using 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 like this in your activity:

Appodeal.Show(AppodealShowStyle.BannerTop, “placementName”);

If the loaded ad can’t be shown for a specific placement, nothing will be shown. 

You can configure your impression logic for each placement.

If you have no placements, or call  Appodeal.show  with placement that do not exist, the impression will be tagged with 'default' placement and its settings will be applied.

Important!

Placement settings affect ONLY ad presentation, not loading or caching.

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. To implement them, you need to follow below steps:

  1. Subscribe to the desired Banner event using one of the options from this guide. (you can subscribe to any event you want)
  2. You can use callbacks as shown below after:

public void YourMethod()
{
	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 flag shows loaded banner's height, precache flag 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


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.

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:


Appodeal.GetPredictedEcpm(AppodealAdType.Banner);

Advanced

Appodeal provides a number of settings that enable you to control the format of banner ads.

To enable 728*90 banner use the following method before initialization:

Appodeal.SetTabletBanners(true);

To disable banner refresh animation use the following method before initialization:

Appodeal.SetBannerAnimation(false);

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 :

Appodeal.SetSmartBanners(false);