Banner ads are classic static banners, usually located at the bottom or top of the screen. Appodeal supports traditional 320x50 banners, 728x90 tablet banners and smart banners that adjust to the size and orientation of the device.
1. Manual caching
By default, auto caching is enabled: Appodeal SDK starts to load Banner right after the initialization method is called. The next banner ad starts to load after the previous one has been shown.
To disable automatic caching for banners, use the code below before SDK initialization:
2. Checking if banner has been loaded
You can check if the ad has been loaded before showing it. This method returns a boolean value indicating whether or not the banner has been loaded.
3. Displaying banner at the bottom of the screen
Banner is a singleton now, if you are using
bannerBottom on different controllers, the SDK will use the same banner instance.
Banner ads are refreshed every 15 seconds automatically by default. To display a banner, you need to call the following code:
4. Displaying banner at the top of the screen
5. Displaying banner at the left or right corner of the screen
If your app uses landscape interface orientation you can show Appodeal Banner at the left or right corner. The banner will have the offset according to the safe area layout guide.
Disable banner smart sizing if you use AppodealShowStyleBannerLeft or AppodealShowStyleBannerRight
6. Displaying banner in programmatically created view
You can also add the Appodeal banner to your view hierarchy manually.
BannerViewmust be on the top of the hierarchy and mustn't be overlapped by other views.
7. Using banner callbacks
Callbacks are used to track different lifecycle events of an ad, e.g., when a banner has successfully loaded or is about to appear. To get them, you need to set the delegate as follows:
Now you can use the following callback methods:
If automatic caching is ON for the Banner ad type, do not show banner in the
bannerDidLoadAdIsPrecache callback. The banner will be refreshed automatically after the first show.
8. Hiding banner
To remove banner from your view hierarchy:
9. Banner placements
Appodeal SDK allows you to tag each impression with different placement. To be able to use placements, you need to create them in Appodeal Dashboard. Read more about placements.
If you have no placements or call Appodeal.show with a placement that does not exist, the impression will be tagged with 'default' placement with corresponding settings applied.
Placement settings affect ONLY ad presentation, not loading or caching.
10. Advanced banner integration
Advanced BannerView integration
If basic integration is not appropriate for you due to the complex views hierarchy of your app, you can use
AppodealBannerView UIView subclass to integrate banners.
11. Enabling smart banners
Smart banners are banner ads which automatically fit the screen/container size. Using them helps to deal with increasing fragmentation of the screen sizes on different devices. To enable them, use the following method:
12. Changing banner background
This method allows to create a grey background for banner ads:
13. Enabling banner refresh animation
14. Getting predicted eCPM
This method returns the expected eCPM for the cached ad. The amount is calculated based on historical data for the current ad unit.
15. Checking if banner has been initialized
true if banner was initialized.
16. Checking if autocache is enabled for banner
true if autocache is enabled for banner.