NativeSignalRequest.Builder

class NativeSignalRequest.Builder


A builder class for creating NativeSignalRequest.

Summary

Public constructors

Builder(signalType: String)

Gets a Builder for NativeSignalRequest.

Public functions

NativeSignalRequest.Builder

Sets a slot-level ad category exclusion label.

NativeSignalRequest.Builder

Adds a keyword for targeting purposes.

NativeSignalRequest

Constructs a NativeSignalRequest with the specified attributes.

open NativeSignalRequest.Builder

Indicates whether downloading image assets should be disabled by the SDK when loading an ad.

open NativeSignalRequest.Builder
@CanIgnoreReturnValue
enableCustomClickGestureDirection(
    customClickGestureDirection: NativeAd.SwipeGestureDirection,
    customClickGestureAllowTaps: Boolean
)

Enables swipes as a custom click gesture.

NativeSignalRequest.Builder
@CanIgnoreReturnValue
putAdSourceExtrasBundle(
    adapterClass: Class<MediationExtrasReceiver>,
    adSourceExtras: Bundle
)

Adds extra parameters to pass to a specific ad source adapter.

NativeSignalRequest.Builder

Adds a custom targeting parameter.

NativeSignalRequest.Builder

Adds a custom targeting parameter with multiple values.

open NativeSignalRequest.Builder

Sets the placement of the AdChoices icon (if available for the returned ad).

open NativeSignalRequest.Builder

Sets the AdSize and overwrites any list of ad sizes passed in setAdSizes.

open NativeSignalRequest.Builder

Sets a list of valid AdSizes and overwrites the ad size passed in setAdSize with the first size in the list.

NativeSignalRequest.Builder

Sets the ad unit ID.

NativeSignalRequest.Builder

Sets the content URL for a web site whose content matches the app's primary content.

open NativeSignalRequest.Builder

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

NativeSignalRequest.Builder

Set extra parameters to pass to AdMob or Ad Manager.

open NativeSignalRequest.Builder

Indicates whether you intend to record impressions manually for the BannerAd.

open NativeSignalRequest.Builder

Sets the media aspect ratio.

NativeSignalRequest.Builder

Sets a list of native ad types to request.

NativeSignalRequest.Builder

Sets URLs representing web content near an ad.

NativeSignalRequest.Builder

Sets an identifier for use in frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.

NativeSignalRequest.Builder

Sets the request agent string to identify the ad request's origin.

open NativeSignalRequest.Builder

Sets the VideoOptions for this request.

Public constructors

Builder

Builder(signalType: String)

Gets a Builder for NativeSignalRequest.

Public functions

addCategoryExclusion

@CanIgnoreReturnValue
fun addCategoryExclusion(categoryExclusion: String): NativeSignalRequest.Builder

Sets a slot-level ad category exclusion label.

This feature is only applicable for Ad Manager ad requests. Any category exclusions will be ignored on AdMob requests.

addKeyword

@CanIgnoreReturnValue
fun addKeyword(keyword: String): NativeSignalRequest.Builder

Adds a keyword for targeting purposes.

build

fun build(): NativeSignalRequest

Constructs a NativeSignalRequest with the specified attributes.

disableImageDownloading

@CanIgnoreReturnValue
open fun disableImageDownloading(): NativeSignalRequest.Builder

Indicates whether downloading image assets should be disabled by the SDK when loading an ad. If called, the SDK will not download image assets and instead return a Image with just the URI and Scale properties populated. By default, the SDK will automatically download image assets and return a Image with all three properties (URI, Scale, and Drawable) populated.

enableCustomClickGestureDirection

@CanIgnoreReturnValue
open fun enableCustomClickGestureDirection(
    customClickGestureDirection: NativeAd.SwipeGestureDirection,
    customClickGestureAllowTaps: Boolean
): NativeSignalRequest.Builder

Enables swipes as a custom click gesture.

Available for allowlisted publishers only. These settings will be ignored for publishers not allowlisted.

Parameters
customClickGestureDirection: NativeAd.SwipeGestureDirection

The SwipeGestureDirection to be counted as a click.

customClickGestureAllowTaps: Boolean

Whether taps should still be allowed as clicks.

putAdSourceExtrasBundle

@CanIgnoreReturnValue
fun putAdSourceExtrasBundle(
    adapterClass: Class<MediationExtrasReceiver>,
    adSourceExtras: Bundle
): NativeSignalRequest.Builder

Adds extra parameters to pass to a specific ad source adapter.

Parameters
adapterClass: Class<MediationExtrasReceiver>

The Class of the adapter that should receive extras.

adSourceExtras: Bundle

A Bundle of extra information to pass to a mediation adapter.

putCustomTargeting

@CanIgnoreReturnValue
fun putCustomTargeting(key: String, value: String): NativeSignalRequest.Builder

Adds a custom targeting parameter. Calling this a second time with the same key will overwrite the old values.

This feature is only applicable for Ad Manager ad requests. Any custom targeting will be ignored on AdMob requests.

putCustomTargeting

@CanIgnoreReturnValue
fun putCustomTargeting(key: String, values: List<String>): NativeSignalRequest.Builder

Adds a custom targeting parameter with multiple values. Calling this a second time with the same key will overwrite the old values.

This feature is only applicable for Ad Manager ad requests. AdMob requests currently ignore custom targeting.

setAdChoicesPlacement

@CanIgnoreReturnValue
open fun setAdChoicesPlacement(adChoicesPlacement: AdChoicesPlacement): NativeSignalRequest.Builder

Sets the placement of the AdChoices icon (if available for the returned ad). The default value is AdChoicesPlacement.TOP_RIGHT.

setAdSize

@CanIgnoreReturnValue
open fun setAdSize(adSize: AdSize): NativeSignalRequest.Builder

Sets the AdSize and overwrites any list of ad sizes passed in setAdSizes.

This feature is available to Ad Manager publishers only. For more information, see mix banner and native ad requests. This method impacts banner ads only.

setAdSizes

@CanIgnoreReturnValue
open fun setAdSizes(adSizes: List<AdSize>): NativeSignalRequest.Builder

Sets a list of valid AdSizes and overwrites the ad size passed in setAdSize with the first size in the list.

This feature is available to Ad Manager publishers only. See mix banner and native ad requests for more information. This method impacts banner ads only.

setAdUnitId

@CanIgnoreReturnValue
fun setAdUnitId(adUnitId: String): NativeSignalRequest.Builder

Sets the ad unit ID.

setContentUrl

@CanIgnoreReturnValue
fun setContentUrl(contentUrl: String): NativeSignalRequest.Builder

Sets the content URL for a web site whose content matches the app's primary content. This web site content is used for targeting and brand safety purposes.

Throws
kotlin.IllegalArgumentException

If contentUrl is empty.

setCustomFormatIds

@CanIgnoreReturnValue
open fun setCustomFormatIds(customFormatIds: List<String>): NativeSignalRequest.Builder

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

This feature is available to Ad Manager publishers only.

setGoogleExtrasBundle

@CanIgnoreReturnValue
fun setGoogleExtrasBundle(extraBundle: Bundle): NativeSignalRequest.Builder

Set extra parameters to pass to AdMob or Ad Manager. Calling this a second time will overwrite the old values.

Parameters
extraBundle: Bundle

A Bundle of extra information to pass to AdMob or Ad Manager.

setManualImpressionEnabled

@CanIgnoreReturnValue
open fun setManualImpressionEnabled(enabled: Boolean): NativeSignalRequest.Builder

Indicates whether you intend to record impressions manually for the BannerAd. Use BannerAd.recordManualImpression to record impressions manually.

setMediaAspectRatio

@CanIgnoreReturnValue
open fun setMediaAspectRatio(mediaAspectRatio: NativeAd.NativeMediaAspectRatio): NativeSignalRequest.Builder

Sets the media aspect ratio.

setNativeAdTypes

@CanIgnoreReturnValue
fun setNativeAdTypes(nativeAdTypes: List<NativeAd.NativeAdType>): NativeSignalRequest.Builder

Sets a list of native ad types to request.

setNeighboringContentUrls

@CanIgnoreReturnValue
fun setNeighboringContentUrls(neighboringContentUrls: Set<String>): NativeSignalRequest.Builder

Sets URLs representing web content near an ad. Promotes brand safety and allows displayed ads to have an app level rating (MA, T, PG, etc) that is more appropriate to neighboring content.

Parameters
neighboringContentUrls: Set<String>

The set of neighboring content URLs to be attached to the existing neighboring content URLs.

setPublisherProvidedId

@CanIgnoreReturnValue
fun setPublisherProvidedId(publisherProvidedId: String): NativeSignalRequest.Builder

Sets an identifier for use in frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.

This feature is only applicable for Ad Manager ad requests. Any ID will be ignored on AdMob requests.

setRequestAgent

@CanIgnoreReturnValue
fun setRequestAgent(requestAgent: String): NativeSignalRequest.Builder

Sets the request agent string to identify the ad request's origin. Third party libraries that implement the Mobile Ads SDK on behalf of publishers should call this method to denote the platform from which the ad request originated.

setVideoOptions

@CanIgnoreReturnValue
open fun setVideoOptions(videoOptions: VideoOptions): NativeSignalRequest.Builder

Sets the VideoOptions for this request.

Protected functions

getContentUrl

protected fun getContentUrl(): String?

getGoogleExtrasBundle

protected fun getGoogleExtrasBundle(): Bundle

getPlacementId

protected fun getPlacementId(): Long

getPublisherProvidedId

protected fun getPublisherProvidedId(): String?

getRequestAgent

protected fun getRequestAgent(): String?

self

protected open fun self(): NativeSignalRequest.Builder

Protected properties

adSourceExtrasBundles

protected val adSourceExtrasBundlesMutableMap<StringBundle>

adUnitId

protected var adUnitIdString?

The ad unit ID.

categoryExclusions

protected val categoryExclusionsMutableSet<String>

customTargeting

protected val customTargetingMutableMap<StringString>

keywords

protected val keywordsHashSet<String>

neighboringContentUrls

protected val neighboringContentUrlsHashSet<String>

signalType

protected val signalTypeString