RewardedAd

interface RewardedAd : Ad


A full screen ad that provides the user the opportunity to opt-in to watching a video or engaging with a playable ad in exchange for a reward within the app.

Summary

Public companion functions

suspend AdLoadResult<RewardedAd>
load(adRequest: AdRequest)

Loads a RewardedAd, suspending until a RewardedAd successfully loads or fails to load.

Unit
load(adRequest: AdRequest, adLoadCallback: AdLoadCallback<RewardedAd>)

Loads a RewardedAd, providing the result via adLoadCallback.

Unit
loadFromAdResponse(
    adResponse: String,
    adLoadCallback: AdLoadCallback<RewardedAd>
)

Loads a RewardedAd, providing the result via adLoadCallback.

Public functions

Bundle

Gets all available ad metadata for this RewardedAd.

RewardItem

Gets the RewardItem for the loaded rewarded ad.

Unit
setImmersiveMode(immersiveModeEnabled: Boolean)

Sets a flag that controls if this rewarded object will be displayed in immersive mode.

Unit

Sets ServerSideVerificationOptions for this RewardedAd.

Unit
show(
    activity: Activity,
    onUserEarnedRewardListener: OnUserEarnedRewardListener
)

Shows the rewarded ad.

Public properties

RewardedAdEventCallback?

Optional callback for ad events during the lifecycle of this RewardedAd.

Inherited functions

From com.google.android.libraries.ads.mobile.sdk.common.Ad
Unit

Destroys the ad, stopping any extra processing and destroying resources associated with the ad.

ResponseInfo

Gets information about the ad response for this ad.

Inherited properties

From com.google.android.libraries.ads.mobile.sdk.common.Ad
Long

An identifier for a placement in reporting.

Public companion functions

load

suspend fun load(adRequest: AdRequest): AdLoadResult<RewardedAd>

Loads a RewardedAd, suspending until a RewardedAd successfully loads or fails to load.

Parameters
adRequest: AdRequest

An AdRequest with targeting information.

Returns
AdLoadResult<RewardedAd>

AdLoadResult.Success if the load succeeded, AdLoadResult.Failure otherwise.

load

fun load(adRequest: AdRequest, adLoadCallback: AdLoadCallback<RewardedAd>): Unit

Loads a RewardedAd, providing the result via adLoadCallback.

Parameters
adRequest: AdRequest

An ad request with targeting information.

adLoadCallback: AdLoadCallback<RewardedAd>

A callback to be invoked when a rewarded ad finishes loading.

loadFromAdResponse

fun loadFromAdResponse(
    adResponse: String,
    adLoadCallback: AdLoadCallback<RewardedAd>
): Unit

Loads a RewardedAd, providing the result via adLoadCallback.

Parameters
adResponse: String

An ad response from a server-to-server ad request.

adLoadCallback: AdLoadCallback<RewardedAd>

A callback to be invoked when loading completes.

Public functions

getAdMetadata

fun getAdMetadata(): Bundle

Gets all available ad metadata for this RewardedAd. Ad metadata is empty if the loaded ad doesn't have metadata. Ad metadata may update after loading. Use RewardedAdEventCallback.onAdMetadataChanged to listen for changes:

ad.adEventCallback = object : RewardedAdEventCallback {
override fun onAdMetadataChanged() {
val metadata = ad.getAdMetadata()
}
}

getRewardItem

fun getRewardItem(): RewardItem

Gets the RewardItem for the loaded rewarded ad.

setImmersiveMode

fun setImmersiveMode(immersiveModeEnabled: Boolean): Unit

Sets a flag that controls if this rewarded object will be displayed in immersive mode. Call this method before RewardedAd.show. During RewardedAd.show, if this flag is on and immersive mode is supported, the rewarded ad will turn on the SYSTEM_UI_FLAG_IMMERSIVE_STICKY & SYSTEM_UI_FLAG_HIDE_NAVIGATION flags.

setServerSideVerificationOptions

fun setServerSideVerificationOptions(
    options: ServerSideVerificationOptions
): Unit

Sets ServerSideVerificationOptions for this RewardedAd.

show

fun show(
    activity: Activity,
    onUserEarnedRewardListener: OnUserEarnedRewardListener
): Unit

Shows the rewarded ad.

Parameters
activity: Activity

An Activity context from which to present the ad.

onUserEarnedRewardListener: OnUserEarnedRewardListener

The listener to be notified when user earns a reward.

Public properties

adEventCallback

var adEventCallbackRewardedAdEventCallback?

Optional callback for ad events during the lifecycle of this RewardedAd.