Banner Cache

Integrate banner cache

Note

Banner cache is currently only available on the 3.3-beta-release branch.

Create Banner Cache

To create banner cache, call createBannerCache method:

_aatKitBinding.createBannerCache()

You can change the cache configuration if needed. Please modify corresponding variables or pass more parameters to the constructor of BannerCacheConfiguration (Android) orAATBannerCacheConfiguration (iOS):

AATKitBinding.kt
    //Change banner cache configuration if needed
    private val bannerCachePlacementName = "bannerCachePlacement"
    private val bannerCacheSize = 2
    
    ...
    
    private fun createBannerCache() {
        //Set more parameters of BannerCacheConfiguration if needed
        val configuration = BannerCacheConfiguration(bannerCachePlacementName, bannerCacheSize)
        configuration.delegate = bannerCacheListener
        bannerCache = AATKit.createBannerCache(configuration)
    }
AATKitBinding.swift
    //Change banner cache parameters if needed
    private let bannerCachePlacementName = "bannerCachePlacement"
    private let bannerCacheSize = 2
    
    ...
    
    
    private func createBannerCache() {
        //Set more parameters of AATBannerCacheConfiguration if needed
        let configuration = AATBannerCacheConfiguration(placementName: bannerCachePlacementName, size: bannerCacheSize)
        configuration.delegate = bannerCacheDelegate
        Self.bannerCache = AATSDK.createBannerCache(configuration: configuration)
    }

Consume Banners

Next banner is consumed automatically when adding AATKitBanner widget with passed type parameter as AATKitBannerType.cached:

AATKitBanner(
  type: AATKitBannerType.cached,
)

Destroy old banner

Banner is destroyed automatically when AATKitBanner widget is no longer attached to the UI.

Destroy no longer needed BannerCache

For proper memory management, BannerCache needs to be destroyed when is no longer needed. The destroyBannerCache method destroys the BannerCache:

_aatKitBinding.destroyBannerCache();

Code Example

Please see list_page.dart to check how banner cache is integrated within ListView widget. Please note our example app requires to call creating banner cache manually by pressing the Create banner cache button from the home_page.dart.

Last updated