NativeCustomFormatAd

interface NativeCustomFormatAd


An Ad Manager custom native ad format. Custom (user-defined) native ad formats allow you to define your own variables for traditional native ads. Custom native ad formats let you define and render your own assets, and allows you to define the click behavior of the ad.

Summary

Nested types

An interface for open measurement in display ads.

Interface definition for a callback to be invoked when a user clicks on a custom native ad format.

Interface definition for a callback to be invoked when a custom native ad format has successfully loaded.

Constants

const String!
ASSET_NAME_VIDEO = "_videoMediaView"

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

Public functions

Unit

Destroys the ad object.

(Mutable)List<String!>?

Returns a list of all available assets.

String?

Returns the custom native ad format's ID as defined in the Ad Manager UI.

NativeCustomFormatAd.DisplayOpenMeasurement!

Returns the DisplayOpenMeasurement associated with this ad.

NativeAd.Image?
getImage(assetName: String!)

Returns an image asset.

MediaContent?

Returns the MediaContent associated with this ad.

CharSequence?
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.

Constants

ASSET_NAME_VIDEO

const val ASSET_NAME_VIDEO = "_videoMediaView": String!

The asset name associated with the video content returned by getMediaContent. This is the asset name that will be reported in onCustomClick when the user clicks on the MediaView containing with the video content returned by getMediaContent.

Public functions

destroy

fun destroy(): Unit

Destroys the ad object. No other methods should be called on the ad object after destroy is called.

getAvailableAssetNames

fun getAvailableAssetNames(): (Mutable)List<String!>?

Returns a list of all available assets.

Returns
(Mutable)List<String!>?

a list of all available assets, or an empty list if no asset is available.

getCustomFormatId

fun getCustomFormatId(): String?

Returns the custom native ad format's ID as defined in the Ad Manager UI.

getDisplayOpenMeasurement

fun getDisplayOpenMeasurement(): NativeCustomFormatAd.DisplayOpenMeasurement!

Returns the DisplayOpenMeasurement associated with this ad.

Returns
NativeCustomFormatAd.DisplayOpenMeasurement!

null if display open measurement is not available for this ad.

getImage

fun getImage(assetName: String!): NativeAd.Image?

Returns an image asset.

Parameters
assetName: String!

The name of the asset to be retrieved.

Returns
NativeAd.Image?

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

getMediaContent

fun getMediaContent(): MediaContent?

Returns the MediaContent associated with this ad.

getText

fun getText(assetName: String!): CharSequence?

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
CharSequence?

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.