tencent cloud

Rewarded Video Ad
Terakhir diperbarui:2025-04-09 18:35:50
Rewarded Video Ad
Terakhir diperbarui: 2025-04-09 18:35:50
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)
// true
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

By default, the rewarded video ad component is hidden. You need to call RewardedVideoAd.show() to display it.
rewardedVideoAd.show()
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.
If the ad is fetched successfully, RewardedVideoAd.onLoad() will be executed. The Promise returned by RewardedVideoAd.show() will also be a resolved Promise. Neither of these callback functions receives any parameters.
rewardedVideoAd.onLoad(() => {
console.log('rewardedVideoAd load')
})

rewardedVideoAd.show()
.then(() => console.log('rewardedVideoAd show'))
If the ad fails to fetch, the callback function registered with RewardedVideoAd.onError() will be executed, and the parameter of the callback function is an object containing failure information.Common error codes.
rewardedVideoAd.onError(err => {
console.log(err)
})
The Promise returned by RRewardedVideoAd.show() will also be a rejected Promise.
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).





Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
Ya
Tidak

masukan