Banner Cache
Integrate banner cache
Last updated
Integrate banner cache
Last updated
The banner cache is a special tool to help you integrate infeed banners more easily. It will wrap an infeed banner and use it to automatically preload banner ads aiming to have a defined amount of banners available for an immediate handout to the app whenever they are needed. Compared to using the directly, it comes with the following
Pros
Automatically caches banner ads, so your app can consume and present them whenever needed (i.e. when the dedicated feed cell enters the visible area of the screen)
Automatically takes care of correct ad space counting (it counts an ad space whenever you try to consume an ad because we assume, you only consume an ad when you need to present it right now).
Cons
You cannot specify specific configurations for the ad request (like e.g. keyword targeting X for the first ad request and keyword targeting Y for the next one and so on) and control the load cycle of a specific ad.
can be configured with the following:
placementName
defines the name of the internally wrapped placement (e.g. important for the statistics on the Dashboard).
size
defines how many preloaded banners should be available in the cache. Max value: 5.
delegate
an instance of that will notify you when the first banner is loaded and ready to be consumed.
requestConfiguration
an instance of that will be used internally for requesting banner ads from the InfeedBannerPlacement
.
retryInterval
represents the retry interval (in seconds) for failed ad load requests.
minimumDelay
represents the minimum delay between two banner consumptions in seconds. Useful to prevent consuming too many ads when the user is fast scrolling. Default: 1 s.
shouldCacheAdditionalAdAtStart
defines if the cache should load an additional ad at the beginning. false
by default.
Configure Banner Request
To consume banners, use the consume
method. It returns an instance of BannerPlacementLayout to be used within the app. Can return null if there are no banners available in the cache. Also automatically counts an ad space. BannerCache will no longer hold any references to returned banners, and they need to be destroyed manually by the app.
When you no longer need a banner, you have to destroy it manually by removing it from your view and calling the "destroy" method:
For proper memory management, BannerCache needs to be destroyed when is no longer needed. The destroy()
method destroys the BannerCache, clearing all preloaded banner ads and canceling pending reload requests. Destroyed BannerCache can no longer be used.
See the for infeed banner placement.
If the force
parameter is true, the minDelay
parameter of the instance will be ignored.
To listen to the banner cache status, implement the