• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.notificationManager (NotificationManager模块)(系统接口)
2<!--Kit: Notification Kit-->
3<!--Subsystem: Notification-->
4<!--Owner: @michael_woo888-->
5<!--Designer: @dongqingran; @wulong158-->
6<!--Tester: @wanghong1997-->
7<!--Adviser: @huipeizi-->
8
9本模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知渠道,获取通知的使能状态、角标使能状态,获取通知的相关信息等。
10
11> **说明:**
12>
13> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
14>
15> 当前界面仅包含本模块的系统接口,其他公开接口参见[NotificationManager](./js-apis-notificationManager.md)。
16
17## 导入模块
18
19```ts
20import { notificationManager } from '@kit.NotificationKit';
21```
22
23## notificationManager.publish
24
25publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
26
27发布通知给指定的用户。使用callback异步回调。
28
29**系统能力**:SystemCapability.Notification.Notification
30
31**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.SEND_NOTIFICATION_CROSS_USER
32
33**系统接口**:此接口为系统接口。
34
35**参数:**
36
37| 参数名     | 类型                                        | 必填 | 说明                                        |
38| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
39| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
40| userId   | number                                      | 是   | 用户ID。                           |
41| callback | AsyncCallback\<void\>                       | 是   | 被指定的回调方法。                           |
42
43**错误码:**
44
45以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[HTTP错误码](../apis-network-kit/errorcode-net-http.md)。
46
47| 错误码ID | 错误信息                                              |
48| -------- | ---------------------------------------------------- |
49| 201      | Permission denied.     |
50| 202      | Not system application to call the interface.                                      |
51| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
52| 1600001  | Internal error.                                      |
53| 1600002  | Marshalling or unmarshalling error.                  |
54| 1600003  | Failed to connect to the service.                    |
55| 1600004  | Notification disabled.                               |
56| 1600005  | Notification slot disabled.                    |
57| 1600007  | The notification does not exist.                       |
58| 1600008  | The user does not exist.                               |
59| 1600009  | The notification sending frequency reaches the upper limit.            |
60| 1600012  | No memory space.                                     |
61| 1600014  | No permission.                                   |
62| 1600015  | The current notification status does not support duplicate configurations. |
63| 1600016  | The notification version for this update is too low. |
64| 1600020  | The application is not allowed to send notifications due to permission settings. |
65| 2300007  | Network unreachable.                              |
66
67**示例:**
68
69```ts
70import { BusinessError } from '@kit.BasicServicesKit';
71
72// publish回调
73let publishCallback = (err: BusinessError): void => {
74    if (err) {
75        console.error(`publish failed, code is ${err.code}, message is ${err.message}`);
76    } else {
77        console.info("publish success");
78    }
79}
80// 用户ID,使用时需替换为真实的userId。
81let userId: number = 1;
82// 通知Request对象
83let notificationRequest: notificationManager.NotificationRequest = {
84    id: 1,
85    content: {
86        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
87        normal: {
88            title: "test_title",
89            text: "test_text",
90            additionalText: "test_additionalText"
91        }
92    }
93};
94notificationManager.publish(notificationRequest, userId, publishCallback);
95```
96
97## notificationManager.publish
98
99publish(request: NotificationRequest, userId: number): Promise\<void\>
100
101发布通知给指定的用户。使用Promise异步回调。
102
103**系统能力**:SystemCapability.Notification.Notification
104
105**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.SEND_NOTIFICATION_CROSS_USER
106
107**系统接口**:此接口为系统接口。
108
109**参数:**
110
111| 参数名     |  类型                                        | 必填 | 说明                                        |
112| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
113| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
114| userId   | number                                      | 是   | 用户ID。                           |
115
116**返回值:**
117
118| 类型     | 说明        |
119| ------- |-----------|
120| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
121
122**错误码:**
123
124以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[HTTP错误码](../apis-network-kit/errorcode-net-http.md)。
125
126| 错误码ID | 错误信息                                              |
127| -------- | ---------------------------------------------------- |
128| 201      | Permission denied.     |
129| 202      | Not system application to call the interface.                                      |
130| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
131| 1600001  | Internal error.                                      |
132| 1600002  | Marshalling or unmarshalling error.                  |
133| 1600003  | Failed to connect to the service.                           |
134| 1600004  | Notification disabled.                         |
135| 1600005  | Notification slot disabled.                    |
136| 1600007  | The notification does not exist.                       |
137| 1600008  | The user does not exist.                               |
138| 1600009  | The notification sending frequency reaches the upper limit.            |
139| 1600012  | No memory space.                                     |
140| 1600014  | No permission.                                   |
141| 1600015  | The current notification status does not support duplicate configurations. |
142| 1600016  | The notification version for this update is too low. |
143| 1600020  | The application is not allowed to send notifications due to permission settings. |
144| 2300007  | Network unreachable.                              |
145
146**示例:**
147
148```ts
149import { BusinessError } from '@kit.BasicServicesKit';
150
151let notificationRequest: notificationManager.NotificationRequest = {
152    id: 1,
153    content: {
154        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
155        normal: {
156            title: "test_title",
157            text: "test_text",
158            additionalText: "test_additionalText"
159        }
160    }
161};
162
163// 用户ID,使用时需替换为真实的userId。
164let userId: number = 1;
165
166notificationManager.publish(notificationRequest, userId).then(() => {
167	console.info("publish success");
168}).catch((err: BusinessError) => {
169    console.error(`publish failed, code is ${err.code}, message is ${err.message}`);
170});
171```
172
173## notificationManager.addSlot
174
175addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
176
177创建通知渠道。使用callback异步回调。
178
179**系统能力**:SystemCapability.Notification.Notification
180
181**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
182
183**系统接口**:此接口为系统接口。
184
185**参数:**
186
187| 参数名     | 类型                  | 必填 | 说明                 |
188| -------- | --------------------- | ---- | -------------------- |
189| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)       | 是   | 要创建的通知渠道对象。 |
190| callback | AsyncCallback\<void\> | 是   | 表示被指定通道的回调方法。 |
191
192**错误码:**
193
194以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
195
196| 错误码ID | 错误信息                            |
197| -------- | ----------------------------------- |
198| 201      | Permission denied.     |
199| 202      | Not system application to call the interface.                                      |
200| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
201| 1600001  | Internal error.                     |
202| 1600002  | Marshalling or unmarshalling error. |
203| 1600003  | Failed to connect to the service.          |
204| 1600012  | No memory space.                          |
205
206**示例:**
207
208```ts
209import { BusinessError } from '@kit.BasicServicesKit';
210
211// addSlot回调
212let addSlotCallBack = (err: BusinessError): void => {
213    if (err) {
214        console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
215    } else {
216        console.info("addSlot success");
217    }
218}
219// 通知slot对象
220let notificationSlot: notificationManager.NotificationSlot = {
221    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
222};
223notificationManager.addSlot(notificationSlot, addSlotCallBack);
224```
225
226## notificationManager.addSlot
227
228addSlot(slot: NotificationSlot): Promise\<void\>
229
230创建通知渠道。使用Promise异步回调。
231
232**系统能力**:SystemCapability.Notification.Notification
233
234**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
235
236**系统接口**:此接口为系统接口。
237
238**参数:**
239
240| 参数名 | 类型             | 必填 | 说明                 |
241| ---- | ---------------- | ---- | -------------------- |
242| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md) | 是   | 要创建的通知渠道对象。 |
243
244**返回值:**
245
246| 类型     | 说明        |
247| ------- |-----------|
248| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
249
250**错误码:**
251
252以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
253
254| 错误码ID | 错误信息                            |
255| -------- | ----------------------------------- |
256| 201      | Permission denied.     |
257| 202      | Not system application to call the interface.                                      |
258| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
259| 1600001  | Internal error.                     |
260| 1600002  | Marshalling or unmarshalling error. |
261| 1600003  | Failed to connect to the service.          |
262| 1600012  | No memory space.                          |
263
264**示例:**
265
266```ts
267import { BusinessError } from '@kit.BasicServicesKit';
268
269// 通知slot对象
270let notificationSlot: notificationManager.NotificationSlot = {
271    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
272};
273notificationManager.addSlot(notificationSlot).then(() => {
274	console.info("addSlot success");
275}).catch((err: BusinessError) => {
276    console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
277});
278```
279
280## notificationManager.addSlots
281
282addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
283
284创建多个通知渠道。使用callback异步回调。
285
286**系统能力**:SystemCapability.Notification.Notification
287
288**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
289
290**系统接口**:此接口为系统接口。
291
292**参数:**
293
294| 参数名     | 类型                      | 必填 | 说明                     |
295| -------- | ------------------------- | ---- | ------------------------ |
296| slots    | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)\> | 是   | 要创建的通知渠道对象数组。数组中的元素个数为0~5。 |
297| callback | AsyncCallback\<void\>     | 是   | 表示被指定通道的回调方法。     |
298
299**错误码:**
300
301以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
302
303| 错误码ID | 错误信息                            |
304| -------- | ----------------------------------- |
305| 201      | Permission denied.     |
306| 202      | Not system application to call the interface.                                      |
307| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
308| 1600001  | Internal error.                     |
309| 1600002  | Marshalling or unmarshalling error. |
310| 1600003  | Failed to connect to the service.          |
311| 1600012  | No memory space.                          |
312
313**示例:**
314
315```ts
316import { BusinessError } from '@kit.BasicServicesKit';
317
318// addSlots回调
319let addSlotsCallBack = (err: BusinessError): void => {
320    if (err) {
321        console.error(`addSlots failed, code is ${err.code}, message is ${err.message}`);
322    } else {
323        console.info("addSlots success");
324    }
325}
326// 通知slot对象
327let notificationSlot: notificationManager.NotificationSlot = {
328    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
329};
330// 通知slot array 对象
331let notificationSlotArray: notificationManager.NotificationSlot[] = new Array();
332notificationSlotArray[0] = notificationSlot;
333
334notificationManager.addSlots(notificationSlotArray, addSlotsCallBack);
335```
336
337## notificationManager.addSlots
338
339addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
340
341创建多个通知渠道。使用Promise异步回调。
342
343**系统能力**:SystemCapability.Notification.Notification
344
345**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
346
347**系统接口**:此接口为系统接口。
348
349**参数:**
350
351| 参数名  | 类型                      | 必填 | 说明                     |
352| ----- | ------------------------- | ---- | ------------------------ |
353| slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)\> | 是   | 要创建的通知渠道对象数组。数组中的元素个数为0~5。 |
354
355**返回值:**
356
357| 类型      | 说明        |
358|---------|-----------|
359| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
360
361**错误码:**
362
363以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
364
365| 错误码ID | 错误信息                            |
366| -------- | ----------------------------------- |
367| 201      | Permission denied.     |
368| 202      | Not system application to call the interface.                                      |
369| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
370| 1600001  | Internal error.                     |
371| 1600002  | Marshalling or unmarshalling error. |
372| 1600003  | Failed to connect to the service.          |
373| 1600012  | No memory space.                          |
374
375**示例:**
376
377```ts
378import { BusinessError } from '@kit.BasicServicesKit';
379
380// 通知slot对象
381let notificationSlot: notificationManager.NotificationSlot = {
382    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
383};
384// 通知slot array 对象
385let notificationSlotArray: notificationManager.NotificationSlot[] = new Array();
386notificationSlotArray[0] = notificationSlot;
387
388notificationManager.addSlots(notificationSlotArray).then(() => {
389	console.info("addSlots success");
390}).catch((err: BusinessError) => {
391    console.error(`addSlots failed, code is ${err.code}, message is ${err.message}`);
392});
393```
394
395
396## notificationManager.setNotificationEnable
397
398setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
399
400设定指定应用的通知使能状态。使用callback异步回调。
401
402**系统能力**:SystemCapability.Notification.Notification
403
404**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
405
406**系统接口**:此接口为系统接口。
407
408**参数:**
409
410| 参数名     | 类型                  | 必填 | 说明                 |
411| -------- | --------------------- | ---- | -------------------- |
412| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)   | 是   | 指定应用的包信息。        |
413| enable   | boolean               | 是   | 使能状态(true:使能,false:禁止)。             |
414| callback | AsyncCallback\<void\> | 是   | 设定通知使能回调函数。 |
415
416**错误码:**
417
418以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
419
420| 错误码ID | 错误信息                                 |
421| -------- | ---------------------------------------- |
422| 201      | Permission denied.     |
423| 202      | Not system application to call the interface.                                      |
424| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
425| 1600001  | Internal error.                          |
426| 1600002  | Marshalling or unmarshalling error.      |
427| 1600003  | Failed to connect to the service.               |
428| 17700001 | The specified bundle name was not found. |
429
430**示例:**
431
432```ts
433import { BusinessError } from '@kit.BasicServicesKit';
434
435let setNotificationEnableCallback = (err: BusinessError): void => {
436    if (err) {
437        console.error(`setNotificationEnable failed, code is ${err.code}, message is ${err.message}`);
438    } else {
439        console.info("setNotificationEnable success");
440    }
441}
442let bundle: notificationManager.BundleOption = {
443    bundle: "bundleName1",
444};
445notificationManager.setNotificationEnable(bundle, false, setNotificationEnableCallback);
446```
447
448## notificationManager.setNotificationEnable
449
450setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
451
452设定指定应用的通知使能状态。使用Promise异步回调。
453
454**系统能力**:SystemCapability.Notification.Notification
455
456**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
457
458**系统接口**:此接口为系统接口。
459
460**参数:**
461
462| 参数名   | 类型         | 必填 | 说明       |
463| ------ | ------------ | ---- | ---------- |
464| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
465| enable | boolean      | 是   | 使能状态(true:使能,false:禁止)。   |
466
467**返回值:**
468
469| 类型      | 说明        |
470|---------|-----------|
471| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
472
473**错误码:**
474
475以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
476
477| 错误码ID | 错误信息                                 |
478| -------- | ---------------------------------------- |
479| 201      | Permission denied.     |
480| 202      | Not system application to call the interface.                                      |
481| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
482| 1600001  | Internal error.                          |
483| 1600002  | Marshalling or unmarshalling error.      |
484| 1600003  | Failed to connect to the service.               |
485| 17700001 | The specified bundle name was not found. |
486
487**示例:**
488
489```ts
490import { BusinessError } from '@kit.BasicServicesKit';
491
492let bundle: notificationManager.BundleOption = {
493    bundle: "bundleName1",
494};
495notificationManager.setNotificationEnable(bundle, false).then(() => {
496	console.info("setNotificationEnable success");
497}).catch((err: BusinessError) => {
498    console.error(`setNotificationEnable failed, code is ${err.code}, message is ${err.message}`);
499});
500```
501
502## notificationManager.getAllNotificationEnabledBundles<sup>12+</sup>
503
504getAllNotificationEnabledBundles(): Promise<Array<BundleOption\>>
505
506获取允许通知的应用程序列表。使用Promise异步回调。
507
508**系统能力**:SystemCapability.Notification.Notification
509
510**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
511
512**系统接口**:此接口为系统接口。
513
514**返回值:**
515
516| 类型      | 说明        |
517|---------|-----------|
518| Promise<Array<[BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption)\>> | 返回允许通知的应用程序列表。 |
519
520**错误码:**
521
522以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
523
524| 错误码ID | 错误信息                            |
525| -------- | ----------------------------------- |
526| 201      | Permission denied.     |
527| 202      | Not system application to call the interface.                                      |
528| 1600001  | Internal error.                     |
529| 1600002  | Marshalling or unmarshalling error. |
530| 1600003  | Failed to connect to the service.          |
531
532**示例:**
533
534```ts
535import { BusinessError } from '@kit.BasicServicesKit';
536
537notificationManager.getAllNotificationEnabledBundles().then((data: Array<notificationManager.BundleOption>) => {
538    console.info(`Enable bundle data is ${JSON.stringify(data)}`);
539    data.forEach(element => {
540        console.info(`Enable uid is ${JSON.stringify(element.uid)}`);
541        console.info(`Enable bundle is ${JSON.stringify(element.bundle)}`);
542    });
543}).catch((err: BusinessError) => {
544    console.error(`getAllNotificationEnabledBundles failed, code is ${err.code}, message is ${err.message}`);
545})
546```
547
548## notificationManager.isNotificationEnabled
549
550isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
551
552获取指定应用的通知使能状态。使用callback异步回调。
553
554**系统能力**:SystemCapability.Notification.Notification
555
556**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
557
558**系统接口**:此接口为系统接口。
559
560**参数:**
561
562| 参数名     | 类型                  | 必填 | 说明                     |
563| -------- | --------------------- | ---- | ------------------------ |
564| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。            |
565| callback | AsyncCallback\<boolean\> | 是   | 获取通知使能状态回调函数(true:使能,false:禁止)。 |
566
567**错误码:**
568
569以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
570
571| 错误码ID | 错误信息                                 |
572| -------- | ---------------------------------------- |
573| 201      | Permission denied.     |
574| 202      | Not system application to call the interface.                                      |
575| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
576| 1600001  | Internal error.                          |
577| 1600002  | Marshalling or unmarshalling error.      |
578| 1600003  | Failed to connect to the service.               |
579| 17700001 | The specified bundle name was not found. |
580
581**示例:**
582
583```ts
584import { BusinessError } from '@kit.BasicServicesKit';
585
586let isNotificationEnabledCallback = (err: BusinessError, data: boolean): void => {
587    if (err) {
588        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
589    } else {
590        console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
591    }
592}
593
594let bundle: notificationManager.BundleOption = {
595    bundle: "bundleName1",
596};
597
598notificationManager.isNotificationEnabled(bundle, isNotificationEnabledCallback);
599```
600
601## notificationManager.isNotificationEnabled
602
603isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
604
605获取指定应用的通知使能状态。使用Promise异步回调。
606
607**系统能力**:SystemCapability.Notification.Notification
608
609**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
610
611**系统接口**:此接口为系统接口。
612
613**参数:**
614
615| 参数名   | 类型         | 必填 | 说明       |
616| ------ | ------------ | ---- | ---------- |
617| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
618
619**返回值:**
620
621| 类型               | 说明                                                |
622| ------------------ | --------------------------------------------------- |
623| Promise\<boolean\> | 以Promise形式返回获取指定应用的通知使能状态的结果(true:使能,false:禁止)。 |
624
625**错误码:**
626
627以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
628
629| 错误码ID | 错误信息                                 |
630| -------- | ---------------------------------------- |
631| 201      | Permission denied.     |
632| 202      | Not system application to call the interface.                                      |
633| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
634| 1600001  | Internal error.                          |
635| 1600002  | Marshalling or unmarshalling error.      |
636| 1600003  | Failed to connect to the service.               |
637| 17700001 | The specified bundle name was not found. |
638
639**示例:**
640
641```ts
642import { BusinessError } from '@kit.BasicServicesKit';
643
644let bundle: notificationManager.BundleOption = {
645    bundle: "bundleName1",
646};
647notificationManager.isNotificationEnabled(bundle).then((data: boolean) => {
648	console.info(`isNotificationEnabled success, data: ${JSON.stringify(data)}`);
649}).catch((err: BusinessError) => {
650    console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
651});
652```
653
654## notificationManager.isNotificationEnabled
655
656isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
657
658获取指定用户ID下的通知使能状态。使用callback异步回调。
659
660**系统能力**:SystemCapability.Notification.Notification
661
662**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
663
664**系统接口**:此接口为系统接口。
665
666**参数:**
667
668| 参数名     | 类型                  | 必填 | 说明                     |
669| -------- | --------------------- | ---- | ------------------------ |
670| userId   | number                | 是   | 指定的用户ID。 |
671| callback | AsyncCallback\<boolean\> | 是   | 获取通知使能状态回调函数(true:使能,false:禁止)。 |
672
673**错误码:**
674
675以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
676
677| 错误码ID | 错误信息                            |
678| -------- | ----------------------------------- |
679| 201      | Permission denied.     |
680| 202      | Not system application to call the interface.                                      |
681| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
682| 1600001  | Internal error.                     |
683| 1600002  | Marshalling or unmarshalling error. |
684| 1600003  | Failed to connect to the service.          |
685| 1600008  | The user does not exist.              |
686
687**示例:**
688
689```ts
690import { BusinessError } from '@kit.BasicServicesKit';
691
692let isNotificationEnabledCallback = (err: BusinessError, data: boolean): void => {
693    if (err) {
694        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
695    } else {
696        console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
697    }
698}
699
700// 用户ID,使用时需替换为真实的userId。
701let userId: number = 1;
702
703notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
704```
705
706## notificationManager.isNotificationEnabled
707
708isNotificationEnabled(userId: number): Promise\<boolean\>
709
710获取指定用户下的通知使能状态。使用Promise异步回调。
711
712**系统能力**:SystemCapability.Notification.Notification
713
714**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
715
716**系统接口**:此接口为系统接口。
717
718**参数:**
719
720| 参数名   | 类型         | 必填 | 说明       |
721| ------ | ------------ | ---- | ---------- |
722| userId | number       | 是   | 指定的用户ID。 |
723
724**返回值:**
725
726| 类型                                                        | 说明                                                         |
727| ----------------------------------------------------------- | ------------------------------------------------------------ |
728| Promise\<boolean\> | 以Promise形式返回获取通知使能状态的结果(true:使能,false:禁止)。 |
729
730**错误码:**
731
732以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
733
734| 错误码ID | 错误信息                                 |
735| -------- | ---------------------------------------- |
736| 201      | Permission denied.     |
737| 202      | Not system application to call the interface.                                      |
738| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
739| 1600001  | Internal error.                          |
740| 1600002  | Marshalling or unmarshalling error.      |
741| 1600003  | Failed to connect to the service.               |
742| 1600008  | The user does not exist.                  |
743
744**示例:**
745
746```ts
747import { BusinessError } from '@kit.BasicServicesKit';
748
749// 用户ID,使用时需替换为真实的userId。
750let userId: number = 1;
751
752notificationManager.isNotificationEnabled(userId).then((data: boolean) => {
753	console.info(`isNotificationEnabled success, data: ${JSON.stringify(data)}`);
754}).catch((err: BusinessError) => {
755    console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
756});
757```
758
759## notificationManager.displayBadge
760
761displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
762
763设定指定应用的角标使能状态。使用callback异步回调。
764
765**系统能力**:SystemCapability.Notification.Notification
766
767**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
768
769**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
770
771**系统接口**:此接口为系统接口。
772
773**参数:**
774
775| 参数名     | 类型                  | 必填 | 说明                 |
776| -------- | --------------------- | ---- | -------------------- |
777| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。           |
778| enable   | boolean               | 是   | 使能状态(true:使能,false:禁止)。             |
779| callback | AsyncCallback\<void\> | 是   | 设定角标使能回调函数。 |
780
781**错误码:**
782
783以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
784
785| 错误码ID | 错误信息                                 |
786| -------- | ---------------------------------------- |
787| 201      | Permission denied.     |
788| 202      | Not system application to call the interface.                                      |
789| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
790| 801 | Capability not supported. |
791| 1600001  | Internal error.                          |
792| 1600002  | Marshalling or unmarshalling error.      |
793| 1600003  | Failed to connect to the service.               |
794| 17700001 | The specified bundle name was not found. |
795
796**示例:**
797
798```ts
799import { BusinessError } from '@kit.BasicServicesKit';
800
801let displayBadgeCallback = (err: BusinessError): void => {
802    if (err) {
803        console.error(`displayBadge failed, code is ${err.code}, message is ${err.message}`);
804    } else {
805        console.info("displayBadge success");
806    }
807}
808let bundle: notificationManager.BundleOption = {
809    bundle: "bundleName1",
810};
811notificationManager.displayBadge(bundle, false, displayBadgeCallback);
812```
813
814## notificationManager.displayBadge
815
816displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
817
818设定指定应用的角标使能状态。使用Promise异步回调。
819
820**系统能力**:SystemCapability.Notification.Notification
821
822**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
823
824**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
825
826**系统接口**:此接口为系统接口。
827
828**参数:**
829
830| 参数名   | 类型         | 必填 | 说明       |
831| ------ | ------------ | ---- | ---------- |
832| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
833| enable | boolean      | 是   | 使能状态(true:使能,false:禁止)。   |
834
835**返回值:**
836
837| 类型      | 说明        |
838|---------|-----------|
839| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
840
841**错误码:**
842
843以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
844
845| 错误码ID | 错误信息                                 |
846| -------- | ---------------------------------------- |
847| 201      | Permission denied.     |
848| 202      | Not system application to call the interface.                                      |
849| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
850| 801 | Capability not supported. |
851| 1600001  | Internal error.                          |
852| 1600002  | Marshalling or unmarshalling error.      |
853| 1600003  | Failed to connect to the service.               |
854| 17700001 | The specified bundle name was not found. |
855
856**示例:**
857
858```ts
859import { BusinessError } from '@kit.BasicServicesKit';
860
861let bundle: notificationManager.BundleOption = {
862    bundle: "bundleName1",
863};
864notificationManager.displayBadge(bundle, false).then(() => {
865	console.info("displayBadge success");
866}).catch((err: BusinessError) => {
867    console.error(`displayBadge failed, code is ${err.code}, message is ${err.message}`);
868});
869```
870
871## notificationManager.isBadgeDisplayed
872
873isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
874
875获取指定应用的角标使能状态。使用callback异步回调。
876
877**系统能力**:SystemCapability.Notification.Notification
878
879**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
880
881**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
882
883**系统接口**:此接口为系统接口。
884
885**参数:**
886
887| 参数名     | 类型                  | 必填 | 说明                     |
888| -------- | --------------------- | ---- | ------------------------ |
889| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。               |
890| callback | AsyncCallback\<boolean\> | 是   | 获取角标使能状态回调函数(true:使能,false:禁止)。 |
891
892**错误码:**
893
894以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
895
896| 错误码ID | 错误信息                                 |
897| -------- | ---------------------------------------- |
898| 201      | Permission denied.     |
899| 202      | Not system application to call the interface.                                      |
900| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
901| 801 | Capability not supported. |
902| 1600001  | Internal error.                          |
903| 1600002  | Marshalling or unmarshalling error.      |
904| 1600003  | Failed to connect to the service.               |
905| 17700001 | The specified bundle name was not found. |
906
907**示例:**
908
909```ts
910import { BusinessError } from '@kit.BasicServicesKit';
911
912let isBadgeDisplayedCallback = (err: BusinessError, data: boolean): void => {
913    if (err) {
914        console.error(`isBadgeDisplayed failed, code is ${err.code}, message is ${err.message}`);
915    } else {
916        console.info(`isBadgeDisplayed success, data is ${JSON.stringify(data)}`);
917    }
918}
919let bundle: notificationManager.BundleOption = {
920    bundle: "bundleName1",
921};
922notificationManager.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
923```
924
925## notificationManager.isBadgeDisplayed
926
927isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
928
929获取指定应用的角标使能状态。使用Promise异步回调。
930
931**系统能力**:SystemCapability.Notification.Notification
932
933**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
934
935**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
936
937**系统接口**:此接口为系统接口。
938
939**参数:**
940
941| 参数名   | 类型         | 必填 | 说明       |
942| ------ | ------------ | ---- | ---------- |
943| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
944
945**返回值:**
946
947| 类型                                                        | 说明                                                         |
948| ----------------------------------------------------------- | ------------------------------------------------------------ |
949| Promise\<boolean\> | 以Promise形式返回获取指定应用的角标使能状态(true:使能,false:禁止)。 |
950
951**错误码:**
952
953以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
954
955| 错误码ID | 错误信息                                 |
956| -------- | ---------------------------------------- |
957| 201      | Permission denied.     |
958| 202      | Not system application to call the interface.                                      |
959| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
960| 801 | Capability not supported. |
961| 1600001  | Internal error.                          |
962| 1600002  | Marshalling or unmarshalling error.      |
963| 1600003  | Failed to connect to the service.               |
964| 17700001 | The specified bundle name was not found. |
965
966**示例:**
967
968```ts
969import { BusinessError } from '@kit.BasicServicesKit';
970
971let bundle: notificationManager.BundleOption = {
972  bundle: "bundleName1",
973};
974
975notificationManager.isBadgeDisplayed(bundle).then((data: boolean) => {
976	console.info(`isBadgeDisplayed success, data: ${JSON.stringify(data)}`);
977}).catch((err: BusinessError) => {
978    console.error(`isBadgeDisplayed failed, code is ${err.code}, message is ${err.message}`);
979});
980```
981
982## notificationManager.setSlotFlagsByBundle<sup>11+</sup>
983
984setSlotFlagsByBundle(bundle: BundleOption, slotFlags: number): Promise\<void\>
985
986设定指定应用的通知渠道。使用Promise异步回调。
987
988**系统能力**:SystemCapability.Notification.Notification
989
990**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
991
992**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
993
994**系统接口**:此接口为系统接口。
995
996**参数:**
997
998| 参数名   | 类型         | 必填 | 说明       |
999| ------ | ------------ | ---- | ---------- |
1000| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1001| slotFlags   | number | 是   | 通知渠道标识位。<br>- bit0:铃声提示。0表示关闭,1表示开启。 <br>- bit1:锁屏。0表示关闭,1表示开启。 <br>- bit2:横幅。0表示关闭,1表示开启。 <br>- bit3:亮屏。0表示关闭,1表示开启。 <br>- bit4:振动。0表示关闭,1表示开启。 <br>- bit5:状态栏通知图标。0表示关闭,1表示开启。 |
1002
1003**返回值:**
1004
1005| 类型      | 说明        |
1006|---------|-----------|
1007| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1008
1009**错误码:**
1010
1011以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1012
1013| 错误码ID | 错误信息                                 |
1014| -------- | ---------------------------------------- |
1015| 201      | Permission denied.     |
1016| 202      | Not system application to call the interface.                                      |
1017| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1018| 801 | Capability not supported. |
1019| 1600001  | Internal error.                          |
1020| 1600002  | Marshalling or unmarshalling error.      |
1021| 1600003  | Failed to connect to the service.               |
1022| 17700001 | The specified bundle name was not found. |
1023
1024**示例:**
1025
1026```ts
1027import { BusinessError } from '@kit.BasicServicesKit';
1028
1029let bundle: notificationManager.BundleOption = {
1030    bundle: "bundleName1",
1031};
1032
1033let slotFlags: number = 1;
1034
1035notificationManager.setSlotFlagsByBundle(bundle, slotFlags).then(() => {
1036	console.info("setSlotFlagsByBundle success");
1037}).catch((err: BusinessError) => {
1038    console.error(`setSlotFlagsByBundle failed, code is ${err.code}, message is ${err.message}`);
1039});
1040```
1041
1042## notificationManager.setSlotByBundle
1043
1044setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
1045
1046设置指定应用的通知渠道。使用callback异步回调。
1047
1048设置前需要先通过[addSlot](#notificationmanageraddslot)创建通知渠道。
1049
1050**系统能力**:SystemCapability.Notification.Notification
1051
1052**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1053
1054**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1055
1056**系统接口**:此接口为系统接口。
1057
1058**参数:**
1059
1060| 参数名     | 类型                  | 必填 | 说明                 |
1061| -------- | --------------------- | ---- | -------------------- |
1062| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。           |
1063| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)      | 是   | 通知渠道。             |
1064| callback | AsyncCallback\<void\> | 是   | 设定通知渠道回调函数。 |
1065
1066**错误码:**
1067
1068以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1069
1070| 错误码ID | 错误信息                                 |
1071| -------- | ---------------------------------------- |
1072| 201      | Permission denied.     |
1073| 202      | Not system application to call the interface.                                      |
1074| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1075| 801 | Capability not supported. |
1076| 1600001  | Internal error.                          |
1077| 1600002  | Marshalling or unmarshalling error.      |
1078| 1600003  | Failed to connect to the service.               |
1079| 17700001 | The specified bundle name was not found. |
1080
1081**示例:**
1082
1083```ts
1084import { BusinessError } from '@kit.BasicServicesKit';
1085
1086let setSlotByBundleCallback = (err: BusinessError): void => {
1087    if (err) {
1088        console.error(`setSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
1089    } else {
1090        console.info("setSlotByBundle success");
1091    }
1092}
1093let bundle: notificationManager.BundleOption = {
1094    bundle: "bundleName1",
1095};
1096let notificationSlot: notificationManager.NotificationSlot = {
1097    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
1098};
1099notificationManager.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
1100```
1101
1102## notificationManager.setSlotByBundle
1103
1104setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
1105
1106设置指定应用的通知渠道。使用Promise异步回调。
1107
1108设置前需要先通过[addSlot](#notificationmanageraddslot)创建通知渠道。
1109
1110**系统能力**:SystemCapability.Notification.Notification
1111
1112**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1113
1114**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1115
1116**系统接口**:此接口为系统接口。
1117
1118**参数:**
1119
1120| 参数名   | 类型         | 必填 | 说明       |
1121| ------ | ------------ | ---- | ---------- |
1122| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1123| slot   | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md) | 是   | 通知渠道。 |
1124
1125**返回值:**
1126
1127| 类型      | 说明        |
1128|---------|-----------|
1129| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1130
1131**错误码:**
1132
1133以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1134
1135| 错误码ID | 错误信息                                 |
1136| -------- | ---------------------------------------- |
1137| 201      | Permission denied.     |
1138| 202      | Not system application to call the interface.                                      |
1139| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1140| 801 | Capability not supported. |
1141| 1600001  | Internal error.                          |
1142| 1600002  | Marshalling or unmarshalling error.      |
1143| 1600003  | Failed to connect to the service.               |
1144| 17700001 | The specified bundle name was not found. |
1145
1146**示例:**
1147
1148```ts
1149import { BusinessError } from '@kit.BasicServicesKit';
1150
1151let bundle: notificationManager.BundleOption = {
1152    bundle: "bundleName1",
1153};
1154
1155let notificationSlot: notificationManager.NotificationSlot = {
1156    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
1157};
1158
1159notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => {
1160	console.info("setSlotByBundle success");
1161}).catch((err: BusinessError) => {
1162    console.error(`setSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
1163});
1164```
1165
1166## notificationManager.getSlotFlagsByBundle<sup>11+</sup>
1167
1168getSlotFlagsByBundle(bundle: BundleOption): Promise\<number\>
1169
1170获取指定应用的通知渠道标识位。使用Promise异步回调。
1171
1172**系统能力**:SystemCapability.Notification.Notification
1173
1174**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1175
1176**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1177
1178**系统接口**:此接口为系统接口。
1179
1180**参数:**
1181
1182| 参数名   | 类型         | 必填 | 说明       |
1183| ------ | ------------ | ---- | ---------- |
1184| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1185
1186**返回值:**
1187
1188| 类型                                                        | 说明                                                         |
1189| ----------------------------------------------------------- | ------------------------------------------------------------ |
1190|  Promise\<number\>| 以Promise形式返回获取指定应用的通知渠道标识位。<br>- bit0:铃声提示。0表示关闭,1表示开启。 <br>- bit1:锁屏。0表示关闭,1表示开启。 <br>- bit2:横幅。0表示关闭,1表示开启。 <br>- bit3:亮屏。0表示关闭,1表示开启。 <br>- bit4:振动。0表示关闭,1表示开启。 <br>- bit5:状态栏通知图标。0表示关闭,1表示开启。 |
1191
1192**错误码:**
1193
1194以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1195
1196| 错误码ID | 错误信息                                 |
1197| -------- | ---------------------------------------- |
1198| 201      | Permission denied.     |
1199| 202      | Not system application to call the interface.                                      |
1200| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1201| 801 | Capability not supported. |
1202| 1600001  | Internal error.                          |
1203| 1600002  | Marshalling or unmarshalling error.      |
1204| 1600003  | Failed to connect to the service.               |
1205| 17700001 | The specified bundle name was not found. |
1206
1207**示例:**
1208
1209```ts
1210import { BusinessError } from '@kit.BasicServicesKit';
1211
1212let bundle: notificationManager.BundleOption = {
1213    bundle: "bundleName1",
1214};
1215notificationManager.getSlotFlagsByBundle(bundle).then((data : number) => {
1216	console.info(`getSlotFlagsByBundle success, data: ${JSON.stringify(data)}`);
1217}).catch((err: BusinessError) => {
1218    console.error(`getSlotFlagsByBundle failed, code is ${err.code}, message is ${err.message}`);
1219});
1220```
1221
1222## notificationManager.getSlotsByBundle
1223
1224getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
1225
1226获取指定应用的所有通知渠道。使用callback异步回调。
1227
1228**系统能力**:SystemCapability.Notification.Notification
1229
1230**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1231
1232**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1233
1234**系统接口**:此接口为系统接口。
1235
1236**参数:**
1237
1238| 参数名     | 类型                                     | 必填 | 说明                 |
1239| -------- | ---------------------------------------- | ---- | -------------------- |
1240| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)                             | 是   | 指定应用的包信息。           |
1241| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)>> | 是   | 获取通知渠道回调函数。 |
1242
1243**错误码:**
1244
1245以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1246
1247| 错误码ID | 错误信息                                 |
1248| -------- | ---------------------------------------- |
1249| 201      | Permission denied.     |
1250| 202      | Not system application to call the interface.                                      |
1251| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1252| 801 | Capability not supported. |
1253| 1600001  | Internal error.                          |
1254| 1600002  | Marshalling or unmarshalling error.      |
1255| 1600003  | Failed to connect to the service.               |
1256| 17700001 | The specified bundle name was not found. |
1257
1258**示例:**
1259
1260```ts
1261import { BusinessError } from '@kit.BasicServicesKit';
1262
1263let getSlotsByBundleCallback = (err: BusinessError, data: Array<notificationManager.NotificationSlot>): void => {
1264    if (err) {
1265        console.error(`getSlotsByBundle failed, code is ${err.code}, message is ${err.message}`);
1266    } else {
1267        console.info(`getSlotsByBundle success, data is ${JSON.stringify(data)}`);
1268    }
1269}
1270let bundle: notificationManager.BundleOption = {
1271    bundle: "bundleName1",
1272};
1273notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback);
1274```
1275
1276## notificationManager.getSlotsByBundle
1277
1278getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
1279
1280获取指定应用的所有通知渠道。使用Promise异步回调。
1281
1282**系统能力**:SystemCapability.Notification.Notification
1283
1284**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1285
1286**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1287
1288**系统接口**:此接口为系统接口。
1289
1290**参数:**
1291
1292| 参数名   | 类型         | 必填 | 说明       |
1293| ------ | ------------ | ---- | ---------- |
1294| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1295
1296**返回值:**
1297
1298| 类型                                                        | 说明                                                         |
1299| ----------------------------------------------------------- | ------------------------------------------------------------ |
1300| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)>> | 以Promise形式返回获取指定应用的通知渠道。 |
1301
1302**错误码:**
1303
1304以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1305
1306| 错误码ID | 错误信息                                 |
1307| -------- | ---------------------------------------- |
1308| 201      | Permission denied.     |
1309| 202      | Not system application to call the interface.                                      |
1310| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1311| 801 | Capability not supported. |
1312| 1600001  | Internal error.                          |
1313| 1600002  | Marshalling or unmarshalling error.      |
1314| 1600003  | Failed to connect to the service.               |
1315| 17700001 | The specified bundle name was not found. |
1316
1317**示例:**
1318
1319```ts
1320import { BusinessError } from '@kit.BasicServicesKit';
1321
1322let bundle: notificationManager.BundleOption = {
1323    bundle: "bundleName1",
1324};
1325
1326notificationManager.getSlotsByBundle(bundle).then((data: Array<notificationManager.NotificationSlot>) => {
1327	console.info(`getSlotsByBundle success, data: ${JSON.stringify(data)}`);
1328}).catch((err: BusinessError) => {
1329    console.error(`getSlotsByBundle failed, code is ${err.code}, message is ${err.message}`);
1330});
1331```
1332
1333## notificationManager.getSlotNumByBundle
1334
1335getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
1336
1337获取指定应用的通知渠道数量。使用callback异步回调。
1338
1339**系统能力**:SystemCapability.Notification.Notification
1340
1341**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1342
1343**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1344
1345**系统接口**:此接口为系统接口。
1346
1347**参数:**
1348
1349| 参数名     | 类型                      | 必填 | 说明                   |
1350| -------- | ------------------------- | ---- | ---------------------- |
1351| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)              | 是   | 指定应用的包信息。             |
1352| callback | AsyncCallback\<number\> | 是   | 获取通知渠道数量回调函数。 |
1353
1354**错误码:**
1355
1356以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1357
1358| 错误码ID | 错误信息                                 |
1359| -------- | ---------------------------------------- |
1360| 201      | Permission denied.     |
1361| 202      | Not system application to call the interface.                                      |
1362| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1363| 801 | Capability not supported. |
1364| 1600001  | Internal error.                          |
1365| 1600002  | Marshalling or unmarshalling error.      |
1366| 1600003  | Failed to connect to the service.               |
1367| 17700001 | The specified bundle name was not found. |
1368
1369**示例:**
1370
1371```ts
1372import { BusinessError } from '@kit.BasicServicesKit';
1373
1374let getSlotNumByBundleCallback = (err: BusinessError, data: number): void => {
1375    if (err) {
1376        console.error(`getSlotNumByBundle failed, code is ${err.code}, message is ${err.message}`);
1377    } else {
1378        console.info(`getSlotNumByBundle success data is ${JSON.stringify(data)}`);
1379    }
1380}
1381
1382let bundle: notificationManager.BundleOption = {
1383  bundle: "bundleName1",
1384};
1385
1386notificationManager.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
1387```
1388
1389## notificationManager.getSlotNumByBundle
1390
1391getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
1392
1393获取指定应用的通知渠道数量。使用Promise异步回调。
1394
1395**系统能力**:SystemCapability.Notification.Notification
1396
1397**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1398
1399**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1400
1401**系统接口**:此接口为系统接口。
1402
1403**参数:**
1404
1405| 参数名   | 类型         | 必填 | 说明       |
1406| ------ | ------------ | ---- | ---------- |
1407| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1408
1409**返回值:**
1410
1411| 类型                                                        | 说明                                                         |
1412| ----------------------------------------------------------- | ------------------------------------------------------------ |
1413| Promise\<number\> | 以Promise形式返回获取指定应用的通知渠道数量。 |
1414
1415**错误码:**
1416
1417以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1418
1419| 错误码ID | 错误信息                                 |
1420| -------- | ---------------------------------------- |
1421| 201      | Permission denied.     |
1422| 202      | Not system application to call the interface.                                      |
1423| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1424| 801 | Capability not supported. |
1425| 1600001  | Internal error.                          |
1426| 1600002  | Marshalling or unmarshalling error.      |
1427| 1600003  | Failed to connect to the service.               |
1428| 17700001 | The specified bundle name was not found. |
1429
1430**示例:**
1431
1432```ts
1433import { BusinessError } from '@kit.BasicServicesKit';
1434
1435let bundle: notificationManager.BundleOption = {
1436  bundle: "bundleName1",
1437};
1438
1439notificationManager.getSlotNumByBundle(bundle).then((data: number) => {
1440	console.info(`getSlotNumByBundle success, data: ${JSON.stringify(data)}`);
1441}).catch((err: BusinessError) => {
1442    console.error(`getSlotNumByBundle failed, code is ${err.code}, message is ${err.message}`);
1443});
1444```
1445
1446
1447## notificationManager.getAllActiveNotifications
1448
1449getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
1450
1451获取当前未删除的所有通知。使用callback异步回调。
1452
1453**系统能力**:SystemCapability.Notification.Notification
1454
1455**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1456
1457**系统接口**:此接口为系统接口。
1458
1459**参数:**
1460
1461| 参数名     | 类型                                                         | 必填 | 说明                 |
1462| -------- | ------------------------------------------------------------ | ---- | -------------------- |
1463| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)>> | 是   | 获取活动通知回调函数。 |
1464
1465**错误码:**
1466
1467以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1468
1469| 错误码ID | 错误信息                            |
1470| -------- | ----------------------------------- |
1471| 201      | Permission denied.     |
1472| 202      | Not system application to call the interface.                                      |
1473| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1474| 1600001  | Internal error.                     |
1475| 1600002  | Marshalling or unmarshalling error. |
1476| 1600003  | Failed to connect to the service.          |
1477
1478**示例:**
1479
1480```ts
1481import { BusinessError } from '@kit.BasicServicesKit';
1482
1483let getAllActiveNotificationsCallback = (err: BusinessError, data: Array<notificationManager.NotificationRequest>): void => {
1484    if (err) {
1485        console.error(`getAllActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
1486    } else {
1487        console.info(`getAllActiveNotifications success, data is ${JSON.stringify(data)}`);
1488    }
1489}
1490
1491notificationManager.getAllActiveNotifications(getAllActiveNotificationsCallback);
1492```
1493
1494## notificationManager.getAllActiveNotifications
1495
1496getAllActiveNotifications(): Promise\<Array\<NotificationRequest\>\>
1497
1498获取当前未删除的所有通知。使用Promise异步回调。
1499
1500**系统能力**:SystemCapability.Notification.Notification
1501
1502**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1503
1504**系统接口**:此接口为系统接口。
1505
1506**返回值:**
1507
1508| 类型                                                        | 说明                                                         |
1509| ----------------------------------------------------------- | ------------------------------------------------------------ |
1510| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)\>\> | 以Promise形式返回获取活动通知。 |
1511
1512**错误码:**
1513
1514以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1515
1516| 错误码ID | 错误信息                            |
1517| -------- | ----------------------------------- |
1518| 201      | Permission denied.     |
1519| 202      | Not system application to call the interface.                                      |
1520| 1600001  | Internal error.                     |
1521| 1600002  | Marshalling or unmarshalling error. |
1522| 1600003  | Failed to connect to the service.          |
1523
1524**示例:**
1525
1526```ts
1527import { BusinessError } from '@kit.BasicServicesKit';
1528
1529notificationManager.getAllActiveNotifications().then((data: Array<notificationManager.NotificationRequest>) => {
1530	console.info(`getAllActiveNotifications success, data: ${JSON.stringify(data)}`);
1531}).catch((err: BusinessError) => {
1532    console.error(`getAllActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
1533});
1534```
1535
1536## notificationManager.getActiveNotificationByFilter<sup>11+</sup>
1537
1538getActiveNotificationByFilter(filter: NotificationFilter, callback: AsyncCallback\<NotificationRequest\>): void
1539
1540获取满足条件的普通实况通知信息。使用callback异步回调。
1541
1542**系统能力**:SystemCapability.Notification.Notification
1543
1544**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1545
1546**系统接口**:此接口为系统接口。
1547
1548
1549**参数:**
1550
1551| 参数名     | 类型                                                         | 必填 | 说明                           |
1552| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
1553| filter   | [NotificationFilter](js-apis-inner-notification-notificationRequest-sys.md#notificationfilter11) | 是   | 查询普通实况窗的过滤条件。 |
1554| callback | AsyncCallback\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)> | 是   | 获取满足条件的普通实况通知信息的回调函数。 |
1555
1556**错误码:**
1557
1558以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1559
1560| 错误码ID | 错误信息                                  |
1561| -------- | ---------------------------------------- |
1562| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1563| 1600007  | The notification does not exist.           |
1564| 17700001 | The specified bundle name was not found. |
1565
1566**示例:**
1567
1568```ts
1569import { BusinessError } from '@kit.BasicServicesKit';
1570import { notificationSubscribe } from '@kit.NotificationKit';
1571
1572let bundleOption: notificationManager.BundleOption = {
1573  bundle: "bundleName1",
1574};
1575let notificationKey: notificationSubscribe.NotificationKey = {
1576    id: 11,
1577    label: ""
1578};
1579let filter: notificationManager.NotificationFilter = {
1580    bundle: bundleOption,
1581    notificationKey: notificationKey,
1582    extraInfoKeys: ['event']
1583}
1584let getActiveNotificationByFilterCallback = (err: BusinessError, data: notificationManager.NotificationRequest): void => {
1585    if (err) {
1586        console.error(`getActiveNotificationByFilter failed, code is ${err.code}, message is ${err.message}`);
1587    } else {
1588        console.info("getActiveNotificationByFilter success");
1589    }
1590}
1591notificationManager.getActiveNotificationByFilter(filter, getActiveNotificationByFilterCallback);
1592```
1593
1594## notificationManager.getActiveNotificationByFilter<sup>11+</sup>
1595
1596getActiveNotificationByFilter(filter: NotificationFilter): Promise\<NotificationRequest\>
1597
1598获取满足条件的普通实况通知信息。使用Promise异步回调。
1599
1600**系统能力**:SystemCapability.Notification.Notification
1601
1602**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1603
1604**系统接口**:此接口为系统接口。
1605
1606
1607**参数:**
1608
1609| 参数名     | 类型                                                         | 必填 | 说明                           |
1610| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
1611| filter   | [NotificationFilter](js-apis-inner-notification-notificationRequest-sys.md#notificationfilter11) | 是   | 查询普通实况窗的过滤条件。 |
1612
1613**返回值:**
1614
1615| 类型                                                         | 说明                                    |
1616| ------------------------------------------------------------ | --------------------------------------- |
1617| Promise\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)\> | 以Promise形式返回获取的满足条件的普通实况通知信息。 |
1618
1619**错误码:**
1620
1621以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1622
1623| 错误码ID | 错误信息                                  |
1624| -------- | ---------------------------------------- |
1625| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1626| 1600007  | The notification does not exist.         |
1627| 17700001 | The specified bundle name was not found. |
1628
1629**示例:**
1630
1631```ts
1632import { BusinessError } from '@kit.BasicServicesKit';
1633import { notificationSubscribe } from '@kit.NotificationKit';
1634
1635let bundleOption: notificationManager.BundleOption = {
1636  bundle: "bundleName1",
1637};
1638let notificationKey: notificationSubscribe.NotificationKey = {
1639    id: 11,
1640    label: ""
1641};
1642let filter: notificationManager.NotificationFilter = {
1643    bundle: bundleOption,
1644    notificationKey: notificationKey,
1645    extraInfoKeys: ['event']
1646}
1647notificationManager.getActiveNotificationByFilter(filter).then((data: notificationManager.NotificationRequest) => {
1648	console.info(`getActiveNotificationByFilter success, data: ${JSON.stringify(data)}`);
1649}).catch((err: BusinessError) => {
1650    console.error(`getActiveNotificationByFilter failed, code is ${err.code}, message is ${err.message}`);
1651});
1652```
1653
1654## notificationManager.removeGroupByBundle
1655
1656removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
1657
1658删除指定应用的指定组下的通知。使用callback异步回调。
1659
1660**系统能力**:SystemCapability.Notification.Notification
1661
1662**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1663
1664**系统接口**:此接口为系统接口。
1665
1666**参数:**
1667
1668| 参数名      | 类型                  | 必填 | 说明                         |
1669| --------- | --------------------- | ---- | ---------------------------- |
1670| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 应用的包信息。                   |
1671| groupName | string                | 是   | 通知组名称。               |
1672| callback  | AsyncCallback\<void\> | 是   | 删除指定应用指定组下通知的回调函数。 |
1673
1674**错误码:**
1675
1676以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1677
1678| 错误码ID | 错误信息                                 |
1679| -------- | ---------------------------------------- |
1680| 201      | Permission denied.     |
1681| 202      | Not system application to call the interface.                                      |
1682| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1683| 1600001  | Internal error.                          |
1684| 1600002  | Marshalling or unmarshalling error.      |
1685| 1600003  | Failed to connect to the service.               |
1686| 17700001 | The specified bundle name was not found. |
1687
1688**示例:**
1689
1690```ts
1691import { BusinessError } from '@kit.BasicServicesKit';
1692
1693let removeGroupByBundleCallback = (err: BusinessError): void => {
1694    if (err) {
1695        console.error(`removeGroupByBundle failed, code is ${err.code}, message is ${err.message}`);
1696    } else {
1697        console.info("removeGroupByBundle success");
1698    }
1699}
1700
1701let bundleOption: notificationManager.BundleOption = { bundle: "Bundle" };
1702let groupName: string = "GroupName";
1703
1704notificationManager.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
1705```
1706
1707## notificationManager.removeGroupByBundle
1708
1709removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
1710
1711删除指定应用的指定组下的通知。使用Promise异步回调。
1712
1713**系统能力**:SystemCapability.Notification.Notification
1714
1715**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1716
1717**系统接口**:此接口为系统接口。
1718
1719**参数:**
1720
1721| 参数名      | 类型         | 必填 | 说明           |
1722| --------- | ------------ | ---- | -------------- |
1723| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。     |
1724| groupName | string       | 是   | 通知组名称。 |
1725
1726**返回值:**
1727
1728| 类型      | 说明        |
1729|---------|-----------|
1730| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1731
1732**错误码:**
1733
1734以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
1735
1736| 错误码ID | 错误信息                                 |
1737| -------- | ---------------------------------------- |
1738| 201      | Permission denied.     |
1739| 202      | Not system application to call the interface.                                      |
1740| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1741| 1600001  | Internal error.                          |
1742| 1600002  | Marshalling or unmarshalling error.      |
1743| 1600003  | Failed to connect to the service.               |
1744| 17700001 | The specified bundle name was not found. |
1745
1746**示例:**
1747
1748```ts
1749import { BusinessError } from '@kit.BasicServicesKit';
1750
1751let bundleOption: notificationManager.BundleOption = { bundle: "Bundle" };
1752let groupName: string = "GroupName";
1753
1754notificationManager.removeGroupByBundle(bundleOption, groupName).then(() => {
1755	console.info("removeGroupByBundle success");
1756}).catch((err: BusinessError) => {
1757    console.error(`removeGroupByBundle failed, code is ${err.code}, message is ${err.message}`);
1758});
1759```
1760
1761## notificationManager.setDoNotDisturbDate
1762
1763setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
1764
1765设置免打扰时间。使用callback异步回调。
1766
1767**系统能力**:SystemCapability.Notification.Notification
1768
1769**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
1770
1771**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1772
1773**系统接口**:此接口为系统接口。
1774
1775**参数:**
1776
1777| 参数名     | 类型                  | 必填 | 说明                   |
1778| -------- | --------------------- | ---- | ---------------------- |
1779| date     | [DoNotDisturbDate](#donotdisturbdate)      | 是   | 免打扰时间选项。         |
1780| callback | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |
1781
1782**错误码:**
1783
1784以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1785
1786| 错误码ID | 错误信息                            |
1787| -------- | ----------------------------------- |
1788| 201      | Permission denied.     |
1789| 202      | Not system application to call the interface.                                      |
1790| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1791| 801 | Capability not supported. |
1792| 1600001  | Internal error.                     |
1793| 1600002  | Marshalling or unmarshalling error. |
1794| 1600003  | Failed to connect to the service.          |
1795| 1600012  | No memory space.                          |
1796
1797**示例:**
1798
1799```ts
1800import { BusinessError } from '@kit.BasicServicesKit';
1801
1802let setDoNotDisturbDateCallback = (err: BusinessError): void => {
1803    if (err) {
1804        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
1805    } else {
1806        console.info("setDoNotDisturbDate success");
1807    }
1808}
1809
1810let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1811    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1812    begin: new Date(),
1813    end: new Date(2021, 11, 15, 18, 0)
1814};
1815
1816notificationManager.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
1817```
1818
1819## notificationManager.setDoNotDisturbDate
1820
1821setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
1822
1823设置免打扰时间。使用Promise异步回调。
1824
1825**系统能力**:SystemCapability.Notification.Notification
1826
1827**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
1828
1829**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1830
1831**系统接口**:此接口为系统接口。
1832
1833**参数:**
1834
1835| 参数名 | 类型             | 必填 | 说明           |
1836| ---- | ---------------- | ---- | -------------- |
1837| date | [DoNotDisturbDate](#donotdisturbdate) | 是   | 免打扰时间选项。 |
1838
1839
1840**返回值:**
1841
1842| 类型      | 说明        |
1843|---------|-----------|
1844| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1845
1846**错误码:**
1847
1848以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1849
1850| 错误码ID | 错误信息                            |
1851| -------- | ----------------------------------- |
1852| 201      | Permission denied.     |
1853| 202      | Not system application to call the interface.                                      |
1854| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1855| 801 | Capability not supported. |
1856| 1600001  | Internal error.                     |
1857| 1600002  | Marshalling or unmarshalling error. |
1858| 1600003  | Failed to connect to the service.          |
1859| 1600012  | No memory space.                          |
1860
1861**示例:**
1862
1863```ts
1864import { BusinessError } from '@kit.BasicServicesKit';
1865
1866let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1867    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1868    begin: new Date(),
1869    end: new Date(2021, 11, 15, 18, 0)
1870};
1871notificationManager.setDoNotDisturbDate(doNotDisturbDate).then(() => {
1872	console.info("setDoNotDisturbDate success");
1873}).catch((err: BusinessError) => {
1874    console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
1875});
1876```
1877
1878
1879## notificationManager.setDoNotDisturbDate
1880
1881setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void
1882
1883指定用户设置免打扰时间。使用callback异步回调。
1884
1885**系统能力**:SystemCapability.Notification.Notification
1886
1887**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
1888
1889**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1890
1891**系统接口**:此接口为系统接口。
1892
1893**参数:**
1894
1895| 参数名     | 类型                  | 必填 | 说明                   |
1896| -------- | --------------------- | ---- | ---------------------- |
1897| date     | [DoNotDisturbDate](#donotdisturbdate)      | 是   | 免打扰时间选项。         |
1898| userId   | number                | 是   | 设置免打扰时间的用户ID。 |
1899| callback | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |
1900
1901**错误码:**
1902
1903以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1904
1905| 错误码ID | 错误信息                            |
1906| -------- | ----------------------------------- |
1907| 201      | Permission denied.     |
1908| 202      | Not system application to call the interface.                                      |
1909| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1910| 801 | Capability not supported. |
1911| 1600001  | Internal error.                     |
1912| 1600002  | Marshalling or unmarshalling error. |
1913| 1600003  | Failed to connect to the service.          |
1914| 1600008  | The user does not exist.              |
1915| 1600012  | No memory space.                          |
1916
1917**示例:**
1918
1919```ts
1920import { BusinessError } from '@kit.BasicServicesKit';
1921
1922let setDoNotDisturbDateCallback = (err: BusinessError): void => {
1923    if (err) {
1924        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
1925    } else {
1926        console.info("setDoNotDisturbDate success");
1927    }
1928}
1929
1930let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1931    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1932    begin: new Date(),
1933    end: new Date(2021, 11, 15, 18, 0)
1934};
1935
1936// 用户ID,使用时需替换为真实的userId。
1937let userId: number = 1;
1938
1939notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
1940```
1941
1942## notificationManager.setDoNotDisturbDate
1943
1944setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
1945
1946指定用户设置免打扰时间。使用Promise异步回调。
1947
1948**系统能力**:SystemCapability.Notification.Notification
1949
1950**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
1951
1952**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1953
1954**系统接口**:此接口为系统接口。
1955
1956**参数:**
1957
1958| 参数名   | 类型             | 必填 | 说明           |
1959| ------ | ---------------- | ---- | -------------- |
1960| date   | [DoNotDisturbDate](#donotdisturbdate) | 是   | 免打扰时间选项。 |
1961| userId | number           | 是   | 设置免打扰时间的用户ID。 |
1962
1963**返回值:**
1964
1965| 类型      | 说明        |
1966|---------|-----------|
1967| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1968
1969**错误码:**
1970
1971以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1972
1973| 错误码ID | 错误信息                            |
1974| -------- | ----------------------------------- |
1975| 201      | Permission denied.     |
1976| 202      | Not system application to call the interface.                                      |
1977| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1978| 801 | Capability not supported. |
1979| 1600001  | Internal error.                     |
1980| 1600002  | Marshalling or unmarshalling error. |
1981| 1600003  | Failed to connect to the service.          |
1982| 1600008  | The user does not exist.              |
1983| 1600012  | No memory space.                          |
1984
1985**示例:**
1986
1987```ts
1988import { BusinessError } from '@kit.BasicServicesKit';
1989
1990let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1991    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1992    begin: new Date(),
1993    end: new Date(2021, 11, 15, 18, 0)
1994};
1995
1996// 用户ID,使用时需替换为真实的userId。
1997let userId: number = 1;
1998
1999notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
2000	console.info("setDoNotDisturbDate success");
2001}).catch((err: BusinessError) => {
2002    console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2003});
2004```
2005
2006
2007## notificationManager.getDoNotDisturbDate
2008
2009getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
2010
2011查询免打扰时间。使用callback异步回调。
2012
2013**系统能力**:SystemCapability.Notification.Notification
2014
2015**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2016
2017**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2018
2019**系统接口**:此接口为系统接口。
2020
2021**参数:**
2022
2023| 参数名     | 类型                              | 必填 | 说明                   |
2024| -------- | --------------------------------- | ---- | ---------------------- |
2025| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是   | 查询免打扰时间回调函数。 |
2026
2027**错误码:**
2028
2029以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2030
2031| 错误码ID | 错误信息                            |
2032| -------- | ----------------------------------- |
2033| 201      | Permission denied.     |
2034| 202      | Not system application to call the interface.                                      |
2035| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2036| 801 | Capability not supported. |
2037| 1600001  | Internal error.                     |
2038| 1600002  | Marshalling or unmarshalling error. |
2039| 1600003  | Failed to connect to the service.          |
2040| 1600012  | No memory space.                          |
2041
2042**示例:**
2043
2044```ts
2045import { BusinessError } from '@kit.BasicServicesKit';
2046
2047let getDoNotDisturbDateCallback = (err: BusinessError, data: notificationManager.DoNotDisturbDate): void => {
2048    if (err) {
2049        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2050    } else {
2051        console.info(`getDoNotDisturbDate success, data is ${JSON.stringify(data)}`);
2052    }
2053}
2054
2055notificationManager.getDoNotDisturbDate(getDoNotDisturbDateCallback);
2056```
2057
2058## notificationManager.getDoNotDisturbDate
2059
2060getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
2061
2062查询免打扰时间。使用Promise异步回调。
2063
2064**系统能力**:SystemCapability.Notification.Notification
2065
2066**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2067
2068**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2069
2070**系统接口**:此接口为系统接口。
2071
2072**返回值:**
2073
2074| 类型                                             | 说明                                      |
2075| ------------------------------------------------ | ----------------------------------------- |
2076| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
2077
2078**错误码:**
2079
2080以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2081
2082| 错误码ID | 错误信息                            |
2083| -------- | ----------------------------------- |
2084| 201      | Permission denied.     |
2085| 202      | Not system application to call the interface.                                      |
2086| 801 | Capability not supported. |
2087| 1600001  | Internal error.                     |
2088| 1600002  | Marshalling or unmarshalling error. |
2089| 1600003  | Failed to connect to the service.          |
2090| 1600012  | No memory space.                          |
2091
2092**示例:**
2093
2094```ts
2095import { BusinessError } from '@kit.BasicServicesKit';
2096
2097notificationManager.getDoNotDisturbDate().then((data: notificationManager.DoNotDisturbDate) => {
2098  console.info(`getDoNotDisturbDate success, data: ${JSON.stringify(data)}`);
2099}).catch((err: BusinessError) => {
2100    console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2101});
2102```
2103
2104
2105## notificationManager.getDoNotDisturbDate
2106
2107getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
2108
2109查询指定用户的免打扰时间。使用callback异步回调。
2110
2111**系统能力**:SystemCapability.Notification.Notification
2112
2113**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2114
2115**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2116
2117**系统接口**:此接口为系统接口。
2118
2119**参数:**
2120
2121| 参数名     | 类型                              | 必填 | 说明                   |
2122| -------- | --------------------------------- | ---- | ---------------------- |
2123| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是   | 查询免打扰时间回调函数。 |
2124| userId   | number                            | 是   | 用户ID。 |
2125
2126**错误码:**
2127
2128以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2129
2130| 错误码ID | 错误信息                            |
2131| -------- | ----------------------------------- |
2132| 201      | Permission denied.     |
2133| 202      | Not system application to call the interface.                                      |
2134| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2135| 801 | Capability not supported. |
2136| 1600001  | Internal error.                     |
2137| 1600002  | Marshalling or unmarshalling error. |
2138| 1600003  | Failed to connect to the service.          |
2139| 1600008  | The user does not exist.              |
2140| 1600012  | No memory space.                          |
2141
2142**示例:**
2143
2144```ts
2145import { BusinessError } from '@kit.BasicServicesKit';
2146
2147let getDoNotDisturbDateCallback = (err: BusinessError, data: notificationManager.DoNotDisturbDate): void => {
2148    if (err) {
2149        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2150    } else {
2151        console.info(`getDoNotDisturbDate success, data is ${JSON.stringify(data)}`);
2152    }
2153}
2154
2155// 用户ID,使用时需替换为真实的userId。
2156let userId: number = 1;
2157
2158notificationManager.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
2159```
2160
2161## notificationManager.getDoNotDisturbDate
2162
2163getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
2164
2165查询指定用户的免打扰时间。使用Promise异步回调。
2166
2167**系统能力**:SystemCapability.Notification.Notification
2168
2169**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2170
2171**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2172
2173**系统接口**:此接口为系统接口。
2174
2175**参数:**
2176
2177| 参数名     | 类型                              | 必填 | 说明                   |
2178| -------- | --------------------------------- | ---- | ---------------------- |
2179| userId   | number                            | 是   | 用户ID。 |
2180
2181**返回值:**
2182
2183| 类型                                             | 说明                                      |
2184| ------------------------------------------------ | ----------------------------------------- |
2185| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
2186
2187**错误码:**
2188
2189以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2190
2191| 错误码ID | 错误信息                            |
2192| -------- | ----------------------------------- |
2193| 201      | Permission denied.     |
2194| 202      | Not system application to call the interface.                                      |
2195| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2196| 801 | Capability not supported. |
2197| 1600001  | Internal error.                     |
2198| 1600002  | Marshalling or unmarshalling error. |
2199| 1600003  | Failed to connect to the service.          |
2200| 1600008  | The user does not exist.              |
2201| 1600012  | No memory space.                          |
2202
2203**示例:**
2204
2205```ts
2206import { BusinessError } from '@kit.BasicServicesKit';
2207
2208// 用户ID,使用时需替换为真实的userId。
2209let userId: number = 1;
2210
2211notificationManager.getDoNotDisturbDate(userId).then((data: notificationManager.DoNotDisturbDate) => {
2212	console.info(`getDoNotDisturbDate success, data: ${JSON.stringify(data)}`);
2213}).catch((err: BusinessError) => {
2214    console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2215});
2216```
2217
2218
2219## notificationManager.isSupportDoNotDisturbMode
2220
2221 isSupportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
2222
2223查询是否支持免打扰功能。使用callback异步回调。
2224
2225**系统能力**:SystemCapability.Notification.Notification
2226
2227**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2228
2229**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2230
2231**系统接口**:此接口为系统接口。
2232
2233**参数:**
2234
2235| 参数名     | 类型                     | 必填 | 说明                             |
2236| -------- | ------------------------ | ---- | -------------------------------- |
2237| callback | AsyncCallback\<boolean\> | 是   | 查询是否支持免打扰功能回调函数(true:支持,false:不支持)。 |
2238
2239**错误码:**
2240
2241以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2242
2243| 错误码ID | 错误信息                             |
2244| -------- | ----------------------------------- |
2245| 201      | Permission denied.     |
2246| 202      | Not system application to call the interface.                                      |
2247| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2248| 801 | Capability not supported. |
2249| 1600001  | Internal error.                     |
2250| 1600002  | Marshalling or unmarshalling error. |
2251| 1600003  | Failed to connect to the service.          |
2252
2253**示例:**
2254
2255```ts
2256import { BusinessError } from '@kit.BasicServicesKit';
2257
2258let isSupportDoNotDisturbModeCallback = (err: BusinessError, data: boolean): void => {
2259    if (err) {
2260        console.error(`isSupportDoNotDisturbMode failed, code is ${err.code}, message is ${err.message}`);
2261    } else {
2262        console.info(`isSupportDoNotDisturbMode success, data: ${JSON.stringify(data)}`);
2263    }
2264}
2265
2266notificationManager.isSupportDoNotDisturbMode(isSupportDoNotDisturbModeCallback);
2267```
2268
2269## notificationManager.isSupportDoNotDisturbMode
2270
2271isSupportDoNotDisturbMode(): Promise\<boolean\>
2272
2273查询是否支持免打扰功能。使用Promise异步回调。
2274
2275**系统能力**:SystemCapability.Notification.Notification
2276
2277**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2278
2279**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2280
2281**系统接口**:此接口为系统接口。
2282
2283**返回值:**
2284
2285| 类型                                                        | 说明                                                         |
2286| ----------------------------------------------------------- | ------------------------------------------------------------ |
2287| Promise\<boolean\> | 以Promise形式返回获取是否支持免打扰功能的结果(true:支持,false:不支持)。 |
2288
2289**错误码:**
2290
2291以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2292
2293| 错误码ID | 错误信息                            |
2294| -------- | ----------------------------------- |
2295| 201      | Permission denied.     |
2296| 202      | Not system application to call the interface.                                      |
2297| 801 | Capability not supported. |
2298| 1600001  | Internal error.                     |
2299| 1600002  | Marshalling or unmarshalling error. |
2300| 1600003  | Failed to connect to the service.          |
2301
2302**示例:**
2303
2304```ts
2305import { BusinessError } from '@kit.BasicServicesKit';
2306
2307notificationManager.isSupportDoNotDisturbMode().then((data: boolean) => {
2308	console.info(`isSupportDoNotDisturbMode success, data: ${JSON.stringify(data)}`);
2309}).catch((err: BusinessError) => {
2310    console.error(`isSupportDoNotDisturbMode failed, code is ${err.code}, message is ${err.message}`);
2311});
2312```
2313
2314## notificationManager.setDistributedEnable
2315
2316setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
2317
2318设置设备是否支持分布式通知。使用callback异步回调。
2319
2320**系统能力**:SystemCapability.Notification.Notification
2321
2322**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2323
2324**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2325
2326**系统接口**:此接口为系统接口。
2327
2328**参数:**
2329
2330| 参数名   | 类型                     | 必填 | 说明                       |
2331| -------- | ------------------------ | ---- | -------------------------- |
2332| enable   | boolean                  | 是   | 是否支持(true:支持,false:不支持)。 |
2333| callback | AsyncCallback\<void\> | 是   | 设置设备是否支持分布式通知的回调函数。 |
2334
2335**错误码:**
2336
2337以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2338
2339| 错误码ID | 错误信息                            |
2340| -------- | ----------------------------------- |
2341| 201      | Permission denied.     |
2342| 202      | Not system application to call the interface.                                      |
2343| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2344| 801 | Capability not supported. |
2345| 1600001  | Internal error.                     |
2346| 1600002  | Marshalling or unmarshalling error. |
2347| 1600003  | Failed to connect to the service.          |
2348| 1600010  | Distributed operation failed.       |
2349
2350**示例:**
2351
2352```ts
2353import { BusinessError } from '@kit.BasicServicesKit';
2354
2355let setDistributedEnableCallback = (err: BusinessError): void => {
2356    if (err) {
2357        console.error(`setDistributedEnable failed, code is ${err.code}, message is ${err.message}`);
2358    } else {
2359        console.info("setDistributedEnable success");
2360    }
2361};
2362let enable: boolean = true;
2363notificationManager.setDistributedEnable(enable, setDistributedEnableCallback);
2364```
2365
2366## notificationManager.setDistributedEnable
2367
2368setDistributedEnable(enable: boolean): Promise\<void>
2369
2370设置设备是否支持分布式通知。使用Promise异步回调。
2371
2372**系统能力**:SystemCapability.Notification.Notification
2373
2374**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2375
2376**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2377
2378**系统接口**:此接口为系统接口。
2379
2380**参数:**
2381
2382| 参数名   | 类型                     | 必填 | 说明                       |
2383| -------- | ------------------------ | ---- | -------------------------- |
2384| enable   | boolean                  | 是   | 是否支持(true:支持,false:不支持)。 |
2385
2386**返回值:**
2387
2388| 类型              | 说明        |
2389|-----------------|-----------|
2390| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
2391
2392**错误码:**
2393
2394以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2395
2396| 错误码ID | 错误信息                            |
2397| -------- | ----------------------------------- |
2398| 201      | Permission denied.     |
2399| 202      | Not system application to call the interface.                                      |
2400| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2401| 801 | Capability not supported. |
2402| 1600001  | Internal error.                     |
2403| 1600002  | Marshalling or unmarshalling error. |
2404| 1600003  | Failed to connect to the service.          |
2405| 1600010  | Distributed operation failed.       |
2406
2407**示例:**
2408
2409```ts
2410import { BusinessError } from '@kit.BasicServicesKit';
2411
2412let enable: boolean = true;
2413notificationManager.setDistributedEnable(enable).then(() => {
2414    console.info("setDistributedEnable success");
2415}).catch((err: BusinessError) => {
2416    console.error(`setDistributedEnable failed, code is ${err.code}, message is ${err.message}`);
2417});
2418```
2419
2420## notificationManager.setDistributedEnableByBundle
2421
2422setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
2423
2424设置指定应用是否支持分布式通知。使用callback异步回调。
2425
2426**系统能力**:SystemCapability.Notification.Notification
2427
2428**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2429
2430**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2431
2432**系统接口**:此接口为系统接口。
2433
2434**参数:**
2435
2436| 参数名   | 类型                     | 必填 | 说明                       |
2437| -------- | ------------------------ | ---- | -------------------------- |
2438| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包信息。                   |
2439| enable   | boolean                  | 是   | 指定应用是否支持分布式通知(true:支持,false:不支持)。|
2440| callback | AsyncCallback\<void\> | 是   | 应用程序是否支持分布式通知的回调函数。 |
2441
2442**错误码:**
2443
2444以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
2445
2446| 错误码ID | 错误信息                                 |
2447| -------- | ---------------------------------------- |
2448| 201      | Permission denied.     |
2449| 202      | Not system application to call the interface.                                      |
2450| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2451| 801 | Capability not supported. |
2452| 1600001  | Internal error.                          |
2453| 1600002  | Marshalling or unmarshalling error.      |
2454| 1600003  | Failed to connect to the service.               |
2455| 1600010  | Distributed operation failed.            |
2456| 17700001 | The specified bundle name was not found. |
2457
2458**示例:**
2459
2460```ts
2461import { BusinessError } from '@kit.BasicServicesKit';
2462
2463let setDistributedEnableByBundleCallback = (err: BusinessError): void => {
2464    if (err) {
2465        console.error(`setDistributedEnableByBundle failed, code is ${err.code}, message is ${err.message}`);
2466    } else {
2467        console.info("setDistributedEnableByBundle success");
2468    }
2469};
2470let bundle: notificationManager.BundleOption = {
2471    bundle: "bundleName1",
2472};
2473let enable: boolean = true;
2474notificationManager.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback);
2475```
2476
2477
2478
2479## notificationManager.setDistributedEnableByBundle
2480
2481setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
2482
2483设置指定应用是否支持分布式通知。使用Promise异步回调。
2484
2485**系统能力**:SystemCapability.Notification.Notification
2486
2487**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2488
2489**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2490
2491**系统接口**:此接口为系统接口。
2492
2493**参数:**
2494
2495| 参数名   | 类型                     | 必填 | 说明                       |
2496| -------- | ------------------------ | ---- | -------------------------- |
2497| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                |
2498| enable   | boolean                  | 是   | 指定应用是否支持分布式通知(true:支持,false:不支持)。                  |
2499
2500**返回值:**
2501
2502| 类型              | 说明        |
2503|-----------------|-----------|
2504| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
2505
2506**错误码:**
2507
2508以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
2509
2510| 错误码ID | 错误信息                                 |
2511| -------- | ---------------------------------------- |
2512| 201      | Permission denied.     |
2513| 202      | Not system application to call the interface.                                      |
2514| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2515| 801 | Capability not supported. |
2516| 1600001  | Internal error.                          |
2517| 1600002  | Marshalling or unmarshalling error.      |
2518| 1600003  | Failed to connect to the service.               |
2519| 1600010  | Distributed operation failed.            |
2520| 17700001 | The specified bundle name was not found. |
2521
2522**示例:**
2523
2524```ts
2525import { BusinessError } from '@kit.BasicServicesKit';
2526
2527let bundle: notificationManager.BundleOption = {
2528    bundle: "bundleName1",
2529};
2530let enable: boolean = true;
2531notificationManager.setDistributedEnableByBundle(bundle, enable).then(() => {
2532    console.info("setDistributedEnableByBundle success");
2533}).catch((err: BusinessError) => {
2534    console.error(`setDistributedEnableByBundle failed, code is ${err.code}, message is ${err.message}`);
2535});
2536```
2537
2538## notificationManager.isDistributedEnabledByBundle
2539
2540isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
2541
2542根据应用的包获取应用程序是否支持分布式通知。使用callback异步回调。
2543
2544**系统能力**:SystemCapability.Notification.Notification
2545
2546**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2547
2548**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2549
2550**系统接口**:此接口为系统接口。
2551
2552**参数:**
2553
2554| 参数名   | 类型                     | 必填 | 说明                       |
2555| -------- | ------------------------ | ---- | -------------------------- |
2556| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                     |
2557| callback | AsyncCallback\<boolean\> | 是   | 查询指定应用是否支持分布式通知的回调函数(true:支持,false:不支持)。 |
2558
2559**错误码:**
2560
2561以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
2562
2563| 错误码ID | 错误信息                                 |
2564| -------- | ---------------------------------------- |
2565| 201      | Permission denied.     |
2566| 202      | Not system application to call the interface.                                      |
2567| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2568| 801 | Capability not supported. |
2569| 1600001  | Internal error.                          |
2570| 1600002  | Marshalling or unmarshalling error.      |
2571| 1600003  | Failed to connect to the service.               |
2572| 1600010  | Distributed operation failed.            |
2573| 17700001 | The specified bundle name was not found. |
2574
2575**示例:**
2576
2577```ts
2578import { BusinessError } from '@kit.BasicServicesKit';
2579
2580let isDistributedEnabledByBundleCallback = (err: BusinessError, data: boolean): void => {
2581    if (err) {
2582        console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
2583    } else {
2584        console.info(`isDistributedEnabledByBundle success, data: ${JSON.stringify(data)}`);
2585    }
2586};
2587let bundle: notificationManager.BundleOption = {
2588    bundle: "bundleName1",
2589};
2590notificationManager.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
2591```
2592
2593## notificationManager.isDistributedEnabledByBundle
2594
2595isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
2596
2597查询指定应用是否支持分布式通知。使用Promise异步回调。
2598
2599**系统能力**:SystemCapability.Notification.Notification
2600
2601**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2602
2603**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2604
2605**系统接口**:此接口为系统接口。
2606
2607**参数:**
2608
2609| 参数名   | 类型                     | 必填 | 说明                       |
2610| -------- | ------------------------ | ---- | -------------------------- |
2611| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                |
2612
2613**返回值:**
2614
2615| 类型               | 说明                                              |
2616| ------------------ | ------------------------------------------------- |
2617| Promise\<boolean\> | Promise方式返回指定应用是否支持分布式通知的结果(true:支持,false:不支持)。 |
2618
2619**错误码:**
2620
2621以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
2622
2623| 错误码ID | 错误信息                                 |
2624| -------- | ---------------------------------------- |
2625| 201      | Permission denied.     |
2626| 202      | Not system application to call the interface.                                      |
2627| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2628| 801 | Capability not supported. |
2629| 1600001  | Internal error.                          |
2630| 1600002  | Marshalling or unmarshalling error.      |
2631| 1600003  | Failed to connect to the service.               |
2632| 1600010  | Distributed operation failed.            |
2633| 17700001 | The specified bundle name was not found. |
2634
2635**示例:**
2636
2637```ts
2638import { BusinessError } from '@kit.BasicServicesKit';
2639
2640let bundle: notificationManager.BundleOption = {
2641    bundle: "bundleName1",
2642};
2643notificationManager.isDistributedEnabledByBundle(bundle).then((data: boolean) => {
2644    console.info(`isDistributedEnabledByBundle success, data: ${JSON.stringify(data)}`);
2645}).catch((err: BusinessError) => {
2646    console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
2647});
2648```
2649
2650
2651## notificationManager.getDeviceRemindType
2652
2653getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
2654
2655获取通知的提醒方式。使用callback异步回调。
2656
2657**系统能力**:SystemCapability.Notification.Notification
2658
2659**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2660
2661**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2662
2663**系统接口**:此接口为系统接口。
2664
2665**参数:**
2666
2667| 参数名   | 类型                               | 必填 | 说明                       |
2668| -------- | --------------------------------- | ---- | -------------------------- |
2669| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | 是   | 获取通知提醒方式的回调函数。 |
2670
2671**错误码:**
2672
2673以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2674
2675| 错误码ID | 错误信息                            |
2676| -------- | ----------------------------------- |
2677| 201      | Permission denied.     |
2678| 202      | Not system application to call the interface.                                      |
2679| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2680| 801 | Capability not supported. |
2681| 1600001  | Internal error.                     |
2682| 1600002  | Marshalling or unmarshalling error. |
2683| 1600003  | Failed to connect to the service.          |
2684
2685**示例:**
2686
2687```ts
2688import { BusinessError } from '@kit.BasicServicesKit';
2689
2690let getDeviceRemindTypeCallback = (err: BusinessError, data: notificationManager.DeviceRemindType): void => {
2691    if (err) {
2692        console.error(`getDeviceRemindType failed, code is ${err.code}, message is ${err.message}`);
2693    } else {
2694        console.info(`getDeviceRemindType success, data is ${JSON.stringify(data)}`);
2695    }
2696};
2697notificationManager.getDeviceRemindType(getDeviceRemindTypeCallback);
2698```
2699
2700## notificationManager.getDeviceRemindType
2701
2702getDeviceRemindType(): Promise\<DeviceRemindType\>
2703
2704获取通知的提醒方式。使用Promise异步回调。
2705
2706**系统能力**:SystemCapability.Notification.Notification
2707
2708**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
2709
2710**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2711
2712**系统接口**:此接口为系统接口。
2713
2714**返回值:**
2715
2716| 类型               | 说明            |
2717| ------------------ | --------------- |
2718| Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise方式返回获取通知提醒方式的结果。 |
2719
2720**错误码:**
2721
2722以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2723
2724| 错误码ID | 错误信息                            |
2725| -------- | ----------------------------------- |
2726| 201      | Permission denied.     |
2727| 202      | Not system application to call the interface.                                      |
2728| 801 | Capability not supported. |
2729| 1600001  | Internal error.                     |
2730| 1600002  | Marshalling or unmarshalling error. |
2731| 1600003  | Failed to connect to the service.          |
2732
2733**示例:**
2734
2735```ts
2736import { BusinessError } from '@kit.BasicServicesKit';
2737
2738notificationManager.getDeviceRemindType().then((data: notificationManager.DeviceRemindType) => {
2739    console.info(`getDeviceRemindType success, data: ${JSON.stringify(data)}`);
2740}).catch((err: BusinessError) => {
2741    console.error(`getDeviceRemindType failed, code is ${err.code}, message is ${err.message}`);
2742});
2743```
2744
2745
2746## notificationManager.publishAsBundle
2747
2748publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
2749
2750发布代理通知。使用callback异步回调。
2751
2752**系统能力**:SystemCapability.Notification.Notification
2753
2754**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2755
2756**系统接口**:此接口为系统接口。
2757
2758**参数:**
2759
2760| 参数名               | 类型                                        | 必填 | 说明                                     |
2761| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
2762| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
2763| representativeBundle | string                                      | 是   | 被代理应用的包名。                       |
2764| userId               | number                                      | 是   | 用户ID。                                 |
2765| callback             | AsyncCallback\<void\>                        | 是   | 发布代理通知的回调方法。                 |
2766
2767**错误码:**
2768
2769以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[HTTP错误码](../apis-network-kit/errorcode-net-http.md)。
2770
2771| 错误码ID | 错误信息                                  |
2772| -------- | ----------------------------------------- |
2773| 201      | Permission denied.     |
2774| 202      | Not system application to call the interface.                                      |
2775| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2776| 1600001  | Internal error.                           |
2777| 1600002  | Marshalling or unmarshalling error.       |
2778| 1600003  | Failed to connect to the service.                |
2779| 1600004  | Notification disabled.              |
2780| 1600005  | Notification slot disabled.         |
2781| 1600007  | The notification does not exist.      |
2782| 1600008  | The user does not exist.                    |
2783| 1600009  | The notification sending frequency reaches the upper limit. |
2784| 1600012  | No memory space.                          |
2785| 1600015  | The current notification status does not support duplicate configurations. |
2786| 1600016  | The notification version for this update is too low. |
2787| 1600020  | The application is not allowed to send notifications due to permission settings. |
2788| 2300007  | Network unreachable.                              |
2789
2790**示例:**
2791
2792```ts
2793import { BusinessError } from '@kit.BasicServicesKit';
2794
2795//publishAsBundle回调
2796let callback = (err: BusinessError): void => {
2797    if (err) {
2798        console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
2799    } else {
2800        console.info("publishAsBundle success");
2801    }
2802}
2803// 被代理应用的包名
2804let representativeBundle: string = "com.example.demo";
2805// 用户ID,使用时需替换为真实的userId。
2806let userId: number = 100;
2807// NotificationRequest对象
2808let request: notificationManager.NotificationRequest = {
2809    id: 1,
2810    content: {
2811        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2812        normal: {
2813            title: "test_title",
2814            text: "test_text",
2815            additionalText: "test_additionalText"
2816        }
2817    }
2818};
2819notificationManager.publishAsBundle(request, representativeBundle, userId, callback);
2820```
2821
2822## notificationManager.publishAsBundle
2823
2824publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
2825
2826发布代理通知。使用Promise异步回调。
2827
2828**系统能力**:SystemCapability.Notification.Notification
2829
2830**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2831
2832**系统接口**:此接口为系统接口。
2833
2834**参数:**
2835
2836
2837| 参数名               | 类型                                        | 必填 | 说明                                          |
2838| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
2839| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
2840| representativeBundle | string                                      | 是   | 被代理应用的包名。                            |
2841| userId               | number                                      | 是   | 用户ID。                            |
2842
2843**返回值:**
2844
2845| 类型              | 说明        |
2846|-----------------|-----------|
2847| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
2848
2849**错误码:**
2850
2851以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[HTTP错误码](../apis-network-kit/errorcode-net-http.md)。
2852
2853| 错误码ID | 错误信息                                  |
2854| -------- | ----------------------------------------- |
2855| 201      | Permission denied.     |
2856| 202      | Not system application to call the interface.                                      |
2857| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2858| 1600001  | Internal error.                           |
2859| 1600002  | Marshalling or unmarshalling error.       |
2860| 1600003  | Failed to connect to the service.                |
2861| 1600004  | Notification disabled.                    |
2862| 1600005  | Notification slot disabled.         |
2863| 1600007  | The notification does not exist.      |
2864| 1600008  | The user does not exist.                    |
2865| 1600009  | The notification sending frequency reaches the upper limit. |
2866| 1600012  | No memory space.                          |
2867| 1600015  | The current notification status does not support duplicate configurations. |
2868| 1600016  | The notification version for this update is too low. |
2869| 1600020  | The application is not allowed to send notifications due to permission settings. |
2870| 2300007  | Network unreachable.                              |
2871
2872**示例:**
2873
2874```ts
2875import { BusinessError } from '@kit.BasicServicesKit';
2876
2877// 被代理应用的包名
2878let representativeBundle: string = "com.example.demo";
2879// 用户ID,使用时需替换为真实的userId。
2880let userId: number = 100;
2881// NotificationRequest对象
2882let request: notificationManager.NotificationRequest = {
2883    id: 1,
2884    content: {
2885        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2886        normal: {
2887            title: "test_title",
2888            text: "test_text",
2889            additionalText: "test_additionalText"
2890        }
2891    }
2892};
2893notificationManager.publishAsBundle(request, representativeBundle, userId).then(() => {
2894	console.info("publishAsBundle success");
2895}).catch((err: BusinessError) => {
2896    console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
2897});
2898```
2899
2900## notificationManager.publishAsBundle<sup>12+</sup>
2901
2902publishAsBundle(representativeBundle: BundleOption, request: NotificationRequest): Promise\<void\>
2903
2904发布代理通知。使用Promise异步回调。
2905
2906**系统能力**:SystemCapability.Notification.Notification
2907
2908**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2909
2910**系统接口**:此接口为系统接口。
2911
2912**参数:**
2913
2914
2915| 参数名               | 类型                                        | 必填 | 说明                                          |
2916|----------------------|--------------------------------------------|------|-----------------------------------------------|
2917| representativeBundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)  | 是   | 被代理应用的包信息。                            |
2918| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
2919
2920**返回值:**
2921
2922| 类型              | 说明        |
2923|-----------------|-----------|
2924| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
2925
2926**错误码:**
2927
2928以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[HTTP错误码](../apis-network-kit/errorcode-net-http.md)。
2929
2930| 错误码ID | 错误信息                                  |
2931| -------- | ----------------------------------------- |
2932| 201      | Permission denied.     |
2933| 202      | Not system application to call the interface.                                      |
2934| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2935| 1600001  | Internal error.                           |
2936| 1600002  | Marshalling or unmarshalling error.       |
2937| 1600003  | Failed to connect to the service.                |
2938| 1600004  | Notification disabled.              |
2939| 1600005  | Notification slot disabled.         |
2940| 1600007  | The notification does not exist.      |
2941| 1600008  | The user does not exist.                    |
2942| 1600009  | The notification sending frequency reaches the upper limit. |
2943| 1600012  | No memory space.                          |
2944| 1600015  | The current notification status does not support duplicate configurations. |
2945| 1600016  | The notification version for this update is too low. |
2946| 1600020  | The application is not allowed to send notifications due to permission settings. |
2947| 2300007  | Network unreachable.                              |
2948
2949**示例:**
2950
2951```ts
2952import { BusinessError } from '@kit.BasicServicesKit';
2953
2954// 被代理应用的包信息
2955let representativeBundle: notificationManager.BundleOption = {
2956  bundle: "bundleName1",
2957};
2958// NotificationRequest对象
2959let request: notificationManager.NotificationRequest = {
2960    id: 1,
2961    content: {
2962        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2963        normal: {
2964            title: "test_title",
2965            text: "test_text",
2966            additionalText: "test_additionalText"
2967        }
2968    }
2969};
2970notificationManager.publishAsBundle(representativeBundle, request).then(() => {
2971	console.info("publishAsBundle success");
2972}).catch((err: BusinessError) => {
2973    console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
2974});
2975```
2976
2977## notificationManager.cancelAsBundle
2978
2979cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
2980
2981取消代理通知。使用callback异步回调。
2982
2983**系统能力**:SystemCapability.Notification.Notification
2984
2985**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2986
2987**系统接口**:此接口为系统接口。
2988
2989**参数:**
2990
2991| 参数名               | 类型          | 必填 | 说明                     |
2992| -------------------- | ------------- | ---- | ------------------------ |
2993| id                   | number        | 是   | 通知ID。                 |
2994| representativeBundle | string        | 是   | 被代理应用的包名。       |
2995| userId               | number        | 是   | 用户ID。       |
2996| callback             | AsyncCallback\<void\> | 是   | 取消代理通知的回调方法。 |
2997
2998**错误码:**
2999
3000以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3001
3002| 错误码ID | 错误信息                            |
3003| -------- | ----------------------------------- |
3004| 201      | Permission denied.     |
3005| 202      | Not system application to call the interface.                                      |
3006| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3007| 1600001  | Internal error.                     |
3008| 1600002  | Marshalling or unmarshalling error. |
3009| 1600003  | Failed to connect to the service.          |
3010| 1600007  | The notification does not exist.      |
3011| 1600008  | The user does not exist.              |
3012| 17700001 | The specified bundle name was not found. |
3013
3014**示例:**
3015
3016```ts
3017import { BusinessError } from '@kit.BasicServicesKit';
3018
3019// cancelAsBundle
3020let cancelAsBundleCallback = (err: BusinessError): void => {
3021    if (err) {
3022        console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
3023    } else {
3024        console.info("cancelAsBundle success");
3025    }
3026}
3027// 被代理应用的包名
3028let representativeBundle: string = "com.example.demo";
3029// 用户ID,使用时需替换为真实的userId。
3030let userId: number = 100;
3031notificationManager.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
3032```
3033
3034## notificationManager.cancelAsBundle
3035
3036cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
3037
3038取消代理通知。使用Promise异步回调。
3039
3040**系统能力**:SystemCapability.Notification.Notification
3041
3042**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3043
3044**系统接口**:此接口为系统接口。
3045
3046**参数:**
3047
3048| 参数名               | 类型   | 必填 | 说明               |
3049| -------------------- | ------ | ---- | ------------------ |
3050| id                   | number | 是   | 通知ID。           |
3051| representativeBundle | string | 是   | 被代理应用的包名。 |
3052| userId               | number | 是   | 用户ID。 |
3053
3054**返回值:**
3055
3056| 类型              | 说明        |
3057|-----------------|-----------|
3058| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
3059
3060**错误码:**
3061
3062以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3063
3064| 错误码ID | 错误信息                            |
3065| -------- | ----------------------------------- |
3066| 201      | Permission denied.     |
3067| 202      | Not system application to call the interface.                                      |
3068| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3069| 1600001  | Internal error.                     |
3070| 1600002  | Marshalling or unmarshalling error. |
3071| 1600003  | Failed to connect to the service.          |
3072| 1600007  | The notification does not exist.      |
3073| 1600008  | The user does not exist.              |
3074| 17700001 | The specified bundle name was not found. |
3075
3076**示例:**
3077
3078```ts
3079import { BusinessError } from '@kit.BasicServicesKit';
3080
3081// 被代理应用的包名
3082let representativeBundle: string = "com.example.demo";
3083// 用户ID,使用时需替换为真实的userId。
3084let userId: number = 100;
3085notificationManager.cancelAsBundle(0, representativeBundle, userId).then(() => {
3086	console.info("cancelAsBundle success");
3087}).catch((err: BusinessError) => {
3088    console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
3089});
3090```
3091
3092
3093## notificationManager.cancelAsBundle<sup>12+</sup>
3094
3095cancelAsBundle(representativeBundle: BundleOption, id: number): Promise\<void\>
3096
3097取消代理通知。使用Promise异步回调。
3098
3099**系统能力**:SystemCapability.Notification.Notification
3100
3101**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3102
3103**系统接口**:此接口为系统接口。
3104
3105**参数:**
3106
3107
3108| 参数名               | 类型                                        | 必填 | 说明                                          |
3109| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
3110| representativeBundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)  |是   | 被代理应用的包信息。 |
3111| id                   | number                                     | 是   | 通知ID。           |
3112
3113**返回值:**
3114
3115| 类型              | 说明        |
3116|-----------------|-----------|
3117| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
3118
3119**错误码:**
3120
3121以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3122
3123| 错误码ID | 错误信息                                  |
3124| -------- | ----------------------------------------- |
3125| 201      | Permission denied.     |
3126| 202      | Not system application to call the interface.                                      |
3127| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3128| 1600001  | Internal error.                           |
3129| 1600002  | Marshalling or unmarshalling error.       |
3130| 1600003  | Failed to connect to the service.                |
3131| 1600007  | The notification does not exist.            |
3132| 1600008  | The user does not exist.                    |
3133| 1600012  | No memory space.                          |
3134| 17700001 | The specified bundle name was not found. |
3135
3136**示例:**
3137
3138```ts
3139import { BusinessError } from '@kit.BasicServicesKit';
3140
3141let representativeBundle: notificationManager.BundleOption = {
3142  bundle: "bundleName1",
3143};
3144notificationManager.cancelAsBundle(representativeBundle, 1).then(() => {
3145	console.info("cancelAsBundle success");
3146}).catch((err: BusinessError) => {
3147    console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
3148});
3149```
3150
3151## notificationManager.cancel<sup>12+</sup>
3152
3153cancel(representativeBundle: BundleOption, id: number): Promise\<void\>
3154
3155代理取消当前用户其他应用的通知。使用Promise异步回调。
3156
3157需要当前应用与其他应用存在代理关系,或者当前应用有ohos.permission.NOTIFICATION_AGENT_CONTROLLER权限。
3158
3159**系统能力**:SystemCapability.Notification.Notification
3160
3161**系统接口**:此接口为系统接口。
3162
3163**参数:**
3164
3165| 参数名               | 类型   | 必填 | 说明               |
3166| -------------------- | ------ | ---- | ------------------ |
3167| representativeBundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3168|       id             | number | 是   | 通知ID。 |
3169
3170**返回值:**
3171
3172| 类型              | 说明        |
3173|-----------------|-----------|
3174| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
3175
3176**错误码:**
3177
3178以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3179
3180| 错误码ID | 错误信息                            |
3181| -------- | ----------------------------------- |
3182| 202      | Not system application to call the interface.                                      |
3183| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3184| 1600001  | Internal error.                     |
3185| 1600002  | Marshalling or unmarshalling error. |
3186| 1600003  | Failed to connect to the service.          |
3187| 1600007  | The notification does not exist.      |
3188| 1600012  | No memory space.                    |
3189| 1600017  | There is no corresponding agent relationship configuration.    |
3190
3191**示例:**
3192
3193```ts
3194import { BusinessError } from '@kit.BasicServicesKit';
3195
3196let bundle: notificationManager.BundleOption = {
3197  bundle: "bundleName"
3198};
3199let id: number = 1;
3200notificationManager.cancel(bundle, id).then(() => {
3201  console.info("cancel success");
3202}).catch((err: BusinessError) => {
3203  console.error(`cancel failed, code is ${err.code}, message is ${err.message}`);
3204});
3205```
3206
3207## notificationManager.setNotificationEnableSlot
3208
3209setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
3210
3211设置指定应用的指定渠道类型的使能状态。使用callback异步回调。
3212
3213**系统能力**:SystemCapability.Notification.Notification
3214
3215**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
3216
3217**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3218
3219**系统接口**:此接口为系统接口。
3220
3221**参数:**
3222
3223| 参数名   | 类型                          | 必填 | 说明                   |
3224| -------- | ----------------------------- | ---- | ---------------------- |
3225| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3226| type     | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 指定渠道类型。         |
3227| enable   | boolean                       | 是   | 使能状态(true:使能,false:禁止)。             |
3228| callback | AsyncCallback\<void\>         | 是   | 设置渠道使能回调函数。 |
3229
3230**错误码:**
3231
3232以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3233
3234| 错误码ID | 错误信息                                 |
3235| -------- | ---------------------------------------- |
3236| 201      | Permission denied.     |
3237| 202      | Not system application to call the interface.                                      |
3238| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3239| 801 | Capability not supported. |
3240| 1600001  | Internal error.                          |
3241| 1600002  | Marshalling or unmarshalling error.      |
3242| 1600003  | Failed to connect to the service.               |
3243| 1600012  | No memory space.                         |
3244| 17700001 | The specified bundle name was not found. |
3245
3246**示例:**
3247
3248```ts
3249import { BusinessError } from '@kit.BasicServicesKit';
3250
3251// setNotificationEnableSlot
3252let setNotificationEnableSlotCallback = (err: BusinessError): void => {
3253    if (err) {
3254        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
3255    } else {
3256        console.info("setNotificationEnableSlot success");
3257    }
3258};
3259notificationManager.setNotificationEnableSlot(
3260    { bundle: "ohos.samples.notification", },
3261    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3262    true,
3263    setNotificationEnableSlotCallback);
3264```
3265
3266## notificationManager.setNotificationEnableSlot<sup>11+</sup>
3267
3268setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, isForceControl: boolean, callback: AsyncCallback\<void>): void
3269
3270设置指定应用的指定渠道类型的使能状态。使用callback异步回调。
3271
3272**系统能力**:SystemCapability.Notification.Notification
3273
3274**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
3275
3276**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3277
3278**系统接口**:此接口为系统接口。
3279
3280**参数:**
3281
3282| 参数名   | 类型                          | 必填 | 说明                     |
3283| -------- | ----------------------------- | ---- | ----------------------- |
3284| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。|
3285| type     | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 指定渠道类型。           |
3286| enable   | boolean                       | 是   | 使能状态(true:使能,false:禁止)。               |
3287| isForceControl<sup>11+</sup> | boolean                 | 是   | 渠道开关是否受通知授权开关影响(false:受影响,true:不受影响)。 |
3288| callback | AsyncCallback\<void\>         | 是   | 设置渠道使能回调函数。    |
3289
3290**错误码:**
3291
3292以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3293
3294| 错误码ID | 错误信息                                 |
3295| -------- | ---------------------------------------- |
3296| 201      | Permission denied.     |
3297| 202      | Not system application to call the interface.                                      |
3298| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3299| 801 | Capability not supported. |
3300| 1600001  | Internal error.                          |
3301| 1600002  | Marshalling or unmarshalling error.      |
3302| 1600003  | Failed to connect to the service.               |
3303| 1600012  | No memory space.                         |
3304| 17700001 | The specified bundle name was not found. |
3305
3306**示例:**
3307
3308```ts
3309import { BusinessError } from '@kit.BasicServicesKit';
3310
3311let setNotificationEnableSlotCallback = (err: BusinessError): void => {
3312    if (err) {
3313        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
3314    } else {
3315        console.info("setNotificationEnableSlot success");
3316    }
3317};
3318
3319notificationManager.setNotificationEnableSlot(
3320    { bundle: "ohos.samples.notification", },
3321    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3322    true,
3323    false,
3324    setNotificationEnableSlotCallback);
3325```
3326
3327## notificationManager.setNotificationEnableSlot
3328
3329setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, isForceControl?: boolean): Promise\<void>
3330
3331设置指定应用的指定渠道类型的使能状态。使用promise异步回调。
3332
3333**系统能力**:SystemCapability.Notification.Notification
3334
3335**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
3336
3337**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3338
3339**系统接口**:此接口为系统接口。
3340
3341**参数:**
3342
3343| 参数名 | 类型                          | 必填 | 说明           |
3344| ------ | ----------------------------- | ---- | -------------- |
3345| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。   |
3346| type   | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 渠道类型。 |
3347| enable | boolean                       | 是   | 使能状态(true:使能,false:禁止)。     |
3348| isForceControl<sup>11+</sup> | boolean               | 否   | 渠道开关是否受通知总开关影响(false:受总开关影响,true:不受总开关影响)。默认为false。     |
3349
3350**返回值:**
3351
3352| 类型     | 说明         |
3353| ------- |------------|
3354| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
3355
3356**错误码:**
3357
3358以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3359
3360| 错误码ID | 错误信息                                 |
3361| -------- | ---------------------------------------- |
3362| 201      | Permission denied.     |
3363| 202      | Not system application to call the interface.                                      |
3364| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3365| 801 | Capability not supported. |
3366| 1600001  | Internal error.                          |
3367| 1600002  | Marshalling or unmarshalling error.      |
3368| 1600003  | Failed to connect to the service.               |
3369| 1600012  | No memory space.                         |
3370| 17700001 | The specified bundle name was not found. |
3371
3372**示例:**
3373
3374```ts
3375import { BusinessError } from '@kit.BasicServicesKit';
3376
3377// setNotificationEnableSlot
3378notificationManager.setNotificationEnableSlot(
3379    { bundle: "ohos.samples.notification", },
3380    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3381    true).then(() => {
3382        console.info("setNotificationEnableSlot success");
3383    }).catch((err: BusinessError) => {
3384        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
3385    });
3386```
3387
3388## notificationManager.isNotificationSlotEnabled
3389
3390isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
3391
3392获取指定应用的指定渠道类型的使能状态。使用callback异步回调。
3393
3394**系统能力**:SystemCapability.Notification.Notification
3395
3396**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
3397
3398**系统接口**:此接口为系统接口。
3399
3400**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3401
3402**参数:**
3403
3404| 参数名   | 类型                          | 必填 | 说明                   |
3405| -------- | ----------------------------- | ---- | ---------------------- |
3406| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3407| type     | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 渠道类型。         |
3408| callback | AsyncCallback\<boolean\>         | 是   | 获取渠道使能状态回调函数(true:使能,false:禁止)。 |
3409
3410**错误码:**
3411
3412以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3413
3414| 错误码ID | 错误信息                                 |
3415| -------- | ---------------------------------------- |
3416| 201      | Permission denied.     |
3417| 202      | Not system application to call the interface.                                      |
3418| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3419| 801 | Capability not supported. |
3420| 1600001  | Internal error.                          |
3421| 1600002  | Marshalling or unmarshalling error.      |
3422| 1600003  | Failed to connect to the service.               |
3423| 17700001 | The specified bundle name was not found. |
3424
3425**示例:**
3426
3427```ts
3428import { BusinessError } from '@kit.BasicServicesKit';
3429
3430// isNotificationSlotEnabledCallback
3431let isNotificationSlotEnabledCallback = (err: BusinessError, data: boolean): void => {
3432    if (err) {
3433        console.error(`isNotificationSlotEnabled failed, code is ${err.code}, message is ${err.message}`);
3434    } else {
3435        console.info(`isNotificationSlotEnabled success, data is ${JSON.stringify(data)}`);
3436    }
3437};
3438
3439notificationManager.isNotificationSlotEnabled(
3440    { bundle: "ohos.samples.notification", },
3441    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3442    isNotificationSlotEnabledCallback);
3443```
3444
3445## notificationManager.isNotificationSlotEnabled
3446
3447isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
3448
3449获取指定应用的指定渠道类型的使能状态。使用Promise异步回调。
3450
3451**系统能力**:SystemCapability.Notification.Notification
3452
3453**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
3454
3455**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3456
3457**系统接口**:此接口为系统接口。
3458
3459**参数:**
3460
3461| 参数名 | 类型                          | 必填 | 说明           |
3462| ------ | ----------------------------- | ---- | -------------- |
3463| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。   |
3464| type   | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 渠道类型。 |
3465
3466**返回值:**
3467
3468| 类型                                                        | 说明                                                         |
3469| ----------------------------------------------------------- | ------------------------------------------------------------ |
3470| Promise\<boolean\> | 以Promise形式返回指定类型的渠道使能状态(true:使能,false:禁止)。 |
3471
3472**错误码:**
3473
3474以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3475
3476| 错误码ID | 错误信息                                 |
3477| -------- | ---------------------------------------- |
3478| 201      | Permission denied.     |
3479| 202      | Not system application to call the interface.                                      |
3480| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3481| 801 | Capability not supported. |
3482| 1600001  | Internal error.                          |
3483| 1600002  | Marshalling or unmarshalling error.      |
3484| 1600003  | Failed to connect to the service.               |
3485| 17700001 | The specified bundle name was not found. |
3486
3487**示例:**
3488
3489```ts
3490import { BusinessError } from '@kit.BasicServicesKit';
3491
3492// isNotificationSlotEnabled
3493notificationManager.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
3494    notificationManager.SlotType.SOCIAL_COMMUNICATION).then((data: boolean) => {
3495    console.info(`isNotificationSlotEnabled success, data: ${JSON.stringify(data)}`);
3496}).catch((err: BusinessError) => {
3497    console.error(`isNotificationSlotEnabled failed, code is ${err.code}, message is ${err.message}`);
3498});
3499```
3500
3501
3502## notificationManager.setSyncNotificationEnabledWithoutApp
3503
3504setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
3505
3506设置是否将通知同步到未安装应用程序的设备(callback形式)。
3507
3508**系统能力**:SystemCapability.Notification.Notification
3509
3510**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
3511
3512**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3513
3514**系统接口**:此接口为系统接口。
3515
3516**参数:**
3517
3518| 参数名 | 类型                          | 必填 | 说明           |
3519| ------ | ----------------------------- | ---- | -------------- |
3520| userId | number | 是   | 用户ID。   |
3521| enable | boolean | 是   | 是否启用(true:使能,false:禁止)。   |
3522| callback | AsyncCallback\<void\>    | 是   | 设置是否将通知同步到未安装应用程序的设备的回调函数。 |
3523
3524**错误码:**
3525
3526以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3527
3528| 错误码ID | 错误信息                            |
3529| -------- | ----------------------------------- |
3530| 201      | Permission denied.     |
3531| 202      | Not system application to call the interface.                                      |
3532| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3533| 801 | Capability not supported. |
3534| 1600001  | Internal error.                     |
3535| 1600002  | Marshalling or unmarshalling error. |
3536| 1600003  | Failed to connect to the service.          |
3537| 1600008  | The user does not exist.              |
3538
3539**示例:**
3540
3541```ts
3542import { BusinessError } from '@kit.BasicServicesKit';
3543
3544// 用户ID,使用时需替换为真实的userId。
3545let userId: number = 100;
3546let enable: boolean = true;
3547let setSyncNotificationEnabledWithoutAppCallback = (err: BusinessError): void => {
3548    if (err) {
3549        console.error(`setSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
3550    } else {
3551        console.info("setSyncNotificationEnabledWithoutApp success");
3552    }
3553}
3554notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback);
3555```
3556
3557
3558## notificationManager.setSyncNotificationEnabledWithoutApp
3559
3560setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
3561
3562设置是否将通知同步到未安装应用程序的设备(Promise形式)。
3563
3564**系统能力**:SystemCapability.Notification.Notification
3565
3566**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
3567
3568**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3569
3570**系统接口**:此接口为系统接口。
3571
3572**参数:**
3573
3574| 参数名 | 类型                          | 必填 | 说明           |
3575| ------ | ----------------------------- | ---- | -------------- |
3576| userId | number | 是   | 用户ID。   |
3577| enable | boolean | 是   | 是否启用(true:使能,false:禁止)。   |
3578
3579**返回值:**
3580
3581| 类型                                                        | 说明                                                         |
3582| ----------------------------------------------------------- | ------------------------------------------------------------ |
3583| Promise\<void\> | 以Promise形式返回设置是否将通知同步到未安装应用程序的设备的结果。 |
3584
3585**错误码:**
3586
3587以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3588
3589| 错误码ID | 错误信息                            |
3590| -------- | ----------------------------------- |
3591| 201      | Permission denied.     |
3592| 202      | Not system application to call the interface.                                      |
3593| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3594| 801 | Capability not supported. |
3595| 1600001  | Internal error.                     |
3596| 1600002  | Marshalling or unmarshalling error. |
3597| 1600003  | Failed to connect to the service.          |
3598| 1600008  | The user does not exist.              |
3599
3600**示例:**
3601
3602```ts
3603import { BusinessError } from '@kit.BasicServicesKit';
3604
3605// 用户ID,使用时需替换为真实的userId。
3606let userId: number = 100;
3607let enable: boolean = true;
3608notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
3609    console.info('setSyncNotificationEnabledWithoutApp success');
3610}).catch((err: BusinessError) => {
3611    console.error(`setSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
3612});
3613```
3614
3615
3616## notificationManager.getSyncNotificationEnabledWithoutApp
3617
3618getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
3619
3620获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。
3621
3622**系统能力**:SystemCapability.Notification.Notification
3623
3624**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3625
3626**系统接口**:此接口为系统接口。
3627
3628**参数:**
3629
3630| 参数名 | 类型                          | 必填 | 说明           |
3631| ------ | ----------------------------- | ---- | -------------- |
3632| userId | number | 是   | 用户ID。   |
3633| callback | AsyncCallback\<boolean\>         | 是   | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数(true:开启,false:未开启)。 |
3634
3635**错误码:**
3636
3637以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3638
3639| 错误码ID | 错误信息                            |
3640| -------- | ----------------------------------- |
3641| 201      | Permission denied.     |
3642| 202      | Not system application to call the interface.                                      |
3643| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3644| 1600001  | Internal error.                     |
3645| 1600002  | Marshalling or unmarshalling error. |
3646| 1600003  | Failed to connect to the service.          |
3647| 1600008  | The user does not exist.              |
3648
3649**示例:**
3650
3651```ts
3652import { BusinessError } from '@kit.BasicServicesKit';
3653
3654// 用户ID,使用时需替换为真实的userId。
3655let userId: number = 100;
3656let getSyncNotificationEnabledWithoutAppCallback = (err: BusinessError, data: boolean): void => {
3657    if (err) {
3658        console.error(`getSyncNotificationEnabledWithoutAppCallback failed, code is ${err.code}, message is ${err.message}`);
3659    } else {
3660        console.info(`getSyncNotificationEnabledWithoutAppCallback success, data: ${JSON.stringify(data)}`);
3661    }
3662}
3663notificationManager.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
3664```
3665
3666
3667## notificationManager.getSyncNotificationEnabledWithoutApp
3668
3669getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
3670
3671获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。
3672
3673**系统能力**:SystemCapability.Notification.Notification
3674
3675**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3676
3677**系统接口**:此接口为系统接口。
3678
3679**参数:**
3680
3681| 参数名 | 类型                          | 必填 | 说明           |
3682| ------ | ----------------------------- | ---- | -------------- |
3683| userId | number | 是   | 用户ID。   |
3684
3685**返回值:**
3686
3687| 类型               | 说明                                                         |
3688| ------------------ | ------------------------------------------------------------ |
3689| Promise\<boolean\> | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果(true:开启,false:未开启)。 |
3690
3691**错误码:**
3692
3693以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3694
3695| 错误码ID | 错误信息                            |
3696| -------- | ----------------------------------- |
3697| 201      | Permission denied.     |
3698| 202      | Not system application to call the interface.                                      |
3699| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3700| 1600001  | Internal error.                     |
3701| 1600002  | Marshalling or unmarshalling error. |
3702| 1600003  | Failed to connect to the service.          |
3703| 1600008  | The user does not exist.              |
3704
3705**示例:**
3706
3707```ts
3708import { BusinessError } from '@kit.BasicServicesKit';
3709
3710// 用户ID,使用时需替换为真实的userId。
3711let userId: number = 100;
3712notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data: boolean) => {
3713  console.info(`getSyncNotificationEnabledWithoutApp, data: ${JSON.stringify(data)}`);
3714}).catch((err: BusinessError) => {
3715    console.error(`getSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
3716});
3717```
3718
3719## notificationManager.on<sup>10+</sup>
3720
3721on(type: 'checkNotification', callback: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void
3722
3723注册通知监听回调。通知服务将通知信息回调给校验程序,校验程序返回校验结果决定该通知是否发布,如营销类通知发布频率控制等。
3724
3725系统中每个[SlotType](./js-apis-notificationManager.md#slottype)只允许存在一个注册者。
3726
3727**系统能力**:SystemCapability.Notification.Notification
3728
3729**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3730
3731**系统接口**:此接口为系统接口。
3732
3733**参数:**
3734
3735| 参数名 | 类型                                                                                                                      | 必填 | 说明           |
3736| ------ |-------------------------------------------------------------------------------------------------------------------------| ---- | -------------- |
3737| type | string                                                                                                                  | 是   | 回调函数类型名,固定为'checkNotification'。 |
3738| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  [NotificationCheckResult](#notificationcheckresult10) | 是   | 消息验证函数指针。 |
3739
3740**错误码:**
3741
3742以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3743
3744| 错误码ID | 错误信息                            |
3745| -------- | ----------------------------------- |
3746| 202      | Not system application.                                      |
3747| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3748| 1600001  | Internal error.                     |
3749
3750**示例:**
3751
3752```ts
3753import { BusinessError } from '@kit.BasicServicesKit';
3754
3755let onCheckNotification = (info : notificationManager.NotificationCheckInfo): notificationManager.NotificationCheckResult => {
3756    console.info(`====>OnCheckNotification info: ${JSON.stringify(info)}`);
3757    if(info.notificationId == 1){
3758        let result: notificationManager.NotificationCheckResult =  { code: 1, message: "testMsg1"};
3759        return result;
3760    } else {
3761        let result: notificationManager.NotificationCheckResult =   { code: 0, message: "testMsg0"};
3762        return result;
3763    }
3764}
3765try{
3766    notificationManager.on("checkNotification", onCheckNotification);
3767} catch (err){
3768    console.error(`notificationManager.on failed, code is ${err.code}, message is ${err.message}`);
3769}
3770```
3771
3772## notificationManager.on<sup>11+</sup>
3773
3774on(type: 'checkNotification', checkRequest: NotificationCheckRequest, callback: (checkInfo: NotificationCheckInfo) => Promise\<NotificationCheckResult\>): void
3775
3776注册通知监听回调。通知服务将通知信息回调给校验程序,校验程序返回校验结果决定该通知是否发布,如营销类通知发布频率控制等。使用Promise异步回调。
3777
3778系统中每个[SlotType](./js-apis-notificationManager.md#slottype)只允许存在一个注册者。
3779
3780**系统能力**:SystemCapability.Notification.Notification
3781
3782**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3783
3784**系统接口**:此接口为系统接口。
3785
3786**参数:**
3787
3788| 参数名 | 类型                                                                                                             | 必填 | 说明           |
3789| ------ |-----------------------------------------------------------------------------------------------------------------| ---- | -------------- |
3790| type | string                                                                                                            | 是   | 回调函数类型名,固定为'checkNotification'。 |
3791| checkRequest | [NotificationCheckRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationcheckrequest11)    | 是   | 通知请求验证内容。 |
3792| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  Promise\<[NotificationCheckResult](#notificationcheckresult10)\> | 是   | 消息验证函数指针。 |
3793
3794**错误码:**
3795
3796以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3797
3798| 错误码ID | 错误信息                            |
3799| -------- | ----------------------------------- |
3800| 201      | Permission denied.     |
3801| 202      | Not system application.                                      |
3802| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3803| 1600001  | Internal error.                     |
3804| 1600002  | Marshalling or unmarshalling error.      |
3805| 1600003  | Failed to connect to the service.               |
3806
3807**示例:**
3808
3809```ts
3810import { BusinessError } from '@kit.BasicServicesKit';
3811
3812try{
3813  notificationManager.on('checkNotification',{
3814    contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LIVE_VIEW,
3815    slotType: notificationManager.SlotType.LIVE_VIEW ,
3816    extraInfoKeys: ["event"],
3817  },
3818    async (checkInfo)=>{
3819      return { code: 1, message: "INVALID_PARAMETERS"};
3820  },);
3821} catch (err) {
3822  console.error(`notificationManager.on failed, code is ${err.code}, message is ${err.message}`);
3823}
3824```
3825
3826## notificationManager.off<sup>10+</sup>
3827
3828off(type: 'checkNotification', callback?: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void
3829
3830取消通知监听回调。
3831
3832**系统能力**:SystemCapability.Notification.Notification
3833
3834**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3835
3836**系统接口**:此接口为系统接口。
3837
3838**参数:**
3839
3840| 参数名 | 类型                                                                                                                      | 必填 | 说明           |
3841| ------ |-------------------------------------------------------------------------------------------------------------------------| ---- | -------------- |
3842| type | string                                                                                                                  | 是   | 回调函数类型名,固定为'checkNotification'。 |
3843| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  [NotificationCheckResult](#notificationcheckresult10) | 否   | 消息验证函数指针。 |
3844
3845**错误码:**
3846
3847以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3848
3849| 错误码ID | 错误信息                            |
3850| -------- | ----------------------------------- |
3851| 202      | Not system application.                                      |
3852| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3853| 1600001  | Internal error.                     |
3854
3855**示例:**
3856
3857```ts
3858import { BusinessError } from '@kit.BasicServicesKit';
3859
3860try{
3861    notificationManager.off("checkNotification");
3862} catch (err){
3863    console.error(`notificationManager.off failed, code is ${err.code}, message is ${err.message}`);
3864}
3865```
3866
3867## notificationManager.triggerSystemLiveView<sup>11+</sup>
3868
3869triggerSystemLiveView(bundle: BundleOption, notificationId: number, buttonOptions: ButtonOptions): Promise\<void>
3870
3871触发系统实况窗。使用Promise异步回调。
3872
3873**系统能力**:SystemCapability.Notification.Notification
3874
3875**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
3876
3877**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3878
3879**系统接口**:此接口为系统接口。
3880
3881**参数:**
3882
3883| 参数名 | 类型                   | 必填 | 说明           |
3884| -------------- | ------------- | ---- | -------------- |
3885| bundle         | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)  | 是   |指定应用的包信息。 |
3886| notificationId | number        | 是   | 通知ID。 |
3887| buttonOptions  | [ButtonOptions](#buttonoptions11) | 是   | 按钮信息。 |
3888
3889**返回值:**
3890
3891| 类型 | 说明 |
3892| ---- | ----|
3893| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
3894
3895**错误码:**
3896
3897以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
3898
3899| 错误码ID | 错误信息                            |
3900| -------- | ----------------------------------- |
3901| 201      | Permission denied.     |
3902| 202      | Not system application to call the interface.                                      |
3903| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3904| 801 | Capability not supported. |
3905| 1600001  | Internal error.                     |
3906| 1600002  | Marshalling or unmarshalling error. |
3907| 1600003  | Failed to connect to the service.          |
3908| 1600007  | The notification does not exist.      |
3909| 17700001 | The specified bundle name was not found. |
3910
3911**示例:**
3912
3913```ts
3914import { BusinessError } from '@kit.BasicServicesKit';
3915
3916// 包信息
3917let bundle: notificationManager.BundleOption = {
3918    bundle: "bundleName1",
3919};
3920// 通知ID
3921let notificationId = 1;
3922// 按钮信息
3923let buttonOptions: notificationManager.ButtonOptions = {
3924    buttonName: "buttonName1",
3925}
3926notificationManager.triggerSystemLiveView(bundle, notificationId, buttonOptions).then(() => {
3927  console.info("triggerSystemLiveView success");
3928}).catch((err: BusinessError) => {
3929  console.error(`triggerSystemLiveView failed, code is ${err.code}, message is ${err.message}`);
3930});
3931```
3932
3933
3934## notificationManager.subscribeSystemLiveView<sup>11+</sup>
3935
3936subscribeSystemLiveView(subscriber: SystemLiveViewSubscriber): Promise\<void>
3937
3938订阅系统实况窗。使用Promise异步回调。
3939
3940**系统能力**:SystemCapability.Notification.Notification
3941
3942**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
3943
3944**系统接口**:此接口为系统接口。
3945
3946**参数:**
3947
3948| 参数名 | 类型                   | 必填 | 说明           |
3949| -------------- | ------------- | ---- | -------------- |
3950| subscriber | [SystemLiveViewSubscriber](#systemliveviewsubscriber11)  | 是   | 系统实况窗订阅者。|
3951
3952**返回值:**
3953
3954| 类型 | 说明 |
3955| ---- | ----|
3956| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
3957
3958**错误码:**
3959
3960以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3961
3962| 错误码ID | 错误信息                            |
3963| -------- | ----------------------------------- |
3964| 202      | Not system application to call the interface.                                      |
3965| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3966| 801 | Capability not supported. |
3967| 1600001  | Internal error.                     |
3968| 1600002  | Marshalling or unmarshalling error. |
3969| 1600003  | Failed to connect to the service.          |
3970| 1600012  | No memory space.                    |
3971
3972**示例:**
3973
3974```ts
3975import { BusinessError } from '@kit.BasicServicesKit';
3976
3977let onResponseCallback = (id:number, option:notificationManager.ButtonOptions) => {
3978    console.info(`notificationId: ${id},onResponseCallback: ${JSON.stringify(option)}`);
3979}
3980let subscriber: notificationManager.SystemLiveViewSubscriber  = {
3981    onResponse: onResponseCallback,
3982};
3983notificationManager.subscribeSystemLiveView(subscriber).then(() => {
3984	console.info("subscribeSystemLiveView success");
3985}).catch((err: BusinessError) => {
3986    console.error(`subscribeSystemLiveView failed, code is ${err.code}, message is ${err.message}`);
3987});
3988```
3989
3990## notificationManager.setDistributedEnabledByBundle<sup>12+</sup>
3991
3992setDistributedEnabledByBundle(bundle: BundleOption, deviceType: string, enable: boolean): Promise<void\>
3993
3994设置指定应用是否支持跨设备协同。使用Promise异步回调。
3995
3996**系统能力**:SystemCapability.Notification.Notification
3997
3998**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
3999
4000**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4001
4002**系统接口**:此接口为系统接口。
4003
4004**参数:**
4005
4006| 参数名   | 类型                     | 必填 | 说明                       |
4007| -------- | ------------------------ | ---- | -------------------------- |
4008| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包信息。                   |
4009| deviceType | string | 是   | 设备类型。|
4010| enable   | boolean                  | 是   | 指定应用是否支持跨设备协同(true:支持,false:不支持)。|
4011
4012**返回值:**
4013
4014| 类型 | 说明 |
4015| ---- | ----|
4016| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
4017
4018**错误码:**
4019
4020以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4021
4022| 错误码ID | 错误信息                                 |
4023| -------- | ---------------------------------------- |
4024| 201      | Permission denied.     |
4025| 202      | Not system application to call the interface.                                      |
4026| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4027| 801 | Capability not supported. |
4028| 1600001  | Internal error.                          |
4029| 1600002  | Marshalling or unmarshalling error.      |
4030| 1600003  | Failed to connect to the service.               |
4031| 1600010  | Distributed operation failed.            |
4032| 1600012  | No memory space.                    |
4033| 17700001 | The specified bundle name was not found. |
4034
4035**示例:**
4036
4037```ts
4038import { BusinessError } from '@kit.BasicServicesKit';
4039
4040let bundle: notificationManager.BundleOption = {
4041    bundle: "bundleName1",
4042    uid: 1
4043};
4044let enable: boolean = true;
4045let deviceType: string = "phone";
4046notificationManager.setDistributedEnabledByBundle(bundle, deviceType, enable).then(() => {
4047    console.info("setDistributedEnabledByBundle success");
4048}).catch((err: BusinessError) => {
4049    console.error(`setDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
4050});
4051```
4052
4053## notificationManager.isDistributedEnabledByBundle<sup>12+</sup>
4054
4055isDistributedEnabledByBundle(bundle: BundleOption, deviceType: string): Promise<boolean\>
4056
4057获取指定应用是否支持跨设备协同。使用Promise异步回调。
4058
4059**系统能力**:SystemCapability.Notification.Notification
4060
4061**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
4062
4063**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4064
4065**系统接口**:此接口为系统接口。
4066
4067**参数:**
4068
4069| 参数名   | 类型                     | 必填 | 说明                       |
4070| -------- | ------------------------ | ---- | -------------------------- |
4071| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包信息。                   |
4072| deviceType | string | 是   | 设备类型。 |
4073
4074**返回值:**
4075
4076| 类型 | 说明 |
4077| ---- | ----|
4078| Promise\<boolean\> | 以Promise形式返回指定应用是否支持跨设备协同的开关是否开启的结果(true:开启,false:未开启)。 |
4079
4080**错误码:**
4081
4082以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4083
4084| 错误码ID | 错误信息                                 |
4085| -------- | ---------------------------------------- |
4086| 201      | Permission denied.     |
4087| 202      | Not system application to call the interface.                                      |
4088| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4089| 801 | Capability not supported. |
4090| 1600001  | Internal error.                          |
4091| 1600002  | Marshalling or unmarshalling error.      |
4092| 1600003  | Failed to connect to the service.               |
4093| 1600010  | Distributed operation failed.            |
4094| 1600012  | No memory space.                    |
4095| 17700001 | The specified bundle name was not found. |
4096
4097**示例:**
4098
4099```ts
4100import { BusinessError } from '@kit.BasicServicesKit';
4101
4102let bundle: notificationManager.BundleOption = {
4103    bundle: "bundleName1",
4104    uid: 1
4105};
4106let deviceType: string = "phone";
4107notificationManager.isDistributedEnabledByBundle(bundle, deviceType).then((data: boolean) => {
4108    console.info(`isDistributedEnabledByBundle success, data: ${JSON.stringify(data)}`);
4109}).catch((err: BusinessError) => {
4110    console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
4111});
4112```
4113
4114## notificationManager.setSmartReminderEnabled<sup>12+</sup>
4115
4116setSmartReminderEnabled(deviceType: string, enable: boolean): Promise<void\>
4117
4118设置设备是否与其他设备协同智能提醒。使用Promise异步回调。
4119
4120**系统能力**:SystemCapability.Notification.Notification
4121
4122**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
4123
4124**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4125
4126**系统接口**:此接口为系统接口。
4127
4128**参数:**
4129
4130| 参数名   | 类型                     | 必填 | 说明                       |
4131| -------- | ------------------------ | ---- | -------------------------- |
4132| deviceType | string | 是   | 设备类型。 |
4133| enable   | boolean                  | 是   | 指定应用是否支持设备是否与其他设备协同智能提醒(true:支持,false:不支持)。|
4134
4135**返回值:**
4136
4137| 类型 | 说明 |
4138| ---- | ----|
4139| Promise\<void> | Promise对象。无返回结果的Promise对象。 |
4140
4141**错误码:**
4142
4143以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4144
4145| 错误码ID | 错误信息                                 |
4146| -------- | ---------------------------------------- |
4147| 201      | Permission denied.     |
4148| 202      | Not system application to call the interface.                                      |
4149| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4150| 801 | Capability not supported. |
4151| 1600001  | Internal error.                          |
4152| 1600002  | Marshalling or unmarshalling error.      |
4153| 1600003  | Failed to connect to the service.               |
4154| 1600010  | Distributed operation failed.            |
4155| 1600012  | No memory space.                    |
4156| 17700001 | The specified bundle name was not found. |
4157
4158**示例:**
4159
4160```ts
4161import { BusinessError } from '@kit.BasicServicesKit';
4162
4163let deviceType: string = "phone";
4164let enable: boolean = true;
4165notificationManager.setSmartReminderEnabled(deviceType, enable).then(() => {
4166    console.info("setSmartReminderEnabled success");
4167}).catch((err: BusinessError) => {
4168    console.error(`setSmartReminderEnabled failed, code is ${err.code}, message is ${err.message}`);
4169});
4170```
4171
4172## notificationManager.isSmartReminderEnabled<sup>12+</sup>
4173
4174isSmartReminderEnabled(deviceType: string): Promise<boolean\>
4175
4176获取设备是否与其他设备协同智能提醒。使用Promise异步回调。
4177
4178**系统能力**:SystemCapability.Notification.Notification
4179
4180**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
4181
4182**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4183
4184**系统接口**:此接口为系统接口。
4185
4186**参数:**
4187
4188| 参数名   | 类型                     | 必填 | 说明                       |
4189| -------- | ------------------------ | ---- | -------------------------- |
4190| deviceType | string | 是   | 设备类型。 |
4191
4192**返回值:**
4193
4194| 类型 | 说明 |
4195| ---- | ----|
4196| Promise\<boolean\> | 以Promise形式返回设备与其他设备协同智能提醒的开关是否开启的结果(true:开启,false:未开启)。 |
4197
4198**错误码:**
4199
4200以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4201
4202| 错误码ID | 错误信息                                 |
4203| -------- | ---------------------------------------- |
4204| 201      | Permission denied.     |
4205| 202      | Not system application to call the interface.                                      |
4206| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4207| 801 | Capability not supported. |
4208| 1600001  | Internal error.                          |
4209| 1600002  | Marshalling or unmarshalling error.      |
4210| 1600003  | Failed to connect to the service.               |
4211| 1600010  | Distributed operation failed.            |
4212| 1600012  | No memory space.                    |
4213| 17700001 | The specified bundle name was not found. |
4214
4215**示例:**
4216
4217```ts
4218import { BusinessError } from '@kit.BasicServicesKit';
4219
4220let deviceType: string = "phone";
4221notificationManager.isSmartReminderEnabled(deviceType).then((data: boolean) => {
4222    console.info(`isSmartReminderEnabled success, data:${data}`);
4223}).catch((err: BusinessError) => {
4224    console.error(`isSmartReminderEnabled failed, code is ${err.code}, message is ${err.message}`);
4225});
4226```
4227
4228## notificationManager.setBadgeNumberByBundle<sup>12+</sup>
4229
4230setBadgeNumberByBundle(bundle: BundleOption, badgeNumber: number): Promise\<void\>
4231
4232代理其他应用设定角标个数。使用Promise异步回调。
4233
4234**系统能力**:SystemCapability.Notification.Notification
4235
4236**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
4237
4238**系统接口**:此接口为系统接口。
4239
4240**参数:**
4241
4242| 参数名      | 类型   | 必填 | 说明       |
4243| ----------- | ------ | ---- | ---------- |
4244| bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
4245| badgeNumber | number | 是   | 角标个数。 |
4246
4247**返回值:**
4248
4249| 类型            | 说明                      |
4250| --------------- | ------------------------- |
4251| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
4252
4253**错误码:**
4254
4255以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4256
4257| 错误码ID | 错误信息                            |
4258| -------- | ----------------------------------- |
4259| 202      | Not system application to call the interface.                                      |
4260| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4261| 801 | Capability not supported. |
4262| 1600001  | Internal error.                     |
4263| 1600002  | Marshalling or unmarshalling error. |
4264| 1600003  | Failed to connect to the service.          |
4265| 1600012  | No memory space.                    |
4266| 1600017  | There is no corresponding agent relationship configuration.     |
4267| 17700001 | The specified bundle name was not found.   |
4268
4269**示例:**
4270
4271```ts
4272import { BusinessError } from '@kit.BasicServicesKit';
4273
4274let bundle: notificationManager.BundleOption = {
4275    bundle: 'com.example.bundleName',
4276};
4277let badgeNumber: number = 10;
4278
4279notificationManager.setBadgeNumberByBundle(bundle, badgeNumber).then(() => {
4280    console.info('setBadgeNumberByBundle success');
4281}).catch((err: BusinessError) => {
4282    console.error(`setBadgeNumberByBundle failed, code is ${err.code}, message is ${err.message}`);
4283});
4284```
4285
4286## notificationManager.getSlotByBundle<sup>12+</sup>
4287
4288getSlotByBundle(bundle: BundleOption, slotType: SlotType): Promise\<NotificationSlot>
4289
4290获取指定应用指定类型的通知渠道。使用Promise异步回调。
4291
4292获取前需要先通过[addSlot](#notificationmanageraddslot)创建通知渠道。
4293
4294**系统能力**:SystemCapability.Notification.Notification
4295
4296**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
4297
4298**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4299
4300**系统接口**:此接口为系统接口。
4301
4302**参数:**
4303
4304| 参数名   | 类型         | 必填 | 说明       |
4305| ------ | ------------ | ---- | ---------- |
4306| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
4307| slotType | [SlotType](././js-apis-notificationManager.md#slottype) | 是   | 渠道类型。 |
4308
4309**返回值:**
4310
4311| 类型                                                        | 说明                                                         |
4312| ----------------------------------------------------------- | ------------------------------------------------------------ |
4313| Promise\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)> | 以Promise形式返回获取指定应用指定类型的通知渠道。 |
4314
4315**错误码:**
4316
4317以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4318
4319| 错误码ID | 错误信息                                 |
4320| -------- | ---------------------------------------- |
4321| 201      | Permission denied.     |
4322| 202      | Not system application to call the interface.                                      |
4323| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4324| 801 | Capability not supported. |
4325| 1600001  | Internal error.                          |
4326| 1600002  | Marshalling or unmarshalling error.      |
4327| 1600003  | Failed to connect to the service.               |
4328| 1600012  | No memory space.                         |
4329| 17700001 | The specified bundle name was not found. |
4330
4331**示例:**
4332
4333```ts
4334import { BusinessError } from '@kit.BasicServicesKit';
4335
4336let bundle: notificationManager.BundleOption = {
4337    bundle: "bundleName1",
4338};
4339
4340let slotType = notificationManager.SlotType.LIVE_VIEW;
4341
4342notificationManager.getSlotByBundle(bundle, slotType).then((data: notificationManager.NotificationSlot) => {
4343	console.info(`getSlotByBundle success, data: ${JSON.stringify(data)}`);
4344}).catch((err: BusinessError) => {
4345    console.error(`getSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
4346});
4347```
4348
4349## notificationManager.addDoNotDisturbProfile<sup>12+</sup>
4350
4351addDoNotDisturbProfile(templates: Array\<DoNotDisturbProfile>): Promise\<void\>
4352
4353添加勿扰模式配置信息。使用Promise异步回调。
4354
4355**系统能力**:SystemCapability.Notification.Notification
4356
4357**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
4358
4359**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4360
4361**系统接口**:此接口为系统接口。
4362
4363**参数:**
4364
4365| 参数名   | 类型             | 必填 | 说明           |
4366| ------ | ---------------- | ---- | -------------- |
4367| templates   | Array\<[DoNotDisturbProfile](#donotdisturbprofile12)> | 是 | 勿扰模式的配置信息。 |
4368
4369**返回值:**
4370
4371| 类型      | 说明        |
4372|---------|-----------|
4373| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
4374
4375**错误码:**
4376
4377以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4378
4379| 错误码ID | 错误信息                            |
4380| -------- | ----------------------------------- |
4381| 201      | Permission denied.     |
4382| 202      | Not system application to call the interface.                                      |
4383| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4384| 801 | Capability not supported. |
4385| 1600001  | Internal error.                     |
4386| 1600002  | Marshalling or unmarshalling error. |
4387| 1600003  | Failed to connect to the service.          |
4388| 1600012  | No memory space.                    |
4389
4390**示例:**
4391
4392```ts
4393import { BusinessError } from '@kit.BasicServicesKit';
4394
4395let trustlist: Array<notificationManager.BundleOption> = [
4396  {
4397    bundle: 'com.example.bundleName',
4398    uid: 0
4399  },
4400  {
4401    bundle: 'com.example.bundleName1',
4402    uid: 1
4403  }
4404]
4405let templates: Array<notificationManager.DoNotDisturbProfile> = [
4406  {
4407    id: 3,
4408    name: '工作模式',
4409    trustlist: trustlist
4410  }
4411]
4412
4413notificationManager.addDoNotDisturbProfile(templates).then(() => {
4414  console.info("addDoNotDisturbProfile success.");
4415}).catch((err: BusinessError) => {
4416  console.error(`addDoNotDisturbProfile failed, code is ${err.code}, message is ${err.message}`);
4417});
4418```
4419
4420## notificationManager.removeDoNotDisturbProfile<sup>12+</sup>
4421
4422removeDoNotDisturbProfile(templates: Array\<DoNotDisturbProfile>): Promise\<void\>
4423
4424删除勿扰模式配置。使用Promise异步回调。
4425
4426**系统能力**:SystemCapability.Notification.Notification
4427
4428**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
4429
4430**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4431
4432**系统接口**:此接口为系统接口。
4433
4434**参数:**
4435
4436| 参数名   | 类型             | 必填 | 说明           |
4437| ------ | ---------------- | ---- | -------------- |
4438| templates   | Array\<[DoNotDisturbProfile](#donotdisturbprofile12)> | 是  | 勿扰模式的配置信息。 |
4439
4440**返回值:**
4441
4442| 类型      | 说明        |
4443|---------|-----------|
4444| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
4445
4446**错误码:**
4447
4448以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4449
4450| 错误码ID | 错误信息                            |
4451| -------- | ----------------------------------- |
4452| 201      | Permission denied.     |
4453| 202      | Not system application to call the interface.                                      |
4454| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4455| 801 | Capability not supported. |
4456| 1600001  | Internal error.                     |
4457| 1600002  | Marshalling or unmarshalling error. |
4458| 1600003  | Failed to connect to the service.          |
4459| 1600012  | No memory space.                    |
4460
4461**示例:**
4462
4463```ts
4464import { BusinessError } from '@kit.BasicServicesKit';
4465
4466let templates: Array<notificationManager.DoNotDisturbProfile> = [
4467  {
4468    id: 3,
4469    name: '工作模式'
4470  }
4471]
4472notificationManager.removeDoNotDisturbProfile(templates).then(() => {
4473  console.info("removeDoNotDisturbProfile success.");
4474}).catch((err: BusinessError) => {
4475  console.error(`removeDoNotDisturbProfile failed, code is ${err.code}, message is ${err.message}`);
4476});
4477```
4478
4479## notificationManager.setAdditionalConfig<sup>12+</sup>
4480
4481setAdditionalConfig(key: string, value: string): Promise\<number\>
4482
4483设置通知的系统附加配置信息。使用Promise异步回调。
4484
4485**系统能力**:SystemCapability.Notification.Notification
4486
4487**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
4488
4489**需要权限**:ohos.permission.NOTIFICATION_AGENT_CONTROLLER
4490
4491**系统接口**:此接口为系统接口。
4492
4493**参数:**
4494
4495| 参数名   | 类型             | 必填 | 说明           |
4496| ------ | ---------------- | ---- | -------------- |
4497| key   | string | 是  | 附加配置键。目前仅支持`RING_TRUSTLIST_PKG`,表示应用支持使用[自定义铃声](./js-apis-inner-notification-notificationRequest.md#notificationrequest-1)。 |
4498| value   | string | 是  | 附加配置值。参数示例:[bundleName1,bundleName2]。 |
4499
4500**返回值:**
4501
4502| 类型      | 说明        |
4503|---------|-----------|
4504| Promise\<number\> | Promise对象,返回0表示设置成功,返回其他值表示设置失败。 |
4505
4506**错误码:**
4507
4508以下错误码的详细介绍请参见[通知错误码](./errorcode-notification.md)。
4509
4510| 错误码ID | 错误信息                            |
4511| -------- | ----------------------------------- |
4512| 201      | Permission denied.     |
4513| 202      | Not system application to call the interface.                                      |
4514| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4515| 801 | Capability not supported. |
4516| 1600001  | Internal error.                     |
4517| 1600002  | Marshalling or unmarshalling error. |
4518| 1600003  | Failed to connect to the service.          |
4519
4520**示例:**
4521
4522```ts
4523import { BusinessError } from '@kit.BasicServicesKit';
4524
4525notificationManager.setAdditionalConfig('RING_TRUSTLIST_PKG','[bundleName1,bundleName2]').then((data: number) => {
4526  console.info(`setAdditionalConfig success, data: ${JSON.stringify(data)}`);
4527}).catch((err: BusinessError) => {
4528  console.error(`setAdditionalConfig failed, code is ${err.code}, message is ${err.message}`);
4529});
4530```
4531
4532## notificationManager.getDoNotDisturbProfile<sup>13+</sup>
4533
4534getDoNotDisturbProfile(id: number): Promise\<DoNotDisturbProfile\>
4535
4536查询勿扰模式配置信息。使用Promise异步回调。
4537
4538**系统能力**:SystemCapability.Notification.Notification
4539
4540**设备行为差异**:该接口在Wearable、TV中返回801错误码,在其他设备类型中可正常调用。
4541
4542**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4543
4544**系统接口**:此接口为系统接口。
4545
4546**参数:**
4547
4548| 参数名   | 类型             | 必填 | 说明           |
4549| ------ | ---------------- | ---- | -------------- |
4550| id   | number | 是  | 勿扰模式编号。 |
4551
4552**返回值:**
4553
4554| 类型      | 说明        |
4555|---------|-----------|
4556| Promise\<[DoNotDisturbProfile](#donotdisturbprofile12)\> | Promise对象,返回勿扰模式的配置信息。 |
4557
4558**错误码:**
4559
4560以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4561
4562| 错误码ID | 错误信息                            |
4563| -------- | ----------------------------------- |
4564| 201      | Permission denied.     |
4565| 202      | Not system application to call the interface.                                      |
4566| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4567| 801 | Capability not supported. |
4568| 1600001  | Internal error.                     |
4569| 1600002  | Marshalling or unmarshalling error. |
4570| 1600003  | Failed to connect to the service.          |
4571| 1600019  | The do-not-disturb profile does not exist.                    |
4572
4573**示例:**
4574
4575```ts
4576import { BusinessError } from '@kit.BasicServicesKit';
4577
4578notificationManager.getDoNotDisturbProfile(1).then((data: notificationManager.DoNotDisturbProfile) => {
4579  console.info(`getDoNotDisturbProfile success: ${JSON.stringify(data)}`);
4580}).catch((err: BusinessError) => {
4581  console.error(`getDoNotDisturbProfile failed, code is ${err.code}, message is ${err.message}`);
4582});
4583```
4584
4585## notificationManager.disableNotificationFeature<sup>18+</sup>
4586
4587disableNotificationFeature(disabled: boolean, bundleList: Array\<string\>): Promise\<void\>
4588
4589将应用包名添加到通知发布权限管控名单,以阻止应用发布通知。支持启用或关闭该功能。
4590
4591**系统能力**:SystemCapability.Notification.Notification
4592
4593**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
4594
4595**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.MANAGE_EDM_POLICY
4596
4597**系统接口**:此接口为系统接口。
4598
4599**参数:**
4600
4601| 参数名   | 类型                                                         | 必填 | 说明                     |
4602| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4603| disabled | boolean | 是   | 是否启用通知发布权限管控名单(true:开启,false:关闭)。 |
4604| bundleList | Array\<string\> | 是   | 指定通知发布权限管控名单的应用列表,使用包名代表应用。 |
4605
4606**返回值:**
4607
4608| 类型            | 说明                     |
4609|-----------------|-------------------------|
4610| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
4611
4612**错误码**:
4613
4614以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4615
4616| 错误码ID | 错误信息                                                     |
4617| -------- | ------------------------------------------------------------ |
4618| 201      | Permission denied. |
4619| 202      | Not system application to call the interface. |
4620| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4621| 801 | Capability not supported. |
4622| 1600001      | Internal error.                     |
4623| 1600002      | Marshalling or unmarshalling error. |
4624
4625**示例:**
4626
4627```ts
4628import { BusinessError } from '@kit.BasicServicesKit';
4629import { hilog } from '@kit.PerformanceAnalysisKit';
4630
4631let disabled: boolean = true;
4632let bundleList: Array<string> = ["com.example.myapplication"];
4633try {
4634  notificationManager.disableNotificationFeature(disabled, bundleList).then(() => {
4635    hilog.info(0x0000, 'testTag', '%{public}s', `disableNotificationFeature success.`);
4636  }).catch((err: BusinessError) => {
4637    hilog.error(0x0000, 'testTag', '%{public}s', `disableNotificationFeature failed, code is ${err.code}, message is ${err.message}`);
4638  });
4639} catch (err) {
4640  hilog.error(0x0000, 'testTag', '%{public}s', `testTag failed, code is ${err.code}, message is ${err.message}`);
4641}
4642```
4643
4644## notificationManager.disableNotificationFeature<sup>20+</sup>
4645
4646disableNotificationFeature(disabled: boolean, bundleList: Array\<string\>, userId: number): Promise\<void\>
4647
4648将应用包名添加到通知发布权限管控名单,以阻止应用发布通知。使用Promise异步回调。
4649
4650**系统能力**:SystemCapability.Notification.Notification
4651
4652**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
4653
4654**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.MANAGE_EDM_POLICY
4655
4656**系统接口**:此接口为系统接口。
4657
4658**参数:**
4659
4660| 参数名   | 类型                                                         | 必填 | 说明                     |
4661| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4662| disabled | boolean | 是   | 表示是否启用通知发布权限管控名单。true表示启用,false表示关闭。 |
4663| bundleList | Array\<string\> | 是   | 指定通知发布权限管控名单的应用列表,使用包名表示应用。 |
4664| userId | number | 是   | 表示用户ID。 |
4665
4666**返回值:**
4667
4668| 类型            | 说明                     |
4669|-----------------|-------------------------|
4670| Promise\<void\> | Promise对象,无返回结果。 |
4671
4672**错误码**:
4673
4674以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4675
4676| 错误码ID | 错误信息                                                     |
4677| -------- | ------------------------------------------------------------ |
4678| 201      | Permission verification failed. The application does not have the permission required to call the API. |
4679| 202      | Permission verification failed. A non-system application calls a system API. |
4680| 1600001      | Internal error.                     |
4681| 1600002      | Marshalling or unmarshalling error. |
4682
4683**示例:**
4684
4685```ts
4686import { BusinessError } from '@kit.BasicServicesKit';
4687import { hilog } from '@kit.PerformanceAnalysisKit';
4688
4689let disabled: boolean = true;
4690let bundleList: Array<string> = ["com.example.myapplication"];
4691let userId: number = 1;
4692try {
4693  notificationManager.disableNotificationFeature(disabled, bundleList, userId).then(() => {
4694    hilog.info(0x0000, 'testTag', '%{public}s', `disableNotificationFeature success.`);
4695  }).catch((err: BusinessError) => {
4696    hilog.error(0x0000, 'testTag', '%{public}s', `disableNotificationFeature failed, code is ${err.code}, message is ${err.message}`);
4697  });
4698} catch (err) {
4699  hilog.error(0x0000, 'testTag', '%{public}s', `testTag failed, code is ${err.code}, message is ${err.message}`);
4700}
4701```
4702
4703## notificationManager.setTargetDeviceStatus<sup>18+</sup>
4704
4705setTargetDeviceStatus(deviceType: string, status: number): Promise\<void\>
4706
4707设置设备配对成功后的状态。当发布通知时,会根据各个设备的状态来确定当前设备的通知提醒方式。
4708
4709**系统能力**:SystemCapability.Notification.Notification
4710
4711**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4712
4713**系统接口**:此接口为系统接口。
4714
4715**参数:**
4716
4717| 参数名   | 类型                                                         | 必填 | 说明                     |
4718| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4719| deviceType | string | 是   | 设备类型。当前仅支持`headset`(可穿戴式音频设备)、`liteWearable`(轻量级智能穿戴设备)、`wearable`(智能穿戴设备)、`current`(本设备)。 |
4720| status | number | 是   | 设备状态。<br>- bit0:设备是否正在被使用。0表示未使用,1表示使用中。<br>- bit1:当前设备使用者是否为机主。0表示为非机主,1表示为机主。<br>- bit2:设备是否处于勿扰模式。0表示处于非勿扰模式,1表示处于勿扰模式。 |
4721
4722**返回值:**
4723
4724| 类型            | 说明                     |
4725|-----------------|-------------------------|
4726| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
4727
4728**错误码**:
4729
4730以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
4731
4732| 错误码ID | 错误信息                                                     |
4733| -------- | ------------------------------------------------------------ |
4734| 201      | Permission denied. |
4735| 202      | Not system application to call the interface. |
4736| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4737
4738**示例:**
4739
4740```ts
4741import { BusinessError } from '@kit.BasicServicesKit';
4742
4743notificationManager.setTargetDeviceStatus("current", 1).then(() => {
4744  console.info(`Succeeded in setting target device status.`);
4745}).catch((err: BusinessError) => {
4746  console.error(`Failed to set target device status. Code is ${err.code}, message is ${err.message}`);
4747});
4748```
4749
4750## notificationManager.setDistributedEnabledBySlot<sup>18+</sup>
4751
4752setDistributedEnabledBySlot(slot: SlotType, deviceType: string, enabled: boolean): Promise\<void\>
4753
4754设置指定渠道的通知是否支持通知跨设备协同至指定类型设备。使用Promise异步回调。
4755
4756**系统能力**:SystemCapability.Notification.Notification
4757
4758**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4759
4760**系统接口**:此接口为系统接口。
4761
4762**参数:**
4763
4764| 参数名   | 类型                                                         | 必填 | 说明                     |
4765| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4766| slot | [SlotType](js-apis-notificationManager.md#slottype) | 是   | 通知渠道类型。 |
4767| deviceType | string | 是   | 设备类型。<br>从API version 18开始,支持的设备类型如下:<br>- headset(可穿戴式音频设备)。<br>- liteWearable(轻量级智能穿戴设备)。<br>- wearable(智能穿戴设备)。<br>从API version 20开始,支持的设备类型如下:<br>- headset(可穿戴式音频设备)。<br>- liteWearable(轻量级智能穿戴设备)。<br>- wearable(智能穿戴设备)。<br>- current(本设备)。<br>- 2in1(PC设备)。<br>- tablet(平板)。 |
4768| enabled | boolean | 是   | 是否开启通知跨设备协同开关。取值为true表示打开,取值为false表示关闭。 |
4769
4770**返回值:**
4771
4772| 类型            | 说明                     |
4773|-----------------|-------------------------|
4774| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
4775
4776**错误码**:
4777
4778以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
4779
4780| 错误码ID | 错误信息                                                     |
4781| -------- | ------------------------------------------------------------ |
4782| 201      | Permission denied. |
4783| 202      | Not system application to call the interface. |
4784| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4785
4786**示例:**
4787
4788```ts
4789import { BusinessError } from '@kit.BasicServicesKit';
4790import { hilog } from '@kit.PerformanceAnalysisKit';
4791
4792let slot: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
4793let deviceType: string = 'wearable';
4794let enabled: boolean = true;
4795
4796notificationManager.setDistributedEnabledBySlot(slot, deviceType, enabled).then(() => {
4797    hilog.info(0x0000, 'testTag', '%{public}s', `setDistributedEnabledBySlot success.`);
4798}).catch((err: BusinessError) => {
4799    hilog.error(0x0000, 'testTag', '%{public}s', `setDistributedEnabledBySlot failed, code is ${err.code}, message is ${err.message}`);
4800});
4801```
4802
4803## notificationManager.isDistributedEnabledBySlot<sup>18+</sup>
4804
4805isDistributedEnabledBySlot(slot: SlotType, deviceType: string): Promise\<boolean\>
4806
4807查询指定渠道的通知是否支持通知跨设备协同至指定类型设备。使用Promise异步回调。
4808
4809**系统能力**:SystemCapability.Notification.Notification
4810
4811**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4812
4813**系统接口**:此接口为系统接口。
4814
4815**参数:**
4816
4817| 参数名   | 类型                                                         | 必填 | 说明                     |
4818| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4819| slot | [SlotType](js-apis-notificationManager.md#slottype) | 是   | 通知渠道类型。 |
4820| deviceType | string | 是   | 设备类型。<br>从API version 18开始,支持的设备类型如下:<br>- headset(可穿戴式音频设备)。<br>- liteWearable(轻量级智能穿戴设备)。<br>- wearable(智能穿戴设备)。<br>从API version 20开始,支持的设备类型如下:<br>- headset(可穿戴式音频设备)。<br>- liteWearable(轻量级智能穿戴设备)。<br>- wearable(智能穿戴设备)。<br>- current(本设备)。<br>- 2in1(PC设备)。<br>- tablet(平板)。 |
4821
4822**返回值:**
4823
4824| 类型            | 说明                     |
4825|-----------------|-------------------------|
4826| Promise\<boolean\> | Promise对象,返回true表示指定渠道的通知支持通知跨设备协同至指定类型设备;返回false表示指定渠道的通知不支持通知跨设备协同至指定类型设备。 |
4827
4828**错误码**:
4829
4830以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
4831
4832| 错误码ID | 错误信息                                                     |
4833| -------- | ------------------------------------------------------------ |
4834| 201      | Permission denied. |
4835| 202      | Not system application to call the interface. |
4836| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4837
4838**示例:**
4839
4840```ts
4841import { BusinessError } from '@kit.BasicServicesKit';
4842import { hilog } from '@kit.PerformanceAnalysisKit';
4843
4844let slot: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
4845let deviceType: string = 'wearable';
4846
4847notificationManager.isDistributedEnabledBySlot(slot, deviceType).then((data: boolean) => {
4848    hilog.info(0x0000, 'testTag', '%{public}s', `isDistributedEnabledBySlot success.`);
4849}).catch((err: BusinessError) => {
4850    hilog.error(0x0000, 'testTag', '%{public}s', `isDistributedEnabledBySlot failed, code is ${err.code}, message is ${err.message}`);
4851});
4852```
4853
4854## notificationManager.setSilentReminderEnabled<sup>20+</sup>
4855
4856setSilentReminderEnabled(bundle: BundleOption, enabled: boolean): Promise\<void\>
4857
4858设置静默提醒的开关状态。使用Promise进行异步回调。
4859
4860**系统能力**:SystemCapability.Notification.Notification
4861
4862**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4863
4864**系统接口**:此接口为系统接口。
4865
4866**参数:**
4867
4868| 参数名   | 类型                                                         | 必填 | 说明                     |
4869| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4870| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
4871| enabled | boolean | 是   | 表示是否开启通知静默提醒开关。true表示打开,false表示关闭。 |
4872
4873**返回值:**
4874
4875| 类型            | 说明                     |
4876|-----------------|-------------------------|
4877| Promise\<void\> | Promise对象,无返回结果。 |
4878
4879**错误码**:
4880
4881以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4882
4883| 错误码ID | 错误信息                                                     |
4884| -------- | ------------------------------------------------------------ |
4885| 201      | Permission denied.     |
4886| 202      | Not system application to call the interface.                                      |
4887| 1600001  | Internal error.                     |
4888| 1600002  | Marshalling or unmarshalling error. |
4889| 1600003  | Failed to connect to the service.          |
4890| 1600012  | No memory space.                          |
4891| 17700001 | The specified bundle name was not found. |
4892
4893**示例:**
4894
4895```ts
4896import { BusinessError } from '@kit.BasicServicesKit';
4897import { hilog } from '@kit.PerformanceAnalysisKit';
4898
4899let bundle: notificationManager.BundleOption = {
4900    bundle: "bundleName",
4901};
4902notificationManager.setSilentReminderEnabled(bundle, true).then(() => {
4903    hilog.info(0x0000, 'testTag', '%{public}s', `setSilentReminderEnabled success.`);
4904}).catch((err: BusinessError) => {
4905    hilog.error(0x0000, 'testTag', '%{public}s', `setSilentReminderEnabled failed, code is ${err.code}, message is ${err.message}`);
4906});
4907```
4908
4909## notificationManager.isSilentReminderEnabled<sup>20+</sup>
4910
4911isSilentReminderEnabled(bundle: BundleOption): Promise\<SwitchState\>
4912
4913查询静默提醒的开关状态。使用Promise进行异步回调。
4914
4915**系统能力**:SystemCapability.Notification.Notification
4916
4917**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4918
4919**系统接口**:此接口为系统接口。
4920
4921**参数:**
4922
4923| 参数名   | 类型                                                         | 必填 | 说明                     |
4924| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4925| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
4926
4927**返回值:**
4928
4929| 类型            | 说明                     |
4930|-----------------|-------------------------|
4931| Promise\<[SwitchState](#switchstate20)\> | Promise对象,返回指定应用的通知静默提醒开关状态。 |
4932
4933**错误码**:
4934
4935以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
4936
4937| 错误码ID | 错误信息                                                     |
4938| -------- | ------------------------------------------------------------ |
4939| 201      | Permission denied.     |
4940| 202      | Not system application to call the interface.                                      |
4941| 1600001  | Internal error.                     |
4942| 1600002  | Marshalling or unmarshalling error. |
4943| 1600003  | Failed to connect to the service.          |
4944| 1600012  | No memory space.                          |
4945| 17700001 | The specified bundle name was not found. |
4946
4947**示例:**
4948
4949```ts
4950import { BusinessError } from '@kit.BasicServicesKit';
4951import { hilog } from '@kit.PerformanceAnalysisKit';
4952
4953let bundle: notificationManager.BundleOption = {
4954    bundle: "bundleName1",
4955};
4956notificationManager.isSilentReminderEnabled(bundle).then((data: notificationManager.SwitchState) => {
4957    hilog.info(0x0000, 'testTag', '%{public}s', `isSilentReminderEnabled success, switchState:  ${JSON.stringify(data)}.`);
4958}).catch((err: BusinessError) => {
4959    hilog.error(0x0000, 'testTag', '%{public}s', `isSilentReminderEnabled failed, code is ${err.code}, message is ${err.message}`);
4960});
4961```
4962
4963## notificationManager.isDistributedEnabled<sup>20+</sup>
4964
4965isDistributedEnabled(deviceType: string): Promise\<boolean\>
4966
4967查询设备是否支持跨设备协同通知。使用Promise异步回调。
4968
4969**系统能力**:SystemCapability.Notification.Notification
4970
4971**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4972
4973**系统接口**:此接口为系统接口。
4974
4975**参数:**
4976
4977| 参数名   | 类型                                                         | 必填 | 说明                     |
4978| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4979| deviceType | string | 是   | 设备类型。当前仅支持以下类型:<br>- headset(可穿戴式音频设备)。<br>- liteWearable(轻量级智能穿戴设备)。<br>- wearable(智能穿戴设备)。<br>- current(本设备)。<br>- 2in1(PC设备)。<br>- tablet(平板)。 |
4980
4981**返回值:**
4982
4983| 类型            | 说明                     |
4984|-----------------|-------------------------|
4985| Promise\<boolean\> | 返回设备是否支持跨设备协同通知的结果,返回true表示支持;返回false表示不支持。Promise对象。 |
4986
4987**错误码**:
4988
4989以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)
4990
4991| 错误码ID | 错误信息                                                     |
4992| -------- | ------------------------------------------------------------ |
4993| 201      | Permission denied. |
4994| 202      | Not system application to call the interface. |
4995
4996**示例:**
4997
4998```ts
4999import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
5000import { BusinessError } from '@kit.BasicServicesKit';
5001
5002export default class EntryAbility extends UIAbility {
5003  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
5004  }
5005
5006  onForeground(): void {
5007    try {
5008      let deviceType: string = "wearable";
5009      notificationManager.isDistributedEnabled(deviceType).then((data: boolean) => {
5010        console.info('isDistributedEnabled succeeded, result = ' + data);
5011      }).catch((err: BusinessError) => {
5012        console.error(`isDistributedEnabled failed. Code is ${err.code}, message is ${err.message}`);
5013      });
5014    } catch (err) {
5015      console.error(`isDistributedEnabled failed. Code is ${err.code}, message is ${err.message}`);
5016    }
5017  }
5018}
5019```
5020
5021## notificationManager.setDistributedEnabled<sup>20+</sup>
5022
5023setDistributedEnabled(enable: boolean, deviceType: string): Promise\<void\>
5024
5025设置设备是否支持跨设备协同通知。使用Promise异步回调。
5026
5027**系统能力**:SystemCapability.Notification.Notification
5028
5029**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
5030
5031**系统接口**:此接口为系统接口。
5032
5033**参数:**
5034
5035| 参数名   | 类型                                                         | 必填 | 说明                     |
5036| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
5037| enable   | boolean | 是   | 表示指定设备类型是否支持跨设备协同通知。true表示支持,false表示不支持。 |
5038| deviceType | string | 是   | 设备类型。当前仅支持以下类型:<br>- headset(可穿戴式音频设备)。<br>- liteWearable(轻量级智能穿戴设备)。<br>- wearable(智能穿戴设备)。<br>- current(本设备)。<br>- 2in1(PC设备)。<br>- tablet(平板)。 |
5039
5040**返回值:**
5041
5042| 类型            | 说明                     |
5043|-----------------|-------------------------|
5044| Promise\<void\> | 无返回结果。Promise对象。 |
5045
5046**错误码**:
5047
5048以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)
5049
5050| 错误码ID | 错误信息                                                     |
5051| -------- | ------------------------------------------------------------ |
5052| 201      | Permission denied. |
5053| 202      | Not system application to call the interface. |
5054
5055**示例:**
5056
5057```ts
5058import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
5059import { BusinessError } from '@kit.BasicServicesKit';
5060
5061export default class EntryAbility extends UIAbility {
5062  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
5063  }
5064
5065  onForeground(): void {
5066    try {
5067      let isEnable: boolean = true;
5068      let deviceType: string = "wearable";
5069      notificationManager.setDistributedEnabled(isEnable, deviceType).then(() => {
5070        console.info('setDistributedEnabled succeeded.');
5071      }).catch((err: BusinessError) => {
5072        console.error(`setDistributedEnabled failed. Code is ${err.code}, message is ${err.message}`);
5073      });
5074    } catch (err) {
5075      console.error(`setDistributedEnabled failed. Code is ${err.code}, message is ${err.message}`);
5076    }
5077  }
5078}
5079```
5080
5081## notificationManager.getDistributedDeviceList<sup>20+</sup>
5082
5083getDistributedDeviceList(): Promise\<Array\<string\>\>
5084
5085查询支持跨设备协同通知的设备类型。使用Promise异步回调。
5086
5087**系统能力**:SystemCapability.Notification.Notification
5088
5089**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
5090
5091**系统接口**:此接口为系统接口。
5092
5093**返回值:**
5094
5095| 类型            | 说明                     |
5096|-----------------|-------------------------|
5097| Promise\<Array\<string\>\> | 返回支持跨设备协同通知的设备列表。Promise对象。 |
5098
5099**错误码**:
5100
5101以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)
5102
5103| 错误码ID | 错误信息                                                     |
5104| -------- | ------------------------------------------------------------ |
5105| 201      | Permission denied. |
5106| 202      | Not system application to call the interface. |
5107
5108**示例:**
5109
5110```ts
5111import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
5112import { BusinessError } from '@kit.BasicServicesKit';
5113
5114export default class EntryAbility extends UIAbility {
5115  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
5116  }
5117
5118  onForeground(): void {
5119    try {
5120      notificationManager.getDistributedDeviceList().then((data: Array<string>) => {
5121        console.info('getDistributedDeviceList succeeded, result = ' + data);
5122      }).catch((err: BusinessError) => {
5123        console.error(`getDistributedDeviceList failed. Code is ${err.code}, message is ${err.message}`);
5124      });
5125    } catch (err) {
5126      console.error(`getDistributedDeviceList failed. Code is ${err.code}, message is ${err.message}`);
5127    }
5128  }
5129}
5130```
5131
5132## DoNotDisturbDate
5133
5134**系统能力**:SystemCapability.Notification.Notification
5135
5136**系统接口**:此接口为系统接口。
5137
5138| 名称  | 类型                                  | 必填 | 说明                   |
5139| ----- | ------------------------------------- | ---- | ---------------------- |
5140| type  | [DoNotDisturbType](#donotdisturbtype) | 是   | 免打扰设置的时间类型。 |
5141| begin | Date                                  | 是   | 免打扰设置的起点时间。 |
5142| end   | Date                                  | 是   | 免打扰设置的终点时间。 |
5143
5144## DoNotDisturbType
5145
5146**系统能力**:SystemCapability.Notification.Notification
5147
5148**系统接口**:此接口为系统接口。
5149
5150| 名称         | 值               | 说明                                       |
5151| ------------ | ---------------- | ------------------------------------------ |
5152| TYPE_NONE    | 0 | 非通知勿扰类型。                           |
5153| TYPE_ONCE    | 1 | 以设置时间段(只看小时和分钟)一次执行勿扰。 |
5154| TYPE_DAILY   | 2 | 以设置时间段(只看小时和分钟)每天执行勿扰。 |
5155| TYPE_CLEARLY | 3 | 以设置时间段(明确月日时)执行勿扰。     |
5156
5157
5158## DeviceRemindType
5159
5160**系统能力**:SystemCapability.Notification.Notification
5161
5162**系统接口**:此接口为系统接口。
5163
5164| 名称                 | 值  | 说明                               |
5165| -------------------- | --- | --------------------------------- |
5166| IDLE_DONOT_REMIND    | 0   | 设备未被使用,无需提醒。            |
5167| IDLE_REMIND          | 1   | 提醒设备未被使用。                 |
5168| ACTIVE_DONOT_REMIND  | 2   | 设备正在使用,无需提醒。            |
5169| ACTIVE_REMIND        | 3   | 提醒设备正在使用。                 |
5170
5171
5172## SourceType
5173
5174**系统能力**:SystemCapability.Notification.Notification
5175
5176**系统接口**:此接口为系统接口。
5177
5178| 名称                 | 值  | 说明                  |
5179| -------------------- | --- | -------------------- |
5180| TYPE_NORMAL          | 0   | 一般通知。            |
5181| TYPE_CONTINUOUS      | 1   | 连续通知。            |
5182| TYPE_TIMER           | 2   | 计划通知。            |
5183
5184## NotificationCheckInfo<sup>10+</sup>
5185
5186**系统能力**:SystemCapability.Notification.Notification
5187
5188**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
5189
5190**系统接口**:此接口为系统接口。
5191
5192| 名称                         | 类型                          | 只读 | 可选 | 说明            |
5193| ---------------------------- | ---------------------------- | ---- | ---- |--------------- |
5194| bundleName                   | string                       |  否  | 否   | Bundle名称。    |
5195| notificationId               | number                       |  否  | 否   | 通知ID。        |
5196| label<sup>11+</sup>          | string                       |  否  | 是   | 通知标签。      |
5197| contentType                  | [ContentType](./js-apis-notificationManager.md#contenttype)  |  否  | 否   | 通知类型。      |
5198| creatorUserId<sup>11+</sup>  | number                       |  否  | 否   | 通知的user ID。 |
5199| slotType<sup>11+</sup>       | [SlotType](./js-apis-notificationManager.md#slottype)        |  否  | 否   | 渠道类型。      |
5200| extraInfos<sup>11+</sup>     | Record<string, Object>       |  否  | 是   | 实况通知的附加信息。 |
5201
5202## NotificationCheckResult<sup>10+</sup>
5203
5204**系统能力**:SystemCapability.Notification.Notification
5205
5206**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
5207
5208**系统接口**:此接口为系统接口。
5209
5210| 名称    | 类型     | 只读 | 可选 | 说明                     |
5211| ------- | ------- | ---- | ---- | ----------------------- |
5212| code    | number  |  否  | 否   | 0-display,1-no display。|
5213| message | string  |  否  | 否   | 结果信息。                |
5214
5215
5216## ButtonOptions<sup>11+</sup>
5217
5218描述触发按钮信息。
5219
5220**系统能力**:SystemCapability.Notification.Notification
5221
5222**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
5223
5224**系统接口**:此接口为系统接口。
5225
5226| 名称       |   类型  | 只读 | 可选 | 说明                    |
5227| ---------- | ------ | ---- | ---- | ---------------------- |
5228| buttonName | string |  否  | 否   | 按钮名称。              |
5229
5230
5231## SystemLiveViewSubscriber<sup>11+</sup>
5232
5233系统实况窗订阅者。
5234
5235**系统能力**:SystemCapability.Notification.Notification
5236
5237**系统接口**:此接口为系统接口。
5238
5239| 名称         | 类型                                                                               | 只读 | 可选 | 说明                   |
5240| ----------- | ---------------------------------------------------------------------------------- | ---- | ---- | --------------------- |
5241| onResponse  | (notificationId: number, buttonOptions: [ButtonOptions](#buttonoptions11)) => void | 否   |  是  | 点击按钮的回调。        |
5242
5243
5244## SlotType
5245
5246**系统能力**:SystemCapability.Notification.Notification
5247
5248| 名称                                | 值     | 说明                                                         |
5249| ----------------------------------- | ------ | ------------------------------------------------------------ |
5250| EMERGENCY_INFORMATION<sup>12+</sup> | 10     | 紧急事件。**系统接口**:此接口为系统接口。                               |
5251
5252
5253## NotificationControlFlagStatus<sup>12+</sup>
5254每个bit位都可以控制通知的提示方式。当notificationControlFlags和下表中枚举值进行按位或操作,则表示关闭其提示方式。
5255
5256**系统能力**:SystemCapability.Notification.Notification
5257
5258**系统接口**:此接口为系统接口。
5259
5260| 名称                                 | 值   | 说明     |
5261| ------------------------------------ | ---- | -------- |
5262| NOTIFICATION_STATUS_CLOSE_SOUND      | 1<<0 | 关闭声音提示功能。 |
5263| NOTIFICATION_STATUS_CLOSE_LOCKSCREEN |  1<<1    |     关闭锁屏提示功能。     |
5264| NOTIFICATION_STATUS_CLOSE_BANNER     |    1<<2   |     关闭横幅提示功能。     |
5265| NOTIFICATION_STATUS_CLOSE_LIGHT_SCREEN     |   1<<3   |     关闭亮屏提示功能。     |
5266| NOTIFICATION_STATUS_CLOSE_VIBRATION     |   1<<4   |     关闭振动提示功能。     |
5267| NOTIFICATION_STATUS_CLOSE_STATUSBAR_ICON     |  1<<5    |     关闭状态栏图标提示功能。     |
5268
5269## DoNotDisturbProfile<sup>12+</sup>
5270
5271**系统能力**:SystemCapability.Notification.Notification
5272
5273**系统接口**:此接口为系统接口。
5274
5275| 名称      | 类型    | 只读 | 可选 | 说明           |
5276| --------- | ------ | ---- | ---- | ------------- |
5277| id        | number | 否   |  否  | 勿扰模式编号。 |
5278| name      | string | 否   |  否  | 勿扰模式名称。 |
5279| trustlist | Array\<[BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)> | 否 | 是 | 勿扰模式的信任列表。 |
5280
5281## NotificationLiveViewContent<sup>11+</sup>
5282
5283type NotificationLiveViewContent = _NotificationLiveViewContent
5284
5285描述普通实况通知。
5286
5287**系统能力:** SystemCapability.Notification.Notification
5288
5289**系统接口**:此接口为系统接口。
5290
5291| 类型 | 说明 |
5292| --- | --- |
5293| [_NotificationLiveViewContent](js-apis-inner-notification-notificationContent-sys.md#notificationliveviewcontent11) | 描述普通实况通知。 |
5294
5295## SwitchState<sup>20+</sup>
5296
5297描述通知相关开关的设置状态。
5298
5299**系统能力**:SystemCapability.Notification.Notification
5300
5301**系统接口**:此接口为系统接口。
5302
5303| 名称                 | 值  | 说明                               |
5304| --------------------| --- | --------------------------------- |
5305| USER_MODIFIED_OFF   | 0   | 表示用户设置的关闭状态。            |
5306| USER_MODIFIED_ON    | 1   | 表示用户设置的开启状态。                 |
5307| SYSTEM_DEFAULT_OFF  | 2   | 表示在用户设置前的初始关闭状态。            |
5308| SYSTEM_DEFAULT_ON   | 3   | 表示在用户设置前的初始开启状态。                 |
5309