目录

Advertising

This function depends on the services provided by the Petal Ads SDK, which may collect users' personal data. Inform users that their personal data will be collected and guide them to read the corresponding privacy policy before they use this function in your quick game.

Definition

API

Description

Consent APIs

qg.setUnderAgeOfPromise(boolean underAgeOfPromise)

Sets the flag indicating whether a user is below the age of consent.

qg.requestConsentUpdate(Object object)

Requests an update to the user's consent status.

qg.setConsentStatus(number consentStatus)

Sets a user's consent status.

qg.setTagForChildProtection(number childProtection)

Sets whether to process ad requests according to the COPPA.

qg.setTagForUnderAgeOfPromise(number underAgeOfPromiseStr)

Sets whether to process ad requests in a manner appropriate for users below the age of consent.

qg.setAdContentClassification(string adContentClassification)

Sets the maximum ad content rating.

qg.setNonPersonalizedAd(number personalizedAd)

Sets whether to request non-personalized ads.

Native ad APIs

qg.createNativeAd(Object object)

Creates a native ad component. If a native ad component has been created before, the API returns the existing one.

nativeAd.load()

Obtains ad data.

nativeAd.reportAdShow()

Reports ad impressions. Only one report is valid for each ad. adId is a field in the ad data obtained by using the load method.

nativeAd.reportAdClick()

Reports ad clicks. Only one report is valid for each ad. adId is a field in the ad data obtained by using the load method.

nativeAd.onLoad(function callback)

Sets the callback for successful ad loading.

nativeAd.offLoad()

Removes the listener for successful native ad loading.

nativeAd.onError(function callback)

Listens for native ad error events.

nativeAd.offError()

Removes the listener for native ad loading errors.

nativeAd.setTagForChildProtection(number childProtection)

Sets whether to process ad requests according to the COPPA.

nativeAd.setTagForUnderAgeOfPromise(number underAgeOfPromiseStr)

Sets whether to process ad requests in a manner appropriate for users below the age of consent.

nativeAd.setAdContentClassification(string adContentClassification)

Sets the maximum ad content rating.

nativeAd.setNonPersonalizedAd(number personalizedAd)

Sets whether to request non-personalized ads.

nativeAd.startDownload(Object object)

Downloads the app associated with the native ad from the ad landing page.

nativeAd.showDownloadButton(Object object)

Shows the control button. adId is a field in the ad data obtained using the load method.

nativeAd.hideDownloadButton(Object object)

Hides the control button. adId is a field in the ad data obtained using the load method.

nativeAd.destroy()

Destroys a native ad.

Rewarded video ad APIs

qg.createRewardedVideoAd(Object object)

Creates a rewarded video ad.

rewardedVideoAd.load()

Manually obtains ads for refreshing the ad content.

rewardedVideoAd.show()

Displays the rewarded video ad. The rewarded video ad component is hidden by default, and calling show() will make it visible.

rewardedVideoAd.onLoad(function callback)

Sets the callback for successful ad loading.

rewardedVideoAd.offLoad()

Removes the listener for successful rewarded video ad loading.

rewardedVideoAd.onClose(function callback)

Listens for rewarded video ad closing events. A rewarded video ad can be closed only when the user actively closes it.

rewardedVideoAd.offClose()

Removes the listener for rewarded video ad closing events.

rewardedVideoAd.onError(function callback)

Listens for rewarded video ad loading error events.

rewardedVideoAd.offError()

Removes the listener for rewarded video ad loading error events.

rewardedVideoAd.setTagForChildProtection(number childProtection)

Sets whether to process ad requests according to the COPPA.

rewardedVideoAd.setTagForUnderAgeOfPromise(number underAgeOfPromiseStr)

Sets whether to process ad requests in a manner appropriate for users below the age of consent.

rewardedVideoAd.setAdContentClassification(string adContentClassification)

Sets the maximum ad content rating.

rewardedVideoAd.setNonPersonalizedAd(number personalizedAd)

Sets whether to request non-personalized ads.

rewardedVideoAd.destroy()

Destroys a rewarded video ad.

Banner ad APIs

qg.createBannerAd(Object object)

Creates a banner ad component. If a banner ad component has been created before, the API returns the existing one.

bannerAd.show()

Loads and displays a banner ad.

bannerAd.hide()

Hides a banner ad.

bannerAd.onError(function callback)

Listens for banner ad error events.

bannerAd.offError()

Removes the listener for banner ad error events.

bannerAd.onLoad(function callback)

Listens for banner ad loading events.

bannerAd.offLoad()

Removes the listener for banner ad loading events.

bannerAd.onClose(function callback)

Listens for banner ad closing events.

bannerAd.offClose()

Removes the listener for banner ad closing events.

bannerAd.destroy()

Destroys a banner ad.

Interstitial ad APIs

qg.createInterstitialAd(Object object)

Adds the content of an interstitial ad.

interstitialAd.load()

Loads an interstitial ad.

interstitialAd.show()

Displays an interstitial ad.

interstitialAd.onLoad(function callback)

Listens for interstitial ad loading events.

interstitialAd.offLoad()

Removes the listener for interstitial ad loading events.

interstitialAd.onError(function callback)

Listens for interstitial ad error events.

interstitialAd.offError() (1078+)

Removes the listener for interstitial ad error events.

interstitialAd.onClose(function callback)

Listens for interstitial ad closing events.

interstitialAd.offClose()

Removes the listener for interstitial ad closing events.

interstitialAd.onClick(function callback)

Listens for interstitial ad click events.

interstitialAd.offClick()

Removes the listener for interstitial ad click events.

interstitialAd.destroy()

Destroys an interstitial ad.

[h2]qg.setUnderAgeOfPromise(boolean underAgeOfPromise) (1077+)

[h2]qg.requestConsentUpdate(Object object) (1077+)

[h2]qg.setConsentStatus(number consentStatus) (1077+)

[h2]qg.setTagForChildProtection(number childProtection) (1078+)

[h2]qg.setTagForUnderAgeOfPromise(number underAgeOfPromiseStr) (1078+)

[h2]qg.setAdContentClassification(string adContentClassification) (1078+)

[h2]qg.setNonPersonalizedAd(number personalizedAd) (1078+)

[h2]qg.createNativeAd(Object object) (1075+)

[h2]nativeAd.load() (1075+)

[h2]nativeAd.reportAdShow() (1075+)

[h2]nativeAd.reportAdClick() (1075+)

[h2]nativeAd.onLoad(function callback) (1075+)

[h2]nativeAd.offLoad() (1075+)

[h2]nativeAd.onError(function callback) (1075+)

[h2]nativeAd.offError() (1075+)

[h2]nativeAd.setTagForChildProtection(number childProtection) (1077+)

[h2]nativeAd.setTagForUnderAgeOfPromise(number underAgeOfPromiseStr) (1077+)

[h2]nativeAd.setAdContentClassification(string adContentClassification) (1077+)

[h2]nativeAd.setNonPersonalizedAd(number personalizedAd) (1077+)

[h2]nativeAd.startDownload(Object object) (1078+)

[h2]nativeAd.showDownloadButton(Object object) (1115+)

[h2]nativeAd.hideDownloadButton(Object object) (1115+)

[h2]nativeAd.destroy() (1075+)

[h2]qg.createRewardedVideoAd(Object object) (1075+)

[h2]rewardedVideoAd.load() (1075+)

[h2]rewardedVideoAd.show() (1075+)

[h2]rewardedVideoAd.onLoad(function callback) (1075+)

[h2]rewardedVideoAd.offLoad() (1075+)

[h2]rewardedVideoAd.onClose(function callback) (1075+)

[h2]rewardedVideoAd.offClose() (1075+)

[h2]rewardedVideoAd.onError(function callback) (1075+)

[h2]rewardedVideoAd.offError() (1075+)

[h2]rewardedVideoAd.setTagForChildProtection(number childProtection) (1077+)

[h2]rewardedVideoAd.setTagForUnderAgeOfPromise(number underAgeOfPromiseStr) (1077+)

[h2]rewardedVideoAd.setAdContentClassification(string adContentClassification) (1077+)

[h2]rewardedVideoAd.setNonPersonalizedAd(number personalizedAd) (1077+)

[h2]rewardedVideoAd.destroy() (1075+)

[h2]qg.createBannerAd(Object object) (1078+)

[h2]bannerAd.show() (1078+)

[h2]bannerAd.hide() (1078+)

[h2]bannerAd.onError(function callback) (1078+)

[h2]bannerAd.offError() (1078+)

[h2]bannerAd.onLoad(function callback) (1078+)

[h2]bannerAd.offLoad() (1078+)

[h2]bannerAd.onClose(function callback) (1078+)

[h2]bannerAd.offClose() (1078+)

[h2]bannerAd.destroy() (1078+)

[h2]qg.createInterstitialAd(Object object) (1078+)

[h2]interstitialAd.load() (1078+)

[h2]interstitialAd.show() (1078+)

[h2]interstitialAd.onLoad(function callback) (1078+)

[h2]interstitialAd.offLoad() (1078+)

[h2]interstitialAd.onError(function callback) (1078+)

[h2]interstitialAd.offError() (1078+)

[h2]interstitialAd.onClose(function callback) (1078+)

[h2]interstitialAd.offClose() (1078+)

[h2]interstitialAd.onClick(function callback) (1078+)

[h2]interstitialAd.offClick() (1078+)

[h2]interstitialAd.destroy() (1078+)

Result Codes

A result code is the information obtained through the onError method.

Result Code

Description

200

Universal error.

202

Invalid parameter.

1001

The ad request is invalid due to specific reasons. For example, the ad unit ID is not set or the banner ad dimensions are invalid.

1002

The banner ad has expired or the banner ad task has been removed.

1003

Internal error.

1004

The ad request succeeded, but the server did not return any available ad assets.

1100

The ad is being requested and cannot be requested again.

1102

The API version is not supported by Ads Kit.

1104

The ad request failed due to a network connection error.

2000

The HMS Core (APK) version is outdated, which does not support the setting of AppInfo.