NativeAdPool

interface NativeAdPool(source)

Manages a pool of preloaded native ads for a single placement. Ads are acquired via acquire and must be returned via release. The composable NativeAdView handles acquire/release automatically. Use the pool directly for manual native ad rendering.

Properties

Link copied to clipboard
abstract val availableAds: StateFlow<Int>

Number of ads currently available for acquire, as a live signal.

Link copied to clipboard
abstract val events: SharedFlow<AdEvent>

Shared flow of native ad lifecycle events.

Link copied to clipboard
abstract val loadState: StateFlow<AdLoadState>

Current load state of the pool.

Link copied to clipboard
abstract val placement: AdPlacement

The placement this pool is bound to.

Functions

Link copied to clipboard
abstract fun acquire(): NativeAdToken?

Acquires a NativeAdToken from the pool, or null if none available. Every acquire must be paired with a release.

Link copied to clipboard
abstract fun availableCount(): Int

Returns the number of cached ads currently available for acquire.

Link copied to clipboard
abstract fun clear()

Clears all cached ads and resets the pool.

Link copied to clipboard
abstract fun mediaInfo(token: NativeAdToken): NativeMediaInfo?

Returns media info (aspect ratio, video duration) for the ad identified by token.

Link copied to clipboard
Link copied to clipboard
fun NativeAdPool.peekIosNativeAd(token: NativeAdToken): GADNativeAd?
Link copied to clipboard
abstract suspend fun preload(count: Int = placement.cachePolicy.maxSize, requestOptions: AdRequestOptions = placement.requestOptions, nativeOptions: NativeAdOptions = placement.nativeOptions): AdLoadState

Preloads count native ads.

Link copied to clipboard
abstract fun release(token: NativeAdToken)

Releases a previously acquired NativeAdToken. The underlying native ad is destroyed/discarded (native ads are single-use and not returned to the pool). Call when the rendering view is disposed.