CustomNativeAd

interface CustomNativeAd : Ad


Custom (user-defined) native ad formats allow you to create your own native ad formats by defining custom lists of assets and the click behavior of the ad.

This feature is available to Ad Manager publishers only.

Summary

Constants

const String

The asset name associated with the video content returned by mediaContent.

Public functions

DisplayOpenMeasurement?

Gets the DisplayOpenMeasurement associated with this ad.

Image?
getImage(assetName: String)

Returns an image asset.

String?
getText(assetName: String)

Returns a string asset of numbers, URLs, or other types other than an image asset.

Unit
performClick(assetName: String)

Performs a click on the ad, executing its clickthrough behavior.

Unit

Records an impression.

Public properties

NativeAdEventCallback?

Callback for receiving custom native ad lifecycle events.

Set<String>

A set of all available assets, or an empty set if no asset is available.

String?

The custom native ad format IDs defined in the Ad Manager UI.

MediaContent?

The MediaContent associated with this ad.

OnCustomClickListener?

An optional listener to override a custom native ad's click logic.

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.

Constants

ASSET_NAME_VIDEO

const val ASSET_NAME_VIDEOString

The asset name associated with the video content returned by mediaContent.

This is the asset name reported in CustomNativeAdEventCallback.onCustomClick when the user clicks on the MediaView containing video content returned by mediaContent.

Public functions

getDisplayOpenMeasurement

fun getDisplayOpenMeasurement(): DisplayOpenMeasurement?

Gets the DisplayOpenMeasurement associated with this ad. Returns null if the custom native ad contains a video asset or does not have Open Measurement enabled.

getImage

fun getImage(assetName: String): Image?

Returns an image asset.

Parameters
assetName: String

The name of the asset to be retrieved.

Returns
Image?

the value of the asset with the asset name, or null if there's no such asset name.

getText

fun getText(assetName: String): String?

Returns a string asset of numbers, URLs, or other types other than an image asset.

Parameters
assetName: String

The name of the asset to be retrieved.

Returns
String?

the value of the asset with the asset name, or null if there's no such asset name.

performClick

fun performClick(assetName: String): Unit

Performs a click on the ad, executing its clickthrough behavior.

Parameters
assetName: String

The name of the asset that was clicked.

recordImpression

fun recordImpression(): Unit

Records an impression. Call this method when the ad is first shown to the user.

Public properties

adEventCallback

var adEventCallbackNativeAdEventCallback?

Callback for receiving custom native ad lifecycle events.

assetNameSet

val assetNameSetSet<String>

A set of all available assets, or an empty set if no asset is available.

This set includes ASSET_NAME_VIDEO if populated.

customFormatId

val customFormatIdString?

The custom native ad format IDs defined in the Ad Manager UI.

mediaContent

val mediaContentMediaContent?

The MediaContent associated with this ad.

onCustomClickListener

var onCustomClickListenerOnCustomClickListener?

An optional listener to override a custom native ad's click logic. When set, calls to performClick trigger OnCustomClickListener.onCustomClick instead of navigating to the click URL defined in the Ad Manager UI.