NativeAd

abstract class NativeAd


A Google native ad.

Summary

Nested types

abstract class NativeAd.AdChoicesInfo

Attribution information.

abstract class NativeAd.Image

A native ad image asset.

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

A listener interface apps can use to receive unconfirmed click events when using the Confirmed Click feature.

Public constructors

Public functions

abstract Unit

Cancels an unconfirmed click that was previously recorded for the ad.

abstract Unit

Destroys the ad object.

abstract Unit

This function is deprecated.

Use enableCustomClickGestureDirection.

abstract NativeAd.AdChoicesInfo?

Returns the information for the AdChoices attribution.

abstract String?

Returns text that identifies the advertiser.

abstract String?

Returns body text.

abstract String?

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

abstract Bundle!

Returns a bundle of extra assets associated with the native ad.

abstract String?

Returns the primary text headline.

abstract NativeAd.Image?

Returns a small image identifying the advertiser.

abstract (Mutable)List<NativeAd.Image!>!

Returns a list of large images.

abstract MediaContent?

Returns the MediaContent associated with this ad.

abstract (Mutable)List<MuteThisAdReason!>!

Returns Mute This Ad reasons available for this ad.

abstract String?

For ads about apps, returns a string representing how much the app costs.

abstract ResponseInfo?

Returns the ResponseInfo object for the loaded ad.

abstract Double?

For ads about apps, returns a star rating from 0 to 5 representing how many stars the app has in the store offering it.

abstract String?

For ads about apps, returns the name of the store offering the app for download.

abstract Boolean

This function is deprecated.

When loading an ad using enableCustomClickGestureDirection, all ads returned will support custom click gesture.

abstract Boolean

Returns true if this ad can be muted programmatically.

abstract Unit
muteThisAd(muteThisAdReason: MuteThisAdReason!)

Mutes This Ad programmatically.

abstract Unit
performClick(clickData: Bundle!)

Should be called when the user has clicked on the ad.

abstract Unit

This function is deprecated.

The Google Mobile Ads SDK now tracks custom click gestures using the click gesture direction requested in enableCustomClickGestureDirection.

abstract Boolean
recordImpression(impressionData: Bundle!)

Should be called when the ad is first displayed.

abstract Unit
reportTouchEvent(touchEventData: Bundle!)

Should be called when a touch event happens on the ad.

abstract Unit

Sets the MuteThisAdListener for the ad.

abstract Unit

Register a callback to be invoked when this ad is estimated to have earned money.

abstract Unit

Sets the UnconfirmedClickListener for the ad.

Public constructors

NativeAd

NativeAd()

Public functions

cancelUnconfirmedClick

abstract fun cancelUnconfirmedClick(): Unit

Cancels an unconfirmed click that was previously recorded for the ad.

destroy

abstract fun destroy(): Unit

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

enableCustomClickGesture

abstract fun enableCustomClickGesture(): Unit

Enables publishers reporting clicks using custom gestures for this NativeAd. The ad unit must be allowlisted to be able to use this method.

By default SDK tracks clicks on asset views. If this method is called, SDK will no longer track clicks for this NativeAd. It should be called before showing the ad.

getAdChoicesInfo

abstract fun getAdChoicesInfo(): NativeAd.AdChoicesInfo?

Returns the information for the AdChoices attribution.

getAdvertiser

abstract fun getAdvertiser(): String?

Returns text that identifies the advertiser. Apps are not required to display this asset, though it's recommended.

getBody

abstract fun getBody(): String?

Returns body text. Apps are required to display this asset.

getCallToAction

abstract fun getCallToAction(): String?

Returns the ad's call to action (such as "Buy" or "Install"). Apps are not required to display this asset, though it's recommended.

getExtras

abstract fun getExtras(): Bundle!

Returns a bundle of extra assets associated with the native ad. If a mediation partner's ad have assets besides the standard ones (price, store, etc.), they can be set by calling the method in setExtras, and can be retrieved via this method. For non-mediation flow, it returns an empty bundle.

getHeadline

abstract fun getHeadline(): String?

Returns the primary text headline. Apps are required to display this asset.

getIcon

abstract fun getIcon(): NativeAd.Image?

Returns a small image identifying the advertiser. Apps are not required to display this asset, though it's recommended.

getImages

abstract fun getImages(): (Mutable)List<NativeAd.Image!>!

Returns a list of large images. Apps are not required to display this asset, though it's recommended.

getMediaContent

abstract fun getMediaContent(): MediaContent?

Returns the MediaContent associated with this ad.

getMuteThisAdReasons

abstract fun getMuteThisAdReasons(): (Mutable)List<MuteThisAdReason!>!

Returns Mute This Ad reasons available for this ad. Use the text description from class for showing to user.

getPrice

abstract fun getPrice(): String?

For ads about apps, returns a string representing how much the app costs. Apps are not required to display this asset, though it's recommended.

getResponseInfo

abstract fun getResponseInfo(): ResponseInfo?

Returns the ResponseInfo object for the loaded ad. Returns null until the ad successfully loads.

getStarRating

abstract fun getStarRating(): Double?

For ads about apps, returns a star rating from 0 to 5 representing how many stars the app has in the store offering it. Apps are not required to display this asset, though it's recommended.

getStore

abstract fun getStore(): String?

For ads about apps, returns the name of the store offering the app for download. For example, "Google Play". Apps are not required to display this asset, though it's recommended.

isCustomClickGestureEnabled

abstract fun isCustomClickGestureEnabled(): Boolean

Indicates whether clicks can be reported using custom click gestures. Reach out to your account manager to allowlist your ad unit for this feature.

isCustomMuteThisAdEnabled

abstract fun isCustomMuteThisAdEnabled(): Boolean

Returns true if this ad can be muted programmatically. Use setRequestCustomMuteThisAd to request custom implementation of Mute This Ad.

muteThisAd

abstract fun muteThisAd(muteThisAdReason: MuteThisAdReason!): Unit

Mutes This Ad programmatically.

Parameters
muteThisAdReason: MuteThisAdReason!

The mute reason selected by the user. Get mute reasons from getMuteThisAdReasons. Use null to Mute This Ad with default reason.

performClick

abstract fun performClick(clickData: Bundle!): Unit

Should be called when the user has clicked on the ad. The ad unit must be allowlisted to be able to use this api. This method should only be used by Unity plugin publishers.

Parameters
clickData: Bundle!

bundle of the app environment when the click happens. For details to construct the click data Bundle, see NativeAdConstants.

recordCustomClickGesture

abstract fun recordCustomClickGesture(): Unit

Reports clicks for this NativeAd using custom click gesture. The ad unit must be allowlisted to be able to use this method.

enableCustomClickGesture must be called before calling this method.

recordImpression

abstract fun recordImpression(impressionData: Bundle!): Boolean

Should be called when the ad is first displayed. The ad unit must be allowlisted to be able to use this api.

Parameters
impressionData: Bundle!

bundle of the app environment when the impression happens. For details to construct the click data Bundle, see NativeAdConstants.

Returns
Boolean

true if the impression is recorded successfully

reportTouchEvent

abstract fun reportTouchEvent(touchEventData: Bundle!): Unit

Should be called when a touch event happens on the ad. The ad unit must be allowlisted to be able to use this api. If you are interested in using this feature, reach out to your account manager.

Parameters
touchEventData: Bundle!

bundle of touch event coordinates and duration.

Example JSON representation of touchEventData Bundle:

  {    "x": "100",  // The x-coordinate of the touch event relative to the window.    "y": "50",  // The y-coordinate of the touch event relative to the window.    "duration_millis": "500",  // The amount of milliseconds the user pressed on the asset.  }

setMuteThisAdListener

abstract fun setMuteThisAdListener(listener: MuteThisAdListener!): Unit

Sets the MuteThisAdListener for the ad.

setOnPaidEventListener

abstract fun setOnPaidEventListener(listener: OnPaidEventListener?): Unit

Register a callback to be invoked when this ad is estimated to have earned money.

setUnconfirmedClickListener

abstract fun setUnconfirmedClickListener(
    listener: NativeAd.UnconfirmedClickListener!
): Unit

Sets the UnconfirmedClickListener for the ad.