@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 System API accessed by non-system app.
401 Parameter error.
29900001 Internal error.

Example

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

// 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 => {
  hilog.info(0x0000, 'testTag', `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 System API accessed by non-system app.
401 Parameter error.
29900001 Internal error.

Example

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

// 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 => {
  hilog.info(0x0000, 'testTag', `domain:${domain} associate with app:${bundleName}`);
});