rememberRewardedInterstitialAd

fun rememberRewardedInterstitialAd(activity: Any?, adUnitId: String = AdUnitId.REWARDED_INTERSTITIAL_DEFAULT, onLoad: () -> Unit = {}, onFailure: (Exception) -> Unit = {}): MutableState<RewardedInterstitialAdHandler>

A composable function that remembers and manages a RewardedInterstitialAdHandler.

This function handles the lifecycle of a rewarded interstitial ad, including loading and reloading it when it's dismissed or hasn't been loaded yet.

Return

A MutableState holding the RewardedInterstitialAdHandler. This allows you to interact with the ad (e.g., to show it) and observe its state.

Parameters

activity

The current activity context. This is crucial for initializing and displaying the ad. It can be null, but ads will not function correctly if it is.

adUnitId

The ad unit ID for the rewarded interstitial ad. Defaults to AdUnitId.REWARDED_INTERSTITIAL_DEFAULT.

onLoad

A callback function that is invoked when the ad has successfully loaded.

onFailure

A callback function that is invoked if the ad fails to load. It provides an Exception object containing details about the failure.

See also