wx.createRewardedVideoAd
wx.createRewardedVideoAd(Object object)
Feature description:Creates a rewarded video ad component. The rewarded video ad created by this method is a singleton within a page and cannot be used across pages in the mini program.
Parameter: Object object.
|
adUnitId | string | - | True | Ad unit ID. |
multiton | boolean | - | False | Whether to enable multiple-instance mode. Default: false. |
RewardedVideoAd
The rewarded video ad will be rendered as a native component with a higher level than regular components. The rewarded video ad object is a singleton within a page. By default, the rewarded ad is hidden and needs to be displayed using RewardedVideoAd.show().
RewardedVideoAd.load()
Feature description:Loads the rewarded video ad.
Return value:Promise, the result of loading the rewarded video ad data.
RewardedVideoAd.show()
Feature description:Displays a rewarded video ad.
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)
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.
|
errMsg | string | Error information. |
| 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)
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.
|
isEnded | boolean | Whether the video was closed after the user watched it completely. |
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)
Error code
Error codes are obtained through 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.
|
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. |