openharmony 鸿蒙 arkts-apis-webview-UserAgentMetadata

2026-08-25 浏览 (1)

Class (UserAgentMetadata)

This class provides APIs for configuring UserAgentMetadata.

NOTE

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

  • The initial APIs of this class are supported since API version 24.

  • The sample effect is subject to the actual device.

setBrandVersionList

setBrandVersionList(brandVersionList: Array<UserAgentBrandVersion>): void

Sets the brand and version information.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
brandVersionListArray<UserAgentBrandVersion>YesSec-CH-UA-Full-Version-List of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getBrandVersionList

getBrandVersionList(): Array<UserAgentBrandVersion>

Obtains the brand and version information list.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
Array<UserAgentBrandVersion>Brand and version information list.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setArchitecture

setArchitecture(arch: string): void

Sets the architecture type of the platform.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
archstringYesSec-CH-UA-Arch of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getArchitecture

getArchitecture(): string

Obtains the architecture type of the platform.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
stringPlatform architecture type.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setBitness

setBitness(bitness: string): void

Sets the bitness type of the platform.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
archstringYesSec-CH-UA-Bitness of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getBitness

getBitness(): string

Obtains the bitness type of the platform.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
stringBitness type of the platform.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setFormFactors

setFormFactors(formFactors: Array<UserAgentFormFactor>): void

Sets the device form, such as the mobile phone or tablet.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
formFactorsArray<UserAgentFormFactor>YesSec-CH-UA-Form-Factor of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getFormFactors

getFormFactors(): Array<UserAgentFormFactor>

Obtains the device form, such as the mobile phone or tablet.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
Array<UserAgentFormFactor>Device form information.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setFullVersion

setFullVersion(fullVersion: string): void

Sets the full version number.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
fullVersionstringYesSec-CH-UA-Full-Version of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getFullVersion

getFullVersion(): string

Obtains the full version number.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
stringFull version number.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setMobile

setMobile(isMobile: boolean): void

Sets whether the device is a mobile device.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
isMobilebooleanYesSec-CH-UA-Mobile of the request header. It indicates whether the device is a mobile device. true means yes; false otherwise. Default value: true.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getMobile

getMobile(): boolean

Obtains whether the device is a mobile device.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
booleanWhether the device is a mobile device. true means yes; false otherwise.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setModel

setModel(model: string): void

Sets the device model.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
modelstringYesSec-CH-UA-Mobile of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getModel

getModel(): string

It is used to obtain the device model.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
stringDevice model.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setPlatform

setPlatform(platform: string): void

Sets the OS name.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
platformstringYesSec-CH-UA-Platform of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getPlatform

getPlatform(): string

Obtains the OS name.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
stringOS name.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setPlatformVersion

setPlatformVersion(platformVersion: string): void

Sets the OS version.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
platformVersionstringYesSec-CH-UA-Platform-Version of the request header. If this parameter is left empty, the default ArkWeb value is used.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getPlatformVersion

getPlatformVersion(): string

Obtains the OS version.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
stringOS version.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

setWow64

setWow64(isWow64: boolean): void

Sets whether the binary file runs in 32-bit mode on a 64-bit Windows.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Parameters

NameTypeMandatoryDescription
isWow64booleanYesSec-CH-UA-WoW64 of the request header. Whether the binary file runs in 32-bit mode on a 64-bit Windows. true means yes; false otherwise. The default value is false.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

getWow64

getWow64(): boolean

Checks whether the binary file runs in 32-bit mode on a 64-bit Windows.

System capability: SystemCapability.Web.Webview.Core

Model restriction: This API can be used only in the stage model.

Return value

TypeDescription
booleanWhether the binary file runs in 32-bit mode on a 64-bit Windows. true means yes; false otherwise.

Example

For details about the sample code, see setUserAgentClientHintsEnabled.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-webview-WebviewController

openharmony 鸿蒙 arkts-apis-webview-t

openharmony 鸿蒙 arkts-apis-webview

openharmony 鸿蒙 capi-arkweb-type-h

openharmony 鸿蒙 arkts-basic-components-web-FullScreenExitHandler

openharmony 鸿蒙 arkts-apis-webview-WebDownloadManager

openharmony 鸿蒙 arkts-basic-components-web-VerifyPinHandler

openharmony 鸿蒙 capi-web-arkweb-webmessage8h

openharmony 鸿蒙 arkts-apis-webview-NativeMediaPlayerHandler

openharmony 鸿蒙 capi-web-arkweb-proxymethodwithresult

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