UnifiedNativeAdMapper

abstract class UnifiedNativeAdMapper


Maps a third party native ad to a Google native ad.

Mediation adapters that load a native ad must extend this class to provide a mapping from the mediated ad network's native ad object to com.google.android.gms.ads.formats.UnifiedNativeAd.

Summary

Public constructors

UnifiedNativeAdMapper(
    headline: String?,
    images: List<NativeAd.Image>?,
    body: String?,
    icon: NativeAd.Image?,
    callToAction: String?,
    advertiser: String?,
    starRating: Double?,
    store: String?,
    price: String?,
    videoController: VideoController?,
    hasVideoContent: Boolean,
    attributionInfo: NativeAd.AdChoicesInfo?,
    adChoicesContent: View?,
    mediaView: View?,
    mediatedAd: Any?,
    extras: Bundle,
    overrideImpressionRecording: Boolean,
    overrideClickHandling: Boolean,
    mediaContentAspectRatio: Float
)

Public functions

open Unit

Subclasses should implement this method if the ad network offers a way to destroy the native ad object.

open Unit

Subclasses should implement this method if overrideClickHandling is false.

open Unit

Subclasses should implement this method if overrideImpressionRecording is false.

open Unit
trackViews(
    containerView: View?,
    clickableAssetViews: Map<StringView>,
    nonclickableAssetViews: Map<StringView>
)

Subclasses should implement this method if the ad network requires access to the native ad asset views, for example to handle impression and click tracking.

open Unit
untrackView(view: View?)

Subclasses should implement this method if the ad network offers a way to stop tracking a native ad view for the ad mapped by this object.

Public properties

View?

A view to be used as AdChoices content.

String?

A text that identifies the advertiser.

NativeAd.AdChoicesInfo?
String?

The body text asset.

String?

The ad's call to action (such as "Buy" or "Install").

Bundle

A bundle of extras containing assets or attributes that do not directly map to those expected for a Google native ad object (headline, body, etc).

Boolean

The current ad has video content.

String?

The primary text headline.

NativeAd.Image?

A small image identifying the advertiser.

List<NativeAd.Image>?

A list of large images.

Float

The aspect ratio of the media to be rendered.

View?

mediated view that displays media.

Any?

The mediated native ad object.

Boolean

A boolean representing whether the ad network does click handling on its own.

Boolean

A boolean representing whether the ad network does impression tracking on its own.

String?

A string representing how much the app costs.

Double?

A star rating from 0 to 5 representing how many stars the app has in the store offering it.

String?

The name of the store offering the app for download.

VideoController?

Playback controller for native video ads.

Public constructors

UnifiedNativeAdMapper

UnifiedNativeAdMapper(
    headline: String? = null,
    images: List<NativeAd.Image>? = null,
    body: String? = null,
    icon: NativeAd.Image? = null,
    callToAction: String? = null,
    advertiser: String? = null,
    starRating: Double? = null,
    store: String? = null,
    price: String? = null,
    videoController: VideoController? = null,
    hasVideoContent: Boolean = false,
    attributionInfo: NativeAd.AdChoicesInfo? = null,
    adChoicesContent: View? = null,
    mediaView: View? = null,
    mediatedAd: Any? = null,
    extras: Bundle = Bundle(),
    overrideImpressionRecording: Boolean = false,
    overrideClickHandling: Boolean = false,
    mediaContentAspectRatio: Float = 0.0f
)

Public functions

destroy

open fun destroy(): Unit

Subclasses should implement this method if the ad network offers a way to destroy the native ad object.

handleClick

open fun handleClick(view: View): Unit

Subclasses should implement this method if overrideClickHandling is false.

recordImpression

open fun recordImpression(): Unit

Subclasses should implement this method if overrideImpressionRecording is false.

trackViews

open fun trackViews(
    containerView: View?,
    clickableAssetViews: Map<StringView>,
    nonclickableAssetViews: Map<StringView>
): Unit

Subclasses should implement this method if the ad network requires access to the native ad asset views, for example to handle impression and click tracking.

Parameters
containerView: View?

The container View for the ad.

clickableAssetViews: Map<StringView>

The Map of clickable asset names to corresponding View. Find the asset names in UnifiedNativeAdAssetNames.

nonclickableAssetViews: Map<StringView>

The Map of non-clickable asset names to corresponding View.Find the asset names in UnifiedNativeAdAssetNames.

untrackView

open fun untrackView(view: View?): Unit

Subclasses should implement this method if the ad network offers a way to stop tracking a native ad view for the ad mapped by this object.

Public properties

adChoicesContent

var adChoicesContentView?

A view to be used as AdChoices content.

advertiser

var advertiserString?

A text that identifies the advertiser.

attributionInfo

var attributionInfoNativeAd.AdChoicesInfo?

body

var bodyString?

The body text asset. Adapters should always map this asset since it is always included for Google ads.

callToAction

var callToActionString?

The ad's call to action (such as "Buy" or "Install"). Adapters should always map this asset since it is always included for Google ads.

extras

var extrasBundle

A bundle of extras containing assets or attributes that do not directly map to those expected for a Google native ad object (headline, body, etc).

hasVideoContent

var hasVideoContentBoolean

The current ad has video content.

headline

var headlineString?

The primary text headline. Adapters should always map this asset since it is always included for Google ads.

icon

var iconNativeAd.Image?

A small image identifying the advertiser.

images

var imagesList<NativeAd.Image>?

A list of large images. Adapters should always map this asset since it is always included for Google ads.

mediaContentAspectRatio

var mediaContentAspectRatioFloat

The aspect ratio of the media to be rendered.

mediaView

var mediaViewView?

mediated view that displays media. This is typically the View provided by the mediated SDK to display video content for an ad, but should display an image asset if no video is present. Adapters are expected to set a View for this property for every ad.

mediatedAd

var mediatedAdAny?

The mediated native ad object. Publishers have the option of accessing it directly to use APIs not fully mapped by the Mobile Ads SDK.

overrideClickHandling

var overrideClickHandlingBoolean

A boolean representing whether the ad network does click handling on its own.

overrideImpressionRecording

var overrideImpressionRecordingBoolean

A boolean representing whether the ad network does impression tracking on its own.

price

var priceString?

A string representing how much the app costs.

starRating

var starRatingDouble?

A star rating from 0 to 5 representing how many stars the app has in the store offering it.

store

var storeString?

The name of the store offering the app for download. For example, "Google Play".

videoController

var videoControllerVideoController?

Playback controller for native video ads.