harmony 鸿蒙@ohos.bundle.appDomainVerify (Application Domain Name Verification) (System API)

  • 2025-06-12
  • 浏览 (7)

@ohos.bundle.appDomainVerify (Application Domain Name Verification) (System API)

The appDomainVerify module provides APIs to query the mappings between applications and domain names for the purposes of application domain name verification.

NOTE

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

Modules to Import

import { appDomainVerify } from '@kit.AbilityKit';

Required Permissions

Permission APL Description
ohos.permission.GET_APP_DOMAIN_BUNDLE_INFO system_basic Allows an application to access the mappings between applications and domain names.

For details about the APL, see Basic Concepts in the Permission Mechanism.

appDomainVerify.queryAssociatedDomains

queryAssociatedDomains(bundleName: string): string[]

Queries the list of domain names associated with an application based on its bundle name.

Required permissions: ohos.permission.GET_APP_DOMAIN_BUNDLE_INFO

System capability: SystemCapability.BundleManager.AppDomainVerify

System API: This is a system API.

Parameters

Name Type Mandatory Description
bundleName string Yes Bundle name of the application.

Returns

Type Description
string[] List of domain names associated with the bundle name. If no domain name is associated, an empty array is returned.

Error codes

For details about the error codes, see Universal Error Codes and Application Domain Name Verification Error Codes.

ID Error Message
201 Permission denied.
202 Permission denied, non-system app called system api.
401 Parameter error.
29900001 System internal error.

Example

import { appDomainVerify } from '@kit.AbilityKit';

// Obtain the list of domain names associated with the bundle name "com.example.app1".
let bundleName = "com.example.app1";
let domains = appDomainVerify.queryAssociatedDomains(bundleName);
domains.forEach(domain => {
  console.log(`app:${bundleName} associate with domain:${domain}`);
});

appDomainVerify.queryAssociatedBundleNames

queryAssociatedBundleNames(domain: string): string[]

Obtains the list of bundle names associated with a domain name.

Required permissions: ohos.permission.GET_APP_DOMAIN_BUNDLE_INFO

System capability: SystemCapability.BundleManager.AppDomainVerify

System API: This is a system API.

Parameters

Name Type Mandatory Description
domain string Yes Domain name.

Returns

Type Description
string[] List of bundle names associated with the domain name. If no application is associated, an empty array is returned.

Error codes

For details about the error codes, see Universal Error Codes and Application Domain Name Verification Error Codes.

ID Error Message
201 Permission denied.
202 Permission denied, non-system app called system api.
401 Parameter error.
29900001 System internal error.

Example

import { appDomainVerify } from '@kit.AbilityKit';

// Obtain the list of bundle names associated with the domain name "example.com".
let domain = "example.com";
let bundleNames = appDomainVerify.queryAssociatedBundleNames(domain);
bundleNames.forEach(bundleName => {
  console.log(`domain:${domain} associate with app:${bundleName}`);
});

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙AbilityAccessControl

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_access_control.h

harmony 鸿蒙ability_base_common.h

0  赞