tencent cloud

All product documents
Tencent Cloud Super App as a Service
Last updated: 2025-04-10 16:37:38
Ad
Last updated: 2025-04-10 16:37:38

wx.createRewardedVideoAd

wx.createRewardedVideoAd(Object object)

Feature description:Creates a rewarded video ad component. The rewarded video ad created by calling this method is a singleton (a global singleton in a mini game, and a singleton within a page in a mini program. The singleton object in the mini program cannot be used across pages.)
Parameter: Object object.
Property
Type
Default value
‍Required
Description
adUnitId
string
-
True
Ad unit ID.
multiton
boolean
-
False
Whether to enable multiple-instance mode. Default: false.
Return value:RewardedVideoAd.Rewarded video ad component.

RewardedVideoAd

Rewarded video ad component. The rewarded video ad is a native component with a higher level than regular components. Each rewarded video ad is a singleton, which is hidden by default and you need to call RewardedVideoAd.show() to display it.

Method

RewardedVideoAd.load()

Feature description:Loads a rewarded video ad.
Return value:Promise. The result of loading data for a rewarded video ad.

RewardedVideoAd.show()

Feature description:Displays a rewarded video ad. The rewarded video ad will slide up from the bottom of the screen.
Return value:Promise, the result of displaying the rewarded video ad.

RewardedVideoAd.destroy()

Feature description:Destroys a rewarded video ad instance.

RewardedVideoAd.onLoad(function listener)

Feature description:Listens for the rewarded video ad loading event.
Parameter: function listener. The listener for the rewarded video ad loading event.

RewardedVideoAd.offLoad(function listener)

Feature description:Removes the listener for the rewarded video ad loading event.
Parameter: function listener. The listener that was passed to onLoad. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

RewardedVideoAd.onLoad(listener)
RewardedVideoAd.offLoad(listener) // Must pass the same function object used in onLoad

RewardedVideoAd.onError(function listener)

Feature description:Listens for rewarded video error events.
Parameter: function listener. The listener for rewarded video error events.
Return parameter: Object res.
Property
Type
Description
errMsg
string
Error information.
errCode
number
Error code.

RewardedVideoAd.offError(function listener)

Feature description:Removes the listener for rewarded video error events.
Parameter: function listener. The listener that was passed to onError. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

RewardedVideoAd.onError(listener)
RewardedVideoAd.offError(listener) // Must pass the same function object used in onError

RewardedVideoAd.onClose(function listener)

Feature description:Listens for the event when a user taps the close button.
Parameter: function listener. The listener for the event when a user taps the close button.
Return parameter: Object res.
Property
Type
Description
isEnded
boolean
Indicates whether the video was closed after being fully watched by the user.

RewardedVideoAd.offClose(function listener)

Feature description:Removes the listener for the event when a user taps the close button.
Parameter: function listener. The listener that was passed to onClose. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

RewardedVideoAd.onClose(listener)
RewardedVideoAd.offClose(listener) // Must pass the same function object used in onClose

wx.createBannerAd

wx.createBannerAd(Object object)

Feature description:Creates a banner ad component. Each time this method is called to create a banner ad, a new instance is returned.
Parameter: Object object.
Property
Type
Default value
‍Required
Description
adUnitId
string
-
True
Ad unit ID.
style
Object
-
True
The style of the banner ad component.
The value of style is as follows:
Property
Type
Default value
‍Required
Description
left
number
-
True
The top-left X coordinate of the banner ad component.
top
number
-
True
The top-left Y coordinate of the banner ad component.
width
number
-
True
The width of the banner ad component.
height
number
-
True
The height of the banner ad component.
Return value:BannerAd.A banner ad component.

BannerAd

The banner ad component, which is a native component with a higher level than regular components. The banner ad component is hidden by default and you need to call BannerAd.show() to display it. The banner ad will be scaled proportionally to the width set by the developer, and the scaled size will be provided using the BannerAd.onResize() event.

Property

Object style
The style of the banner ad component. The values of the style properties represent only the developer-defined settings. The banner ad will be scaled proportionally to the width set by the developer, and the scaled size will be provided using the BannerAd.onResize() event.
Property
Type
Description
left
number
The top-left X coordinate of the banner ad component.
top
number
The top-left Y coordinate of the banner ad component.
width
number
The width of the banner ad component. The minimum value is 300 px, and the maximum value is the screen width (obtained using wx.getSystemInfoSync()).
height
number
The height of the banner ad component.
realWidth
number
The actual width of the banner ad component after proportional scaling.
realHeight
number
The actual height of the banner ad component after proportional scaling.

Method

BannerAd.show()

Feature description:Shows a banner ad.
Return value: Promise. The result of displaying the rewarded video ad.

BannerAd.hide()

Feature description:Hides a banner ad.

BannerAd.destroy()

Feature description:Destroy a banner ad.

BannerAd.onResize(function listener)

Feature description:Listens for the banner ad size change event.
Parameter: function listener. The listener for the banner ad size change event.
Return parameter: Object res.
Property
Type
Description
width
number
Scaled width.
height
number
Scaled height.

BannerAd.offResize(function listener)

Feature description:Removes the listener for the banner ad size change event.
Parameter: function listener. The listener that was pass to onResize. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

BannerAd.onResize(listener)
BannerAd.offResize(listener) // Must pass the same function object used in onResize

BannerAd.onLoad(function listener)

Feature description:Listens for the banner ad loading event.
Parameter: function listener. The listener for the banner ad loading event.

BannerAd.offLoad(function listener)

Feature description:Removes the listener for the banner ad loading event.
Parameter: function listener. The listener that was passed to onLoad. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

BannerAd.onLoad(listener)
BannerAd.offLoad(listener) // Must pass the same function object used in onLoad

BannerAd.onError(function listener)

Feature description:Listens for banner ad error events.
Parameter: function listener. The listener for banner ad error events.
Return parameter: Object res.
Property
Type
Description
errMsg
string
Error information.
errCode
number
Error code.

BannerAd.offError(function listener)

Feature description:Removes the listener for banner ad error events.
Parameter: function listener. The listener that was passed to onError. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

BannerAd.onError(listener)
BannerAd.offError(listener) // Must pass the same function object used in on Error

Error code

Error codes are obtained through the onError event. During debugging, you can capture error details via exception returns. You can add appropriate monitoring information to assist in troubleshooting issues in the live environment.
Error code.
Description
Reason
1000
Failed to call the backend API
This error is not caused by the developer.
1001
Parameter error
Incorrect usage.
1002
Invalid ad unit
Incorrect ad unit ID spelling or accidental use of another app's ad unit ID.
1003
Internal error
This error is not caused by the developer.
1004
No suitable ad
Ads do not appear every time; this time it might not appear because there are no ads that match the user's preferences.
1010
Ad feature disabled
The ad feature has been disabled.


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon