ProgrammaticNativeAdCompose
fun ProgrammaticNativeAdCompose(adUnitId: String, size: ProgrammaticNativeAdLoader.NativeAdSize = ProgrammaticNativeAdLoader.NativeAdSize.SMALL, modifier: Modifier = Modifier, useCachedAd: Boolean = true, showLoadingIndicator: Boolean = true, onAdLoaded: (NativeAdView, NativeAd) -> Unit? = null, onAdFailedToLoad: (AdError) -> Unit? = null, onAdClicked: () -> Unit? = null, onAdImpression: () -> Unit? = null, onAdOpened: () -> Unit? = null, onAdClosed: () -> Unit? = null, onPaidEvent: (AdValue) -> Unit? = null)
A Jetpack Compose component for programmatically loaded native ads.
This composable uses the ProgrammaticNativeAdLoader to load native ads without requiring predefined views in layouts, providing a more flexible and Compose-friendly approach to native ad integration.
Since
2.1.0
Parameters
adUnitId
The AdMob ad unit ID
size
The size of the native ad
modifier
Modifier for styling the ad container
useCachedAd
Whether to use cached ads if available
showLoadingIndicator
Whether to show a loading indicator while the ad loads
onAdLoaded
Callback when the ad loads successfully
onAdFailedToLoad
Callback when the ad fails to load
onAdClicked
Callback when the ad is clicked
onAdImpression
Callback when the ad impression is recorded
onAdOpened
Callback when the ad opens an overlay
onAdClosed
Callback when the ad overlay is closed
onPaidEvent
Callback when a paid event occurs (for revenue tracking)