openharmony 鸿蒙 js-apis-advertising

2025-06-12 浏览 (1)

@ohos.advertising (Ads Service Framework)

The advertising module provides APIs for requesting and displaying ads.

NOTE

  • The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { advertising } from '@kit.AdsKit';

advertising.showAd

showAd(ad: Advertisement, options: AdDisplayOptions, context?: common.UIAbilityContext): void

Shows a full-screen ad.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
adAdvertisementYesAd object.
optionsAdDisplayOptionsYesAd display parameters.
contextcommon.UIAbilityContextNoContext of the UIAbility. If this parameter is not set, the value is obtained from @ohos.app.ability.common.

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: 1. Mandatory parameters are left unspecified.
21800001System internal error.
21800004Failed to display the ad.

Example

import { common } from '@kit.AbilityKit';
import { advertising } from '@kit.AdsKit';
import { hilog } from '@kit.PerformanceAnalysisKit';

@Entry
@Component
struct Index {
  private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
  // Requested ad content.
  private ad?: advertising.Advertisement;
  // Ad display parameters.
  private adDisplayOptions: advertising.AdDisplayOptions = {
    // Whether to mute the ad. By default, the ad is not muted.
    mute: false
  }

  build() {
    Column() {
      Button('showAd')
        .onClick(() => {
          try {
            // Show the ad.
            advertising.showAd(this.ad, this.adDisplayOptions, this.context);
          } catch (err) {
            hilog.error(0x0000, 'testTag', `Fail to show ad. Code is ${err.code}, message is ${err.message}`);
          }
        });
    }
    .width('100%')
    .height('100%')
  }
}

advertising.getAdRequestBody12+

getAdRequestBody(adParams: AdRequestParams[], adOptions: AdOptions): Promise<string>

Obtains the body of an ad request. This API uses a promise to return the result. (This API is available only for some preset applications.)

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
adParamsAdRequestParams[]YesAd request parameters.
- The adid parameter is optional.
adOptionsAdOptionsYesAd configuration.

Return value

TypeDescription
Promise<string>Promise used to return the ad data of the string type.

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.
801Device not supported.
21800001System internal error.

Example

import { advertising } from '@kit.AdsKit';
import { Prompt } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';

function getAdRequestBody(): void {
  const adRequestParamsArray: advertising.AdRequestParams[] = [];
  const adRequestParams: advertising.AdRequestParams = {
    adId: 'testu7m3hc4gvm',
    adType: 3,
    adCount: 2,
    adWidth: 100,
    adHeight: 100
  };
  adRequestParamsArray.push(adRequestParams);
  const adOptions: advertising.AdOptions = {
    // Set whether to request only non-personalized ads. 0: to request personalized ads and non-personalized ads; 1: to request only non-personalized ads. If this parameter is left blank, the service logic prevails.
    nonPersonalizedAd: 0,
    // Specify whether you want your ad content to be treated as COPPA-compliant. The following values are available: -1 (default value): uncertain; 0: no; 1: yes.
    tagForChildProtection: -1,
    // Specify whether you want the ad request to be processed in a way that meets the GDPR for users in the EEA under the age of consent. The following values are available: -1 (default value): uncertain; 0: no; 1: yes.
    tagForUnderAgeOfPromise: -1,
    // Maximum ad content rating. W: aged 3 and up; PI: aged 7 and up, under parental guidance; J: teenagers aged 12 and up; A: adults aged 16 or 18 and up.
    adContentClassification: 'A'
  };
  advertising.getAdRequestBody(adRequestParamsArray, adOptions).then((data) => {
    hilog.info(0x0000, 'testTag', `Succeeded in getting ad request body. Data is ${JSON.stringify(data)}`);
    Prompt.showToast({
      message: data,
      duration: 1000
    });
  }).catch((error: BusinessError) => {
    hilog.error(0x0000, 'testTag', `Fail to get ad request body. Code is ${error.code}, message is ${error.message}`);
    Prompt.showToast({
      message: error.code.toString() + ',' + error.message,
      duration: 1000
    });
  })
}

advertising.parseAdResponse12+

parseAdResponse(adResponse: string, listener: MultiSlotsAdLoadListener, context: common.UIAbilityContext): void

Parses and processes the ad response body. (This API is available only for some preset applications.)

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
adResponsestringYesAd response body.
listenerMultiSlotsAdLoadListenerYesAd request callback.
contextcommon.UIAbilityContextYesUIAbility context.

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.
801Device not supported.
21800001System internal error.
21800005Failed to parse the ad response.

Example

For details about how to obtain the context, see Obtaining the Context of UIAbility.

import { common } from '@kit.AbilityKit';
import { advertising } from '@kit.AdsKit';
import { hilog } from '@kit.PerformanceAnalysisKit';

function parseAdResponse(adResponse: string, context: common.UIAbilityContext): void {
  // Listen for the ad parsing callback.
  const multiSlotsAdLoaderListener: advertising.MultiSlotsAdLoadListener = {
    // Called when ad parsing fails.
    onAdLoadFailure: (errorCode: number, errorMsg: string) => {
      hilog.error(0x0000, 'testTag', `Fail to load multiSlots ad. Code is ${errorCode}, message is ${errorMsg}`);
    },
    // Called when ad parsing is successful.
    onAdLoadSuccess: (ads: Map<string, Array<advertising.Advertisement>>) => {
      hilog.info(0x0000, 'testTag', 'Succeed in loading multiSlots ad');
      // Save the parsed ad content as an array for display.
      const returnAds: Array<advertising.Advertisement> = [];
      ads.forEach((adsArray) => returnAds.push(...adsArray));
    }
  };
  // Call the API to parse the response body.
  hilog.info(0x0000, 'testTag', 'Start to parse ad response');
  advertising.parseAdResponse(adResponse, multiSlotsAdLoaderListener, context);
}

advertising.registerWebAdInterface12+

registerWebAdInterface(controller: web_webview.WebviewController, context: common.UIAbilityContext): void

Injects an ad JavaScript object to the Web component. (This API is available only for some preset applications.)

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
controllerweb_webview.WebviewControllerYesController of the Web component.
contextcommon.UIAbilityContextYesUIAbility context.

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: 1. Mandatory parameters are left unspecified.
21800001System internal error.

Example

import { common } from '@kit.AbilityKit';
import { advertising } from '@kit.AdsKit';
import { webview } from '@kit.ArkWeb';
import { hilog } from '@kit.PerformanceAnalysisKit';

@Entry
@Component
struct Index {
  private webController: webview.WebviewController = new webview.WebviewController();
  private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;

  build() {
    Column() {
      Button('registerWebAdInterface')
        .onClick(() => {
          try {
            advertising.registerWebAdInterface(this.webController, this.context);
          } catch (err) {
            hilog.error(0x0000, 'testTag', `Fail to register web ad interface. Code is ${err.code}, message is ${err.message}`);
          }
        })

      Web({
        src: 'www.example.com',
        controller: this.webController
      })
        .width("100%")
        .height("100%")
    }
  }
}

advertising.registerWebAdInterface16+

registerWebAdInterface(controller: web_webview.WebviewController, context: common.UIAbilityContext, needRefresh: boolean): void

Injects an ad JavaScript object to the Web component. (This API is available only for some preset applications.)

Atomic service API: This API can be used in atomic services since API version 16.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
controllerweb_webview.WebviewControllerYesController of the Web component.
contextcommon.UIAbilityContextYesUIAbility context.
needRefreshbooleanYesWhether a page needs to be refreshed. (The value true means that a page needs to be refreshed; the value false means the opposite.)

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: Mandatory parameters are left unspecified.
21800001operation javascriptRegister error.

Example

import { common } from '@kit.AbilityKit';
import { advertising } from '@kit.AdsKit';
import { webview } from '@kit.ArkWeb';
import { hilog } from '@kit.PerformanceAnalysisKit';

@Entry
@Component
struct Index {
  private webController: webview.WebviewController = new webview.WebviewController();
  private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;

  build() {
    Column() {
      Button('registerWebAdInterface')
        .onClick(() => {
          try {
            advertising.registerWebAdInterface(this.webController, this.context, true);
          } catch (err) {
            hilog.error(0x0000, 'testTag', `Fail to register web ad interface. Code is ${err.code}, message is ${err.message}`);
          }
        })

      Web({
        src: 'www.example.com',
        controller: this.webController
      })
        .width("100%")
        .height("100%")
    }
  }
}

advertising.deleteWebAdInterface16+

deleteWebAdInterface(controller: web_webview.WebviewController, needRefresh: boolean): void

Deletes the ad JavaScript object injected through registerWebAdInterface. (This API is available only to some preset applications.)

Atomic service API: This API can be used in atomic services since API version 16.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
controllerweb_webview.WebviewControllerYesController of the Web component.
needRefreshbooleanYesWhether a page needs to be refreshed. (The value true means that a page needs to be refreshed; the value false means the opposite.)

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: Mandatory parameters are left unspecified.
21800001operation javascriptRegister error.

Example

import { advertising } from '@kit.AdsKit';
import { webview } from '@kit.ArkWeb';
import { hilog } from '@kit.PerformanceAnalysisKit';

@Entry
@Component
struct Index {
  private webController: webview.WebviewController = new webview.WebviewController();

  build() {
    Column() {
      Button('deleteWebAdInterface')
        .onClick(() => {
          try {
            advertising.deleteWebAdInterface(this.webController, true);
          } catch (err) {
            hilog.error(0x0000, 'testTag', `Fail to delete web ad interface. Code is ${err.code}, message is ${err.message}`);
          }
        })

      Web({
        src: 'www.example.com',
        controller: this.webController,
      })
        .width('100%')
        .height('100%')
    }
  }
}

AdLoader

Provides the APIs for loading ads.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

constructor

constructor(context: common.Context)

Constructor.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
contextcommon.ContextYesContext of the ability or application.

Example

For details about how to obtain the context, see Context.

import { advertising } from '@kit.AdsKit';
import { common } from '@kit.AbilityKit';

function createConstructor(context: common.Context): void {
  const adLoader: advertising.AdLoader = new advertising.AdLoader(context);
}

loadAd

loadAd(adParam: AdRequestParams, adOptions: AdOptions, listener: AdLoadListener): void

Loads an ad.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
adParamAdRequestParamsYesAd request parameters.
adOptionsAdOptionsYesAd configuration.
listenerAdLoadListenerYesAd request callback.

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.
801Device not supported.
21800001System internal error.
21800003Failed to load the ad request.

Example

For details about how to obtain the context, see Context.

import { common } from '@kit.AbilityKit';
import { advertising } from '@kit.AdsKit';
import { hilog } from '@kit.PerformanceAnalysisKit';

function loadAd(context: common.Context): void {
  const adRequestParams: advertising.AdRequestParams = {
    // Ad type.
    adType: 3,
    // Ad ID.
    adId: 'testy63txaom86'
  };
  const adOptions: advertising.AdOptions = {
    // Optional custom parameter, which specifies whether to allow ad asset download using mobile data. The options are 0 (no) and 1 (yes). If this parameter is not set, the advertiser's setting will be used.
    allowMobileTraffic: 0,
    // Specify whether you want your ad content to be treated as COPPA-compliant. The following values are available: -1 (default value): uncertain; 0: no; 1: yes.
    tagForChildProtection: -1,
    // Specify whether you want the ad request to be processed in a way that meets the GDPR for users in the EEA under the age of consent. The following values are available: -1 (default value): uncertain; 0: no; 1: yes.
    tagForUnderAgeOfPromise: -1,
    // Maximum ad content rating. W: aged 3 and up; PI: aged 7 and up, under parental guidance; J: teenagers aged 12 and up; A: adults aged 16 or 18 and up.
    adContentClassification: 'A'
  };
  // Listener for the ad loading status.
  const adLoaderListener: advertising.AdLoadListener = {
    // Called when the ad request fails.
    onAdLoadFailure: (errorCode: number, errorMsg: string) => {
      hilog.error(0x0000, 'testTag', `Fail to load ad. Code is ${errorCode}, message is ${errorMsg}`);
    },
    // Called when the ad request is successful.
    onAdLoadSuccess: (ads: Array<advertising.Advertisement>) => {
      hilog.info(0x0000, 'testTag', 'Succeed in loading ad');
      // Save the requested ad content for display.
      const returnAds = ads;
    }
  };
  // Create an AdLoader object.
  const adLoader: advertising.AdLoader = new advertising.AdLoader(context);
  // Load the ad.
  hilog.info(0x0000, 'testTag', 'Start to load ad');
  adLoader.loadAd(adRequestParams, adOptions, adLoaderListener);
}

loadAdWithMultiSlots

loadAdWithMultiSlots(adParams: AdRequestParams[], adOptions: AdOptions, listener: MultiSlotsAdLoadListener): void

Loads multiple ads.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
adParamsAdRequestParams[]YesAd request parameters.
adOptionsAdOptionsYesAd configuration.
listenerMultiSlotsAdLoadListenerYesAd request callback.

Error codes

For details about the following error codes, see Ads Service Framework Error Codes.

IDError Message
401Invalid input parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.
801Device not supported.
21800001System internal error.
21800003Failed to load the ad request.

Example

For details about how to obtain the context, see Context.

import { common } from '@kit.AbilityKit';
import { advertising } from '@kit.AdsKit';
import { hilog } from '@kit.PerformanceAnalysisKit';

function loadAdWithMultiSlots(context: common.Context): void {
  const adRequestParamsArray: advertising.AdRequestParams[] = [
    {
      // Ad type.
      adType: 3,
      // Ad ID.
      adId: 'testy63txaom86'
    },
    {
      // Ad type.
      adType: 3,
      // Ad ID.
      adId: 'testy63txaom86'
    }
  ];
  const adOptions: advertising.AdOptions = {
    // Optional custom parameter, which specifies whether to allow ad asset download using mobile data. The options are 0 (no) and 1 (yes). If this parameter is not set, the advertiser's setting will be used.
    allowMobileTraffic: 0,
    // Specify whether you want your ad content to be treated as COPPA-compliant. The following values are available: -1 (default value): uncertain; 0: no; 1: yes.
    tagForChildProtection: -1,
    // Specify whether you want the ad request to be processed in a way that meets the GDPR for users in the EEA under the age of consent. The following values are available: -1 (default value): uncertain; 0: no; 1: yes.
    tagForUnderAgeOfPromise: -1,
    // Maximum ad content rating. W: aged 3 and up; PI: aged 7 and up, under parental guidance; J: teenagers aged 12 and up; A: adults aged 16 or 18 and up.
    adContentClassification: 'A'
  };
  // Listener for the ad loading status.
  const multiSlotsAdLoaderListener: advertising.MultiSlotsAdLoadListener = {
    // Called when the ad request fails.
    onAdLoadFailure: (errorCode: number, errorMsg: string) => {
      hilog.error(0x0000, 'testTag', `Fail to load multiSlots ad. Code is ${errorCode}, message is ${errorMsg}`);
    },
    // Called when the ad request is successful.
    onAdLoadSuccess: (ads: Map<string, Array<advertising.Advertisement>>) => {
      hilog.info(0x0000, 'testTag', 'Succeed in loading multiSlots ad');
      // Save the requested ad content for display.
      const returnAds: Array<advertising.Advertisement> = [];
      ads.forEach((adsArray) => returnAds.push(...adsArray));
    }
  };
  // Create an AdLoader object.
  const adLoader: advertising.AdLoader = new advertising.AdLoader(context);
  // Load the ad.
  hilog.info(0x0000, 'testTag', 'Start to load multiSlots ad');
  adLoader.loadAdWithMultiSlots(adRequestParamsArray, adOptions, multiSlotsAdLoaderListener);
}

AdLoadListener

Enumerates the callbacks used for the request for loading an ad.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

onAdLoadFailure

onAdLoadFailure(errorCode: number, errorMsg: string): void

Called when an ad request fails.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
errorCodenumberYesResult code indicating the ad request failure.
errorMsgstringYesError message about the ad request failure.

onAdLoadSuccess

onAdLoadSuccess(ads: Array<Advertisement>): void

Called when an ad request is successful.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
adsArray<Advertisement>YesAd data.

Example

import { advertising } from '@kit.AdsKit';

const adLoaderListener: advertising.AdLoadListener = {
  onAdLoadFailure: (errorCode: number, errorMsg: string) => {
  },
  onAdLoadSuccess: (ads: Array<advertising.Advertisement>) => {
  }
}

MultiSlotsAdLoadListener

Enumerates the callbacks used for the request for loading multiple ads.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

onAdLoadFailure

onAdLoadFailure(errorCode: number, errorMsg: string): void

Called when a request for loading multiple ads fails.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
errorCodenumberYesResult code indicating the ad request failure.
errorMsgstringYesError message about the ad request failure.

onAdLoadSuccess

onAdLoadSuccess(adsMap: Map<string, Array<Advertisement>>): void

Called when a request for loading multiple ads is successful.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
adsMapMap<string, Array<Advertisement>>YesAd data.

Example

import { advertising } from '@kit.AdsKit';

const multiSlotsAdLoadListener: advertising.MultiSlotsAdLoadListener = {
  onAdLoadFailure: (errorCode: number, errorMsg: string) => {
  },
  onAdLoadSuccess: (adsMap: Map<string, Array<advertising.Advertisement>>) => {
  }
}

AdInteractionListener

Defines the ad status change callback.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

onStatusChanged

onStatusChanged(status: string, ad: Advertisement, data: string)

Called when the ad display status changes.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

Parameters

NameTypeMandatoryDescription
statusstringYesstatus: ad display status, which can be
onAdOpen, onAdClose, onAdClick, onVideoPlayBegin, onVideoPlayEnd, onAdLoad, onAdFail, onMediaProgress, onMediaStart, onMediaPause, onMediaStop, onMediaComplete, onMediaError, onLandscape, onPortrait, onAdReward, onMediaCountDown, or onBackClicked.
adAdvertisementYesContent of the ad.
datastringYesExtended information.

Example

import { advertising } from '@kit.AdsKit';

const adInteractionListener: advertising.AdInteractionListener = {
  onStatusChanged: (status: string, ad: advertising.Advertisement, data: string) => {

  }
}

AdOptions

Defines the ad configuration.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

NameTypeRead-OnlyOptionalDescription
tagForChildProtectionnumberNoYesTag for child protection, which specifies whether you want the ad content to be treated as COPPA-compliant.
- -1: Uncertain.
- 0: No. You do not want the ad content to be treated as COPPA-compliant.
- 1: Yes. You want the ad content to be treated as COPPA-compliant.
adContentClassificationstringNoYesMaximum ad content rating.
- W: ages 3+, all audiences.
- PI: ages 7+, audiences under parental instruction.
- J: ages 12+, teenagers.
- A: ages 16+/18+, adults.
nonPersonalizedAdnumberNoYesWhether to request only non-personalized ads.
- 0: request for personalized and non-personalized ads.
- 1: request for only non-personalized ads.
[key: string]number |boolean |string |undefinedNoYesCustom parameters.

AdRequestParams

Defines the ad request parameters.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

NameTypeRead-OnlyOptionalDescription
adIdstringNoNoAd ID
- This parameter is optional for getAdRequestBody.
adTypenumberNoYesType of the requested ad.
- 1: splash ad.
- 3: native ad.
- 7: rewarded ad.
- 8: banner ad.
- 12: interstitial ad.
- 60: roll ad.
adCountnumberNoYesNumber of ads requested.
adWidthnumberNoYesExpected creative width of ads requested, in vp.
adHeightnumberNoYesExpected creative height of ads requested, in vp.
adSearchKeywordstringNoYesAd keyword.
[key: string]number |boolean |string |undefinedNoYesCustom parameters.
- oaid: A string indicates the Open Anonymous Device Identifier (OAID), which is used to precisely push ads.

AdDisplayOptions

Defines the ad display parameters.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

NameTypeRead-OnlyOptionalDescription
customDatastringNoYesCustom media data.
userIdstringNoYesUser ID.
useMobileDataReminderbooleanNoYesWhether to display a dialog box to notify users when they use mobile data to play videos or download applications.
- true: A dialog box is displayed.
- false: No dialog box is displayed.
mutebooleanNoYesWhether to mute the ad video.
- true: The ad video is muted.
- false: The ad video is not muted.
audioFocusTypenumberNoYesType of the scenario where the audio focus is obtained during video playback.
- 0: The focus is obtained when the video is played in mute or non-mute mode.
- 1: The focus is not obtained when the video is played in mute mode.
- 2: The focus is not obtained when the video is played in mute or non-mute mode.
[key: string]number |boolean |string |undefinedNoYesCustom parameters.
- refreshTime: The value is of the number type, in ms. The value is in the range [30000, 120000]. This parameter is optional for the AutoAdComponent module and specifies the interval at which the ads rotate. If this parameter is set, ads are rotated at the interval specified by this parameter. Otherwise, ads are not rotated and only the first ad in the ad response is displayed.

Advertisement

type Advertisement = _Advertisement

Defines the requested ad content.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Advertising.Ads

TypeDescription
_AdvertisementAdvertisement object.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ads Kit

harmony 鸿蒙Ads Service Framework Error Codes

harmony 鸿蒙OAID Error Codes

harmony 鸿蒙@ohos.advertising.AdComponent (Non-Full-Screen Ad Component)

harmony 鸿蒙@ohos.advertising.AdsServiceExtensionAbility (ExtensionAbility for Ads) (System API)

harmony 鸿蒙@ohos.advertising.AdsServiceExtensionAbility (ExtensionAbility for Ads)

harmony 鸿蒙@ohos.advertising.AutoAdComponent (Carousel Ad Component)

harmony 鸿蒙Advertisement

harmony 鸿蒙@ohos.identifier.oaid (OAID) (System API)

harmony 鸿蒙@ohos.identifier.oaid (OAID)

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/5qNl6q