The rewarded video ad component is composed of native image, text, and video controls from the client. It has the highest layer level and will cover full-screen Canvas elements.
Developers can call wx.createRewardedVideoAd to create a rewarded video ad component. This method returns a global singleton. let video1 = wx.createRewardedVideoAd({ adUnitId: 'xxxx' })
let video2 = wx.createRewardedVideoAd({ adUnitId: 'xxxx' })
console.log(video1 === video2)
The rewarded video ad component is hidden by default, allowing it to be pre-created for early initialization.
let rewardedVideoAd = wx.createRewardedVideoAd({ adUnitId: 'xxxx' })
To avoid misuse of ad resources, each user is limited to a certain number of rewarded video ads per day. It is recommended to check if the ad has been successfully fetched before displaying the ad button.
Show/Hide
The rewarded video ad component can only be closed when the user taps the close
button. Developers cannot control the hiding of the rewarded video ad component.
Fetch success and failure
The rewarded video ad component automatically fetches ads and refreshes them. It fetches an ad upon the component creation and fetches the next ad after the user taps the close
button.
rewardedVideoAd.onLoad(() => {
console.log('rewardedVideoAd load')
})
rewardedVideoAd.show()
.then(() => console.log('rewardedVideoAd show'))
rewardedVideoAd.onError(err => {
console.log(err)
})
rewardedVideoAd.show()
.catch(err => console.log(err))
Retry on fetch failure
If the component fails to fetch the ad automatically, subsequent calls to show() will be rejected. You can now call RewardedVideoAd.load() to manually re-fetch the ad. rewardedVideoAd.show()
.catch(err => {
rewardedVideoAd.load()
.then(() => rewardedVideoAd.show())
})
If the automatic fetch is successful, calling the load() method will return a resolved Promise without fetching the ad again.
rewardedVideoAd.load()
.then(() => rewardedVideoAd.show())
Listening for ad closure
The rewarded video ad component can only be closed when the user taps the close
button. This event can be listened using RewardedVideoAd.onClose() . The close button is displayed after
the rewarded video finishes playing.So when onClose is triggered, it can be assumed that the user has watched the entire ad.
The callback function for RewardedVideoAd.onClose() will pass a parameter res, where res.isEnded describes the state when the ad ends. Property | Type | Description |
isEnded | boolean | Indicates whether the video was closed after the user watched it completely (true), or during playback (false). |