Skip to main content

RewardedAd

Creates Rewarded Ad and register event listeners to various events.

tip

If you are going to use Rewarded Ad inside functional component, consider using useRewardedAd.

Useage Example

TODO

Methods

info

Methods listed below except createAd() must be called from instance created by createAd() static method.

createAd()

static createAd(unitId: string, options?: FullScreenAdOptions): RewardedAd

Creates an ad instance.

Parameters

unitId : Ad unitId.

options (Optional) : Options for this ad.

Properties:

NameTypeDefaultDescription
loadOnMountedbooleantrueWhether your ad to load automatically on mounted.
showOnLoadedbooleanfalseWhether your ad to show automatically on loaded.
loadOnDismissedbooleanfalseWhether your ad to load new ad automatically on dismissed.
requestOptionsRequestOptions{}Optional RequestOptions used to load the ad.

Returns

RewardedAd instance

load()

load(requestOptions?: RequestOptions): Promise<void>

Loads new Ad.

Parameters

requestOptions (Optional) : RequestOptions used to load the ad.

Returns

Promise that waits for ad load. When error is occured while loading ad, the Promise will reject with AdError object.

show()

show(): Promise<void>

Shows loaded Ad.

Ad must be loaded before calling this function.

Returns

Promise that waits for ad present. When error is occurred while presenting ad, the Promise will reject with AdError object.

addEventListener()

addEventListener(event: string, handler: (event?: any) => any): void

Adds an event handler for an ad event.

Parameters

event : Event name. Supported events:

Event NameDescription
adLoadedFires when the ad has finished loading.
adFailedToLoadFires when the ad has failed to load. The argument to the event handler is AdError object.
adPresentedFires when the ad is presented to user.
adFailedToPresentFires when an error occurred while presenting ad. The argument to the event handler is AdError object.
adDismissedFires when the ad is dismissed.
rewardedFires when user earned reward. The argument to the event handler is Reward object.

handler : An event handler.

removeAllListeners()

removeAllListeners(): void

Removes all registered event handlers for this ad.

setRequestOptions()

setRequestOptions(requestOptions?: RequestOptions): void

Sets RequestOptions for this Ad instance.

Parameters

requestOptions : RequestOptions used to load the ad.