Class: AdApi

ad.AdApi

Ads wrapper class. Handles ad instance creation and pre-loading with proper instance recycling.

Constructors

constructor

new AdApi(client): AdApi

Parameters

Name Type
client Client

Returns

AdApi

Properties

adInstance

Private adInstance: Record<string, undefined | Promise<null | AdInstance>>


adPromise

Private adPromise: Record<string, undefined | Promise<null | AdInstance>>


client

Private client: Client

Methods

isSupported

isSupported(type): boolean

Is the ad type supported on the current platform.

Parameters

Name Type Description
type AdType Ad type

Returns

boolean


log

log(event, parameters): void

Parameters

Name Type
event string
parameters Object

Returns

void


prepare

prepare(adData): Promise<void>

Prepare an ad for display. If the ad has already been prepared or is still being prepared the returned promise will resolve to the same instance as the earlier calls. In other words it is safe to call this multiple times before the ad has been shown.

Parameters

Name Type Description
adData AdData Ad configuration

Returns

Promise<void>


show

show(adData, fallbackAdData?): Promise<boolean>

Show an ad. If the ad has not been prepared before calling show the ad will be prepared “on the fly” before showing. The promise resolves with true if the ad was shown succesfully or false if no ad was available.

When a fallback ad is provided it will be used in the case of ad failure. This is usually used to show an interstitial ad when a rewarded video ad is not available.

Parameters

Name Type Description
adData AdData Ad configuration
fallbackAdData? AdData Optional fallback ad configuration

Returns

Promise<boolean>