loadAndTrackNativeAd

fun loadAndTrackNativeAd(context: Context, adUnitId: String, adRequest: AdRequest, placement: String? = null, nativeAdOptions: NativeAdOptions? = null, adListener: AdListener? = null, onPaidEventListener: OnPaidEventListener? = null, onAdLoaded: (NativeAd) -> Unit = {}): AdLoader

Loads a native ad with automatic RevenueCat ad event tracking.

Creates an AdLoader, wires up tracking for loaded, failed-to-load, impression, click, and revenue events, then starts loading.

The onAdLoaded lambda delivers the NativeAd instance — this is native-ad-specific and not part of AdListener, so it is kept as a lambda. All other lifecycle events are received through the optional adListener.

Return

The AdLoader instance. Retain this if you need to load more ads.

Parameters

context

The context.

adUnitId

The AdMob ad unit ID.

adRequest

The AdRequest to use.

placement

A placement identifier for RevenueCat tracking.

nativeAdOptions

Optional NativeAdOptions to configure the native ad request.

adListener

Optional AdListener to receive ad lifecycle events. RevenueCat tracking for impression, click, and failed-to-load is injected transparently before each delegate call.

onPaidEventListener

Optional OnPaidEventListener to receive paid events. RevenueCat revenue tracking is called first, then forwarded to this listener.

onAdLoaded

Called with the loaded NativeAd (already tracked).