1# @ohos.bundle.appDomainVerify (应用域名校验)(系统接口)
2
3本模块提供应用域名校验能力,支持查询应用与域名之间的映射关系。
4
5> **说明:**
6>
7> 本模块首批接口从API version 13开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8
9## 导入模块
10
11```ts
12import { appDomainVerify } from '@kit.AbilityKit';
13```
14
15## 权限列表
16
17| 权限                                    | 权限等级    | 描述             |
18| --------------------------------------- | ----------- | ---------------- |
19| ohos.permission.GET_APP_DOMAIN_BUNDLE_INFO | system_basic | 允许应用访问应用和域名的映射关系的权限。 |
20
21权限等级参考[权限APL等级说明](../../security/AccessToken/app-permission-mgmt-overview.md#权限机制中的基本概念)。
22
23## appDomainVerify.queryAssociatedDomains
24
25queryAssociatedDomains(bundleName: string): string[]
26
27通过应用的包名查询其关联的网站域名列表。
28
29**需要权限:** ohos.permission.GET_APP_DOMAIN_BUNDLE_INFO
30
31**系统能力:** SystemCapability.BundleManager.AppDomainVerify
32
33**系统接口:**  此接口为系统接口。
34
35**参数:**
36
37| 参数名         | 类型     | 必填   | 说明                                      |
38| ----------- | ------ | ---- | --------------------------------------- |
39| bundleName  | string | 是    | 需要查询的应用包名。       |
40
41**返回值:**
42
43| 类型                        | 说明                 |
44| ------------------------- | ------------------ |
45| string[] | 返回包名关联的网站域名列表,若无关联的域名,则返回空数组。 |
46
47**错误码:**
48
49以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle.appDomainVerify错误码](errorcode-appDomainVerify.md.md)。
50
51| 错误码ID | 错误信息                                  |
52| -------- | ----------------------------------------- |
53| 201 | Permission denied. |
54| 202 | Permission denied, non-system app called system api. |
55| 401 | Parameter error.|
56| 29900001 | System internal error. |
57
58**示例:**
59
60```ts
61import { appDomainVerify } from '@kit.AbilityKit';
62
63// 获取包名为"com.example.app1"的应用所关联的域名列表
64let bundleName = "com.example.app1";
65let domains = appDomainVerify.queryAssociatedDomains(bundleName);
66domains.forEach(domain => {
67  console.log(`app:${bundleName} associate with domain:${domain}`);
68});
69```
70
71## appDomainVerify.queryAssociatedBundleNames
72
73queryAssociatedBundleNames(domain: string): string[]
74
75通过网站域名查询其关联的应用包名列表。
76
77**需要权限:** ohos.permission.GET_APP_DOMAIN_BUNDLE_INFO
78
79**系统能力:** SystemCapability.BundleManager.AppDomainVerify
80
81**系统接口:**  此接口为系统接口。
82
83**参数:**
84
85| 参数名         | 类型     | 必填   | 说明                                      |
86| ----------- | ------ | ---- | --------------------------------------- |
87| domain  | string | 是    | 需要查询的网站域名。       |
88
89**返回值:**
90
91| 类型                        | 说明                 |
92| ------------------------- | ------------------ |
93| string[] | 返回网站域名关联的应用包名列表,若无关联的应用,则返回空数组。 |
94
95**错误码:**
96
97以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle.appDomainVerify错误码](errorcode-appDomainVerify.md.md)。
98
99| 错误码ID | 错误信息                                  |
100| -------- | ----------------------------------------- |
101| 201 | Permission denied. |
102| 202 | Permission denied, non-system app called system api. |
103| 401 | Parameter error.|
104| 29900001 | System internal error. |
105
106**示例:**
107
108```ts
109import { appDomainVerify } from '@kit.AbilityKit';
110
111// 获取域名"example.com"应用所关联的包名列表
112let domain = "example.com";
113let bundleNames = appDomainVerify.queryAssociatedBundleNames(domain);
114bundleNames.forEach(bundleName => {
115  console.log(`domain:${domain} associate with app:${bundleName}`);
116});
117```
118