RewardedAd
import { RewardedAd } from 'nitro-ui-admob'
A full-screen ad that grants a reward when watched. Each loaded ad can be shown once, within one hour of loading. Guide: rewarded ads.
| Member | Description |
|---|---|
load(adUnitId, options?) | Loads an ad. |
expiresAt | When the ad expires. |
reward | The reward the ad grants. |
onUserEarnedReward | Called when the user earned the reward. |
setServerSideVerificationOptions(options) | Data for your server-side verification callback. |
show() | Presents the ad once. |
| Callbacks | The shared full-screen events. |
load
static load(adUnitId: string, options?: AdmobRequestOptions): Promise<RewardedAd>
Loads an ad, starting the SDK if needed. options is an AdmobRequestOptions. Rejects with "<code>: <message>" from the SDK.
expiresAt
readonly expiresAt: number
When the ad expires, in milliseconds since the Unix epoch: one hour after loading.
reward
readonly reward: AdmobReward
The AdmobReward granted when the user finishes the ad, as configured in the AdMob UI.
onUserEarnedReward
onUserEarnedReward?: (reward: AdmobReward) => void
Called when the user earned reward.
setServerSideVerificationOptions
setServerSideVerificationOptions(options: AdmobServerSideVerificationOptions): void
Sets the data forwarded to your server-side verification callback. Call it before show. See AdmobServerSideVerificationOptions.
show
show(): void
Presents the ad over the current screen. Callbacks, including onUserEarnedReward, are cleared once it is dismissed or fails to show.
Throws if this ad was already shown or has expired.
Callbacks
| Callback | Type | Called when |
|---|---|---|
onAdShown | () => void | The ad starts covering the screen. |
onAdDismissed | () => void | The user dismissed the ad. |
onAdFailedToShow | (error: AdmobError) => void | The ad could not be presented. |
onAdImpression | () => void | The SDK recorded an impression. |
onAdClicked | () => void | The SDK recorded a click. |
onAdPaid | (value: AdmobAdValue) => void | With the estimated revenue of the impression. |