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.
1. Initialize banner
1. Import the namespaces:2. Add the following code within the
Start()method of your main scene’s MonoBehavior: 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.
2. Display banner
Banner ads are refreshed every 15 seconds automatically by default. To display banner, you need to call the following code:
3. Display banner at custom position
Banner ad can be moved along the axis to the desired position.
Banner at Custom Position use the following code:
yPositionuse custom int value or constants:
AppodealViewPosition.HORIZONTAL_SMART— to use the full-screen width;
AppodealViewPosition.HORIZONTAL_CENTER— to center a banner horizontally;
AppodealViewPosition.HORIZONTAL_RIGHT— to align a banner to the right;
AppodealViewPosition.HORIZONTAL_LEFT— to align a banner to the left;
yPosition you can use custom int value or constants:
AppodealViewPosition.VERTICAL_TOP— to align a banner to the top of the screen;
AppodealViewPosition.VERTICAL_BOTTOM— to align a banner to the bottom of the screen.
To set your custom width and height, you can use the constants of The Unity’s
Screen.height with a constant value.
To hide Banner that was shown at custom position useuse the following code:
4. Check if banner is loaded
5. Hide banner
6. Destroy hidden banner
To free memory from hidden banner call the code below:
7. 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:
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.
Placement settings affect ONLY ad presentation, not loading or caching.
8. Banner 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 three steps:
1. Extend your class with
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.
9. 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:
10. Advanced banner integration
Appodeal provides a number of settings that enable you to control the format of banner ads.
10.1. Enable 728x90 banners
To enable 728*90 banner use the following method before initialization:
10.2. Disable banner refresh animation
To disable banner refresh animation use the following method before initialization:
10.3. 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 :