rememberInterstitialAd

fun rememberInterstitialAd(activity: Any?, adUnitId: String = AdUnitId.INTERSTITIAL_DEFAULT, onLoad: () -> Unit = {}, onFailure: (Exception) -> Unit = {}): MutableState<InterstitialAdHandler>

Composable function to remember an interstitial ad.

This function creates and manages an InterstitialAdHandler instance, automatically loading an ad when the state is AdState.DISMISSED or AdState.NONE.

Return

A MutableState holding the InterstitialAdHandler. You can use this to control and observe the ad's state (e.g., to show the ad).

Parameters

activity

The activity context, required for ad loading.

adUnitId

The ad unit ID for the interstitial ad. Defaults to AdUnitId.INTERSTITIAL_DEFAULT.

onLoad

A callback function invoked when the ad is successfully loaded.

onFailure

A callback function invoked when ad loading fails, providing the Exception that occurred.