• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.notificationManager (NotificationManager模块)
2
3本模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知通道,获取通知的使能状态、角标使能状态,获取通知的相关信息等。
4
5> **说明:**
6>
7> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8
9## 导入模块
10
11```js
12import Notification from '@ohos.notificationManager';
13```
14
15## Notification.publish
16
17publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
18
19发布通知(callback形式)。
20
21**系统能力**:SystemCapability.Notification.Notification
22
23**参数:**
24
25| 参数名     | 类型                                        | 必填 | 说明                                        |
26| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
27| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
28| callback | AsyncCallback\<void\>                       | 是   | 发布通知的回调方法。                        |
29
30**错误码:**
31
32错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
33
34| 错误码ID | 错误信息                                  |
35| -------- | ----------------------------------------- |
36| 1600001  | Internal error.                           |
37| 1600002  | Marshalling or unmarshalling error.       |
38| 1600003  | Failed to connect service.                |
39| 1600004  | Notification is not enabled.              |
40| 1600005  | Notification slot is not enabled.         |
41| 1600009  | Over max number notifications per second. |
42
43**示例:**
44
45```js
46//publish回调
47function publishCallback(err) {
48    if (err) {
49        console.info("publish failed " + JSON.stringify(err));
50    } else {
51        console.info("publish success");
52    }
53}
54//通知Request对象
55let notificationRequest = {
56    id: 1,
57    content: {
58        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
59        normal: {
60            title: "test_title",
61            text: "test_text",
62            additionalText: "test_additionalText"
63        }
64    }
65};
66Notification.publish(notificationRequest, publishCallback);
67```
68
69
70
71## Notification.publish
72
73publish(request: NotificationRequest): Promise\<void\>
74
75发布通知(Promise形式)。
76
77**系统能力**:SystemCapability.Notification.Notification
78
79**参数:**
80
81| 参数名     | 类型                                        | 必填 | 说明                                        |
82| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
83| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
84
85**错误码:**
86
87错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
88
89| 错误码ID | 错误信息                                  |
90| -------- | ----------------------------------------- |
91| 1600001  | Internal error.                           |
92| 1600002  | Marshalling or unmarshalling error.       |
93| 1600003  | Failed to connect service.                |
94| 1600004  | Notification is not enabled.              |
95| 1600005  | Notification slot is not enabled.         |
96| 1600009  | Over max number notifications per second. |
97
98**示例:**
99
100```js
101// 通知Request对象
102let notificationRequest = {
103    notificationId: 1,
104    content: {
105        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
106        normal: {
107            title: "test_title",
108            text: "test_text",
109            additionalText: "test_additionalText"
110        }
111    }
112};
113Notification.publish(notificationRequest).then(() => {
114	console.info("publish success");
115});
116
117```
118
119## Notification.publish
120
121publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
122
123发布通知给指定的用户(callback形式)。
124
125**系统能力**:SystemCapability.Notification.Notification
126
127**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
128
129**系统API**: 此接口为系统接口,三方应用不支持调用。
130
131**参数:**
132
133| 参数名     | 类型                                        | 必填 | 说明                                        |
134| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
135| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
136| userId   | number                                      | 是   | 用户ID。                           |
137| callback | AsyncCallback\<void\>                       | 是   | 被指定的回调方法。                           |
138
139**错误码:**
140
141错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
142
143| 错误码ID | 错误信息                                  |
144| -------- | ----------------------------------------- |
145| 1600001  | Internal error.                           |
146| 1600002  | Marshalling or unmarshalling error.       |
147| 1600003  | Failed to connect service.                |
148| 1600004  | Notification is not enabled.              |
149| 1600005  | Notification slot is not enabled.         |
150| 1600008  | The user is not exist.                    |
151| 1600009  | Over max number notifications per second. |
152
153**示例:**
154
155```js
156// publish回调
157function publishCallback(err) {
158    if (err) {
159        console.info("publish failed " + JSON.stringify(err));
160    } else {
161        console.info("publish success");
162    }
163}
164// 用户ID
165let userId = 1;
166// 通知Request对象
167let notificationRequest = {
168    id: 1,
169    content: {
170        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
171        normal: {
172            title: "test_title",
173            text: "test_text",
174            additionalText: "test_additionalText"
175        }
176    }
177};
178Notification.publish(notificationRequest, userId, publishCallback);
179```
180
181## Notification.publish
182
183publish(request: NotificationRequest, userId: number): Promise\<void\>
184
185发布通知给指定的用户(Promise形式)。
186
187**系统能力**:SystemCapability.Notification.Notification
188
189**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
190
191**系统API**: 此接口为系统接口,三方应用不支持调用。
192
193**参数:**
194
195| 参数名     |  类型                                        | 必填 | 说明                                        |
196| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
197| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
198| userId   | number                                      | 是   | 用户ID。                           |
199
200**错误码:**
201
202错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
203
204| 错误码ID | 错误信息                                  |
205| -------- | ----------------------------------------- |
206| 1600001  | Internal error.                           |
207| 1600002  | Marshalling or unmarshalling error.       |
208| 1600003  | Failed to connect service.                |
209| 1600004  | Notification is not enabled.              |
210| 1600005  | Notification slot is not enabled.         |
211| 1600008  | The user is not exist.                    |
212| 1600009  | Over max number notifications per second. |
213
214**示例:**
215
216```js
217let notificationRequest = {
218    notificationId: 1,
219    content: {
220        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
221        normal: {
222            title: "test_title",
223            text: "test_text",
224            additionalText: "test_additionalText"
225        }
226    }
227};
228
229let userId = 1;
230
231Notification.publish(notificationRequest, userId).then(() => {
232	console.info("publish success");
233});
234```
235
236
237## Notification.cancel
238
239cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
240
241通过通知ID和通知标签取消已发布的通知(callback形式)。
242
243**系统能力**:SystemCapability.Notification.Notification
244
245**参数:**
246
247| 参数名     | 类型                  | 必填 | 说明                 |
248| -------- | --------------------- | ---- | -------------------- |
249| id       | number                | 是   | 通知ID。               |
250| label    | string                | 是   | 通知标签。             |
251| callback | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
252
253**错误码:**
254
255错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
256
257| 错误码ID | 错误信息                            |
258| -------- | ----------------------------------- |
259| 1600001  | Internal error.                     |
260| 1600002  | Marshalling or unmarshalling error. |
261| 1600003  | Failed to connect service.          |
262| 1600007  | The notification is not exist.      |
263
264**示例:**
265
266```js
267// cancel回调
268function cancelCallback(err) {
269    if (err) {
270        console.info("cancel failed " + JSON.stringify(err));
271    } else {
272        console.info("cancel success");
273    }
274}
275Notification.cancel(0, "label", cancelCallback);
276```
277
278
279
280## Notification.cancel
281
282cancel(id: number, label?: string): Promise\<void\>
283
284取消与指定通知ID相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。
285
286**系统能力**:SystemCapability.Notification.Notification
287
288**参数:**
289
290| 参数名  | 类型   | 必填 | 说明     |
291| ----- | ------ | ---- | -------- |
292| id    | number | 是   | 通知ID。   |
293| label | string | 否   | 通知标签。 |
294
295**错误码:**
296
297错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
298
299| 错误码ID | 错误信息                            |
300| -------- | ----------------------------------- |
301| 1600001  | Internal error.                     |
302| 1600002  | Marshalling or unmarshalling error. |
303| 1600003  | Failed to connect service.          |
304| 1600007  | The notification is not exist.      |
305
306**示例:**
307
308```js
309Notification.cancel(0).then(() => {
310	console.info("cancel success");
311});
312```
313
314
315
316## Notification.cancel
317
318cancel(id: number, callback: AsyncCallback\<void\>): void
319
320取消与指定通知ID相匹配的已发布通知(callback形式)。
321
322**系统能力**:SystemCapability.Notification.Notification
323
324**参数:**
325
326| 参数名     | 类型                  | 必填 | 说明                 |
327| -------- | --------------------- | ---- | -------------------- |
328| id       | number                | 是   | 通知ID。               |
329| callback | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
330
331**错误码:**
332
333错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
334
335| 错误码ID | 错误信息                            |
336| -------- | ----------------------------------- |
337| 1600001  | Internal error.                     |
338| 1600002  | Marshalling or unmarshalling error. |
339| 1600003  | Failed to connect service.          |
340| 1600007  | The notification is not exist.      |
341
342**示例:**
343
344```js
345// cancel回调
346function cancelCallback(err) {
347    if (err) {
348        console.info("cancel failed " + JSON.stringify(err));
349    } else {
350        console.info("cancel success");
351    }
352}
353Notification.cancel(0, cancelCallback);
354```
355
356
357
358## Notification.cancelAll
359
360cancelAll(callback: AsyncCallback\<void\>): void
361
362取消所有已发布的通知(callback形式)。
363
364**系统能力**:SystemCapability.Notification.Notification
365
366**错误码:**
367
368错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
369
370| 错误码ID | 错误信息                            |
371| -------- | ----------------------------------- |
372| 1600001  | Internal error.                     |
373| 1600002  | Marshalling or unmarshalling error. |
374| 1600003  | Failed to connect service.          |
375
376**参数:**
377
378| 参数名     | 类型                  | 必填 | 说明                 |
379| -------- | --------------------- | ---- | -------------------- |
380| callback | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
381
382**示例:**
383
384```js
385// cancel回调
386function cancelAllCallback(err) {
387    if (err) {
388        console.info("cancelAll failed " + JSON.stringify(err));
389    } else {
390        console.info("cancelAll success");
391    }
392}
393Notification.cancelAll(cancelAllCallback);
394```
395
396
397
398## Notification.cancelAll
399
400cancelAll(): Promise\<void\>
401
402取消所有已发布的通知(Promise形式)。
403
404**系统能力**:SystemCapability.Notification.Notification
405
406**错误码:**
407
408错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
409
410| 错误码ID | 错误信息                            |
411| -------- | ----------------------------------- |
412| 1600001  | Internal error.                     |
413| 1600002  | Marshalling or unmarshalling error. |
414| 1600003  | Failed to connect service.          |
415
416**示例:**
417
418```js
419Notification.cancelAll().then(() => {
420	console.info("cancelAll success");
421});
422```
423
424
425
426## Notification.addSlot
427
428addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
429
430创建通知通道(callback形式)。
431
432**系统能力**:SystemCapability.Notification.Notification
433
434**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
435
436**系统API**: 此接口为系统接口,三方应用不支持调用。
437
438**参数:**
439
440| 参数名     | 类型                  | 必填 | 说明                 |
441| -------- | --------------------- | ---- | -------------------- |
442| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot.md)       | 是   | 要创建的通知通道对象。 |
443| callback | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
444
445**错误码:**
446
447错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
448
449| 错误码ID | 错误信息                            |
450| -------- | ----------------------------------- |
451| 1600001  | Internal error.                     |
452| 1600002  | Marshalling or unmarshalling error. |
453| 1600003  | Failed to connect service.          |
454
455**示例:**
456
457```js
458// addslot回调
459function addSlotCallBack(err) {
460    if (err) {
461        console.info("addSlot failed " + JSON.stringify(err));
462    } else {
463        console.info("addSlot success");
464    }
465}
466// 通知slot对象
467let notificationSlot = {
468    type: Notification.SlotType.SOCIAL_COMMUNICATION
469};
470Notification.addSlot(notificationSlot, addSlotCallBack);
471```
472
473
474
475## Notification.addSlot
476
477addSlot(slot: NotificationSlot): Promise\<void\>
478
479创建通知通道(Promise形式)。
480
481**系统能力**:SystemCapability.Notification.Notification
482
483**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
484
485**系统API**: 此接口为系统接口,三方应用不支持调用。
486
487**参数:**
488
489| 参数名 | 类型             | 必填 | 说明                 |
490| ---- | ---------------- | ---- | -------------------- |
491| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是   | 要创建的通知通道对象。 |
492
493**错误码:**
494
495错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
496
497| 错误码ID | 错误信息                            |
498| -------- | ----------------------------------- |
499| 1600001  | Internal error.                     |
500| 1600002  | Marshalling or unmarshalling error. |
501| 1600003  | Failed to connect service.          |
502
503**示例:**
504
505```js
506// 通知slot对象
507let notificationSlot = {
508    type: Notification.SlotType.SOCIAL_COMMUNICATION
509};
510Notification.addSlot(notificationSlot).then(() => {
511	console.info("addSlot success");
512});
513```
514
515
516
517## Notification.addSlot
518
519addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
520
521创建指定类型的通知通道(callback形式)。
522
523**系统能力**:SystemCapability.Notification.Notification
524
525**参数:**
526
527| 参数名     | 类型                  | 必填 | 说明                   |
528| -------- | --------------------- | ---- | ---------------------- |
529| type     | [SlotType](#slottype)              | 是   | 要创建的通知通道的类型。 |
530| callback | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。   |
531
532**错误码:**
533
534错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
535
536| 错误码ID | 错误信息                            |
537| -------- | ----------------------------------- |
538| 1600001  | Internal error.                     |
539| 1600002  | Marshalling or unmarshalling error. |
540| 1600003  | Failed to connect service.          |
541
542**示例:**
543
544```js
545// addslot回调
546function addSlotCallBack(err) {
547    if (err) {
548        console.info("addSlot failed " + JSON.stringify(err));
549    } else {
550        console.info("addSlot success");
551    }
552}
553Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
554```
555
556
557
558## Notification.addSlot
559
560addSlot(type: SlotType): Promise\<void\>
561
562创建指定类型的通知通道(Promise形式)。
563
564**系统能力**:SystemCapability.Notification.Notification
565
566**参数:**
567
568| 参数名 | 类型     | 必填 | 说明                   |
569| ---- | -------- | ---- | ---------------------- |
570| type | [SlotType](#slottype) | 是   | 要创建的通知通道的类型。 |
571
572**错误码:**
573
574错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
575
576| 错误码ID | 错误信息                            |
577| -------- | ----------------------------------- |
578| 1600001  | Internal error.                     |
579| 1600002  | Marshalling or unmarshalling error. |
580| 1600003  | Failed to connect service.          |
581
582**示例:**
583
584```js
585Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
586	console.info("addSlot success");
587});
588```
589
590
591
592## Notification.addSlots
593
594addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
595
596创建多个通知通道(callback形式)。
597
598**系统能力**:SystemCapability.Notification.Notification
599
600**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
601
602**系统API**: 此接口为系统接口,三方应用不支持调用。
603
604**参数:**
605
606| 参数名     | 类型                      | 必填 | 说明                     |
607| -------- | ------------------------- | ---- | ------------------------ |
608| slots    | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | 是   | 要创建的通知通道对象数组。 |
609| callback | AsyncCallback\<void\>     | 是   | 表示被指定的回调方法。     |
610
611**错误码:**
612
613错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
614
615| 错误码ID | 错误信息                            |
616| -------- | ----------------------------------- |
617| 1600001  | Internal error.                     |
618| 1600002  | Marshalling or unmarshalling error. |
619| 1600003  | Failed to connect service.          |
620
621**示例:**
622
623```js
624// addSlots回调
625function addSlotsCallBack(err) {
626    if (err) {
627        console.info("addSlots failed " + JSON.stringify(err));
628    } else {
629        console.info("addSlots success");
630    }
631}
632// 通知slot对象
633let notificationSlot = {
634    type: Notification.SlotType.SOCIAL_COMMUNICATION
635};
636// 通知slot array 对象
637let notificationSlotArray = new Array();
638notificationSlotArray[0] = notificationSlot;
639
640Notification.addSlots(notificationSlotArray, addSlotsCallBack);
641```
642
643
644
645## Notification.addSlots
646
647addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
648
649创建多个通知通道(Promise形式)。
650
651**系统能力**:SystemCapability.Notification.Notification
652
653**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
654
655**系统API**: 此接口为系统接口,三方应用不支持调用。
656
657**参数:**
658
659| 参数名  | 类型                      | 必填 | 说明                     |
660| ----- | ------------------------- | ---- | ------------------------ |
661| slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | 是   | 要创建的通知通道对象数组。 |
662
663**错误码:**
664
665错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
666
667| 错误码ID | 错误信息                            |
668| -------- | ----------------------------------- |
669| 1600001  | Internal error.                     |
670| 1600002  | Marshalling or unmarshalling error. |
671| 1600003  | Failed to connect service.          |
672
673**示例:**
674
675```js
676// 通知slot对象
677let notificationSlot = {
678    type: Notification.SlotType.SOCIAL_COMMUNICATION
679};
680// 通知slot array 对象
681let notificationSlotArray = new Array();
682notificationSlotArray[0] = notificationSlot;
683
684Notification.addSlots(notificationSlotArray).then(() => {
685	console.info("addSlots success");
686});
687```
688
689
690
691## Notification.getSlot
692
693getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
694
695获取一个指定类型的通知通道(callback形式)。
696
697**系统能力**:SystemCapability.Notification.Notification
698
699**参数:**
700
701| 参数名     | 类型                              | 必填 | 说明                                                        |
702| -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
703| slotType | [SlotType](#slottype)                          | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
704| callback | AsyncCallback\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | 是   | 表示被指定的回调方法。                                        |
705
706**错误码:**
707
708错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
709
710| 错误码ID | 错误信息                            |
711| -------- | ----------------------------------- |
712| 1600001  | Internal error.                     |
713| 1600002  | Marshalling or unmarshalling error. |
714| 1600003  | Failed to connect service.          |
715
716**示例:**
717
718```js
719// getSlot回调
720function getSlotCallback(err,data) {
721    if (err) {
722        console.info("getSlot failed " + JSON.stringify(err));
723    } else {
724        console.info("getSlot success");
725    }
726}
727let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
728Notification.getSlot(slotType, getSlotCallback);
729```
730
731
732
733## Notification.getSlot
734
735getSlot(slotType: SlotType): Promise\<NotificationSlot\>
736
737获取一个指定类型的通知通道(Promise形式)。
738
739**系统能力**:SystemCapability.Notification.Notification
740
741**参数:**
742
743| 参数名     | 类型     | 必填 | 说明                                                        |
744| -------- | -------- | ---- | ----------------------------------------------------------- |
745| slotType | [SlotType](#slottype) | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
746
747**返回值:**
748
749| 类型                                                        | 说明                                                         |
750| ----------------------------------------------------------- | ------------------------------------------------------------ |
751| Promise\<NotificationSlot\> | 以Promise形式返回获取一个通知通道。 |
752
753**错误码:**
754
755错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
756
757| 错误码ID | 错误信息                            |
758| -------- | ----------------------------------- |
759| 1600001  | Internal error.                     |
760| 1600002  | Marshalling or unmarshalling error. |
761| 1600003  | Failed to connect service.          |
762
763**示例:**
764
765```js
766let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
767Notification.getSlot(slotType).then((data) => {
768	console.info("getSlot success, data: " + JSON.stringify(data));
769});
770```
771
772
773
774## Notification.getSlots
775
776getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
777
778获取此应用程序的所有通知通道(callback形式)。
779
780**系统能力**:SystemCapability.Notification.Notification
781
782**参数:**
783
784| 参数名     | 类型                              | 必填 | 说明                 |
785| -------- | --------------------------------- | ---- | -------------------- |
786| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | 是   | 以callback形式返回获取此应用程序的所有通知通道的结果。 |
787
788**错误码:**
789
790错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
791
792| 错误码ID | 错误信息                            |
793| -------- | ----------------------------------- |
794| 1600001  | Internal error.                     |
795| 1600002  | Marshalling or unmarshalling error. |
796| 1600003  | Failed to connect service.          |
797
798**示例:**
799
800```js
801// getSlots回调
802function getSlotsCallback(err,data) {
803    if (err) {
804        console.info("getSlots failed " + JSON.stringify(err));
805    } else {
806        console.info("getSlots success");
807    }
808}
809Notification.getSlots(getSlotsCallback);
810```
811
812
813
814## Notification.getSlots
815
816getSlots(): Promise\<Array\<NotificationSlot>>
817
818获取此应用程序的所有通知通道(Promise形式)。
819
820**系统能力**:SystemCapability.Notification.Notification
821
822**返回值:**
823
824| 类型                                                        | 说明                                                         |
825| ----------------------------------------------------------- | ------------------------------------------------------------ |
826| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | 以Promise形式返回获取此应用程序的所有通知通道的结果。 |
827
828**错误码:**
829
830错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
831
832| 错误码ID | 错误信息                            |
833| -------- | ----------------------------------- |
834| 1600001  | Internal error.                     |
835| 1600002  | Marshalling or unmarshalling error. |
836| 1600003  | Failed to connect service.          |
837
838**示例:**
839
840```js
841Notification.getSlots().then((data) => {
842	console.info("getSlots success, data: " + JSON.stringify(data));
843});
844```
845
846
847
848## Notification.removeSlot
849
850removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
851
852删除指定类型的通知通道(callback形式)。
853
854**系统能力**:SystemCapability.Notification.Notification
855
856**参数:**
857
858| 参数名     | 类型                  | 必填 | 说明                                                        |
859| -------- | --------------------- | ---- | ----------------------------------------------------------- |
860| slotType | [SlotType](#slottype)              | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
861| callback | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。                                        |
862
863**错误码:**
864
865错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
866
867| 错误码ID | 错误信息                            |
868| -------- | ----------------------------------- |
869| 1600001  | Internal error.                     |
870| 1600002  | Marshalling or unmarshalling error. |
871| 1600003  | Failed to connect service.          |
872
873**示例:**
874
875```js
876// removeSlot回调
877function removeSlotCallback(err) {
878    if (err) {
879        console.info("removeSlot failed " + JSON.stringify(err));
880    } else {
881        console.info("removeSlot success");
882    }
883}
884let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
885Notification.removeSlot(slotType,removeSlotCallback);
886```
887
888
889
890## Notification.removeSlot
891
892removeSlot(slotType: SlotType): Promise\<void\>
893
894删除指定类型的通知通道(Promise形式)。
895
896**系统能力**:SystemCapability.Notification.Notification
897
898**参数:**
899
900| 参数名     | 类型     | 必填 | 说明                                                        |
901| -------- | -------- | ---- | ----------------------------------------------------------- |
902| slotType | [SlotType](#slottype) | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
903
904**错误码:**
905
906错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
907
908| 错误码ID | 错误信息                            |
909| -------- | ----------------------------------- |
910| 1600001  | Internal error.                     |
911| 1600002  | Marshalling or unmarshalling error. |
912| 1600003  | Failed to connect service.          |
913
914**示例:**
915
916```js
917let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
918Notification.removeSlot(slotType).then(() => {
919	console.info("removeSlot success");
920});
921```
922
923
924
925## Notification.removeAllSlots
926
927removeAllSlots(callback: AsyncCallback\<void\>): void
928
929删除所有通知通道(callback形式)。
930
931**系统能力**:SystemCapability.Notification.Notification
932
933**参数:**
934
935| 参数名     | 类型                  | 必填 | 说明                 |
936| -------- | --------------------- | ---- | -------------------- |
937| callback | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
938
939**错误码:**
940
941错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
942
943| 错误码ID | 错误信息                            |
944| -------- | ----------------------------------- |
945| 1600001  | Internal error.                     |
946| 1600002  | Marshalling or unmarshalling error. |
947| 1600003  | Failed to connect service.          |
948
949**示例:**
950
951```js
952function removeAllCallBack(err) {
953    if (err) {
954        console.info("removeAllSlots failed " + JSON.stringify(err));
955    } else {
956        console.info("removeAllSlots success");
957    }
958}
959Notification.removeAllSlots(removeAllCallBack);
960```
961
962
963
964## Notification.removeAllSlots
965
966removeAllSlots(): Promise\<void\>
967
968删除所有通知通道(Promise形式)。
969
970**系统能力**:SystemCapability.Notification.Notification
971
972**错误码:**
973
974错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
975
976| 错误码ID | 错误信息                            |
977| -------- | ----------------------------------- |
978| 1600001  | Internal error.                     |
979| 1600002  | Marshalling or unmarshalling error. |
980| 1600003  | Failed to connect service.          |
981
982**示例:**
983
984```js
985Notification.removeAllSlots().then(() => {
986	console.info("removeAllSlots success");
987});
988```
989
990
991
992## Notification.setNotificationEnable
993
994setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
995
996设定指定应用的通知使能状态(Callback形式)。
997
998**系统能力**:SystemCapability.Notification.Notification
999
1000**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1001
1002**系统API**: 此接口为系统接口,三方应用不支持调用。
1003
1004**参数:**
1005
1006| 参数名     | 类型                  | 必填 | 说明                 |
1007| -------- | --------------------- | ---- | -------------------- |
1008| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)   | 是   | 指定应用的包信息。        |
1009| enable   | boolean               | 是   | 使能状态。             |
1010| callback | AsyncCallback\<void\> | 是   | 设定通知使能回调函数。 |
1011
1012**错误码:**
1013
1014错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1015
1016| 错误码ID | 错误信息                                 |
1017| -------- | ---------------------------------------- |
1018| 1600001  | Internal error.                          |
1019| 1600002  | Marshalling or unmarshalling error.      |
1020| 1600003  | Failed to connect service.               |
1021| 17700001 | The specified bundle name was not found. |
1022
1023**示例:**
1024
1025```js
1026function setNotificationEnablenCallback(err) {
1027    if (err) {
1028        console.info("setNotificationEnablenCallback failed " + JSON.stringify(err));
1029    } else {
1030        console.info("setNotificationEnablenCallback success");
1031    }
1032}
1033let bundle = {
1034    bundle: "bundleName1",
1035};
1036Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback);
1037```
1038
1039
1040
1041## Notification.setNotificationEnable
1042
1043setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
1044
1045设定指定应用的通知使能状态(Promise形式)。
1046
1047**系统能力**:SystemCapability.Notification.Notification
1048
1049**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1050
1051**系统API**: 此接口为系统接口,三方应用不支持调用。
1052
1053**参数:**
1054
1055| 参数名   | 类型         | 必填 | 说明       |
1056| ------ | ------------ | ---- | ---------- |
1057| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1058| enable | boolean      | 是   | 使能状态。   |
1059
1060**错误码:**
1061
1062错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1063
1064| 错误码ID | 错误信息                                 |
1065| -------- | ---------------------------------------- |
1066| 1600001  | Internal error.                          |
1067| 1600002  | Marshalling or unmarshalling error.      |
1068| 1600003  | Failed to connect service.               |
1069| 17700001 | The specified bundle name was not found. |
1070
1071**示例:**
1072
1073```js
1074let bundle = {
1075    bundle: "bundleName1",
1076};
1077Notification.setNotificationEnable(bundle, false).then(() => {
1078	console.info("setNotificationEnable success");
1079});
1080```
1081
1082
1083
1084## Notification.isNotificationEnabled
1085
1086isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
1087
1088获取指定应用的通知使能状态(Callback形式)。
1089
1090**系统能力**:SystemCapability.Notification.Notification
1091
1092**系统API**:此接口为系统接口,三方应用不支持调用。
1093
1094**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1095
1096**参数:**
1097
1098| 参数名     | 类型                  | 必填 | 说明                     |
1099| -------- | --------------------- | ---- | ------------------------ |
1100| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。            |
1101| callback | AsyncCallback\<void\> | 是   | 获取通知使能状态回调函数。 |
1102
1103**错误码:**
1104
1105错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1106
1107| 错误码ID | 错误信息                                 |
1108| -------- | ---------------------------------------- |
1109| 1600001  | Internal error.                          |
1110| 1600002  | Marshalling or unmarshalling error.      |
1111| 1600003  | Failed to connect service.               |
1112| 17700001 | The specified bundle name was not found. |
1113
1114**示例:**
1115
1116```js
1117function isNotificationEnabledCallback(err, data) {
1118    if (err) {
1119        console.info("isNotificationEnabled failed " + JSON.stringify(err));
1120    } else {
1121        console.info("isNotificationEnabled success");
1122    }
1123}
1124let bundle = {
1125    bundle: "bundleName1",
1126};
1127Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
1128```
1129
1130
1131
1132## Notification.isNotificationEnabled
1133
1134isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
1135
1136获取指定应用的通知使能状态(Promise形式)。
1137
1138**系统能力**:SystemCapability.Notification.Notification
1139
1140**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1141
1142**系统API**: 此接口为系统接口,三方应用不支持调用。
1143
1144**参数:**
1145
1146| 参数名   | 类型         | 必填 | 说明       |
1147| ------ | ------------ | ---- | ---------- |
1148| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1149
1150**返回值:**
1151
1152| 类型               | 说明                                                |
1153| ------------------ | --------------------------------------------------- |
1154| Promise\<boolean\> | 以Promise形式返回获取指定应用的通知使能状态的结果。 |
1155
1156**错误码:**
1157
1158错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1159
1160| 错误码ID | 错误信息                                 |
1161| -------- | ---------------------------------------- |
1162| 1600001  | Internal error.                          |
1163| 1600002  | Marshalling or unmarshalling error.      |
1164| 1600003  | Failed to connect service.               |
1165| 17700001 | The specified bundle name was not found. |
1166
1167**示例:**
1168
1169```js
1170let bundle = {
1171    bundle: "bundleName1",
1172};
1173Notification.isNotificationEnabled(bundle).then((data) => {
1174	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
1175});
1176```
1177
1178
1179
1180## Notification.isNotificationEnabled
1181
1182isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
1183
1184获取通知使能状态(Callback形式)。
1185
1186**系统能力**:SystemCapability.Notification.Notification
1187
1188**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1189
1190**系统API**: 此接口为系统接口,三方应用不支持调用。
1191
1192**参数:**
1193
1194| 参数名     | 类型                  | 必填 | 说明                     |
1195| -------- | --------------------- | ---- | ------------------------ |
1196| callback | AsyncCallback\<void\> | 是   | 获取通知使能状态回调函数。 |
1197
1198**错误码:**
1199
1200错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1201
1202| 错误码ID | 错误信息                            |
1203| -------- | ----------------------------------- |
1204| 1600001  | Internal error.                     |
1205| 1600002  | Marshalling or unmarshalling error. |
1206| 1600003  | Failed to connect service.          |
1207
1208**示例:**
1209
1210```js
1211function isNotificationEnabledCallback(err, data) {
1212    if (err) {
1213        console.info("isNotificationEnabled failed " + JSON.stringify(err));
1214    } else {
1215        console.info("isNotificationEnabled success");
1216    }
1217}
1218
1219Notification.isNotificationEnabled(isNotificationEnabledCallback);
1220```
1221
1222
1223
1224## Notification.isNotificationEnabled
1225
1226isNotificationEnabled(): Promise\<boolean\>
1227
1228获取通知使能状态(Promise形式)。
1229
1230**系统能力**:SystemCapability.Notification.Notification
1231
1232**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1233
1234**系统API**: 此接口为系统接口,三方应用不支持调用。
1235
1236**返回值:**
1237
1238| 类型                                                        | 说明                                                         |
1239| ----------------------------------------------------------- | ------------------------------------------------------------ |
1240| Promise\<boolean\> | 以Promise形式返回获取通知使能状态的结果。 |
1241
1242**错误码:**
1243
1244错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1245
1246| 错误码ID | 错误信息                                 |
1247| -------- | ---------------------------------------- |
1248| 1600001  | Internal error.                          |
1249| 1600002  | Marshalling or unmarshalling error.      |
1250| 1600003  | Failed to connect service.               |
1251
1252**示例:**
1253
1254```ts
1255notificationManager.isNotificationEnabled().then((data) => {
1256	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
1257});
1258```
1259
1260## notificationManager.isNotificationEnabled
1261
1262isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
1263
1264获取制定用户ID下的通知使能状态(Callback形式)。
1265
1266**系统能力**:SystemCapability.Notification.Notification
1267
1268**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1269
1270**系统API**: 此接口为系统接口,三方应用不支持调用。
1271
1272**参数:**
1273
1274| 参数名     | 类型                  | 必填 | 说明                     |
1275| -------- | --------------------- | ---- | ------------------------ |
1276| userId   | number                | 是   | 指定的用户ID。 |
1277| callback | AsyncCallback\<void\> | 是   | 获取通知使能状态回调函数。 |
1278
1279**错误码:**
1280
1281错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1282
1283| 错误码ID | 错误信息                            |
1284| -------- | ----------------------------------- |
1285| 1600001  | Internal error.                     |
1286| 1600002  | Marshalling or unmarshalling error. |
1287| 1600003  | Failed to connect service.          |
1288| 1600008  | The user is not exist.              |
1289
1290**示例:**
1291
1292```ts
1293function isNotificationEnabledCallback(err, data) {
1294    if (err) {
1295        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
1296    } else {
1297        console.info("isNotificationEnabled success");
1298    }
1299}
1300
1301let userId = 1;
1302
1303notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
1304```
1305
1306## notificationManager.isNotificationEnabled
1307
1308isNotificationEnabled(userId: number): Promise\<boolean\>
1309
1310获取制定用户下的通知使能状态(Promise形式)。
1311
1312**系统能力**:SystemCapability.Notification.Notification
1313
1314**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1315
1316**系统API**: 此接口为系统接口,三方应用不支持调用。
1317
1318**参数:**
1319
1320| 参数名   | 类型         | 必填 | 说明       |
1321| ------ | ------------ | ---- | ---------- |
1322| userId | number       | 是   | 指定的用户ID。 |
1323
1324**返回值:**
1325
1326| 类型                                                        | 说明                                                         |
1327| ----------------------------------------------------------- | ------------------------------------------------------------ |
1328| Promise\<boolean\> | 以Promise形式返回获取通知使能状态的结果。 |
1329
1330**错误码:**
1331
1332错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1333
1334| 错误码ID | 错误信息                                 |
1335| -------- | ---------------------------------------- |
1336| 1600001  | Internal error.                          |
1337| 1600002  | Marshalling or unmarshalling error.      |
1338| 1600003  | Failed to connect service.               |
1339| 1600008  | The user is not exist..                  |
1340
1341**示例:**
1342
1343```ts
1344let userId = 1;
1345
1346notificationManager.isNotificationEnabled(userId).then((data) => {
1347	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
1348});
1349```
1350
1351
1352
1353## Notification.displayBadge
1354
1355displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
1356
1357设定指定应用的角标使能状态(Callback形式)。
1358
1359**系统能力**:SystemCapability.Notification.Notification
1360
1361**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1362
1363**系统API**: 此接口为系统接口,三方应用不支持调用。
1364
1365**参数:**
1366
1367| 参数名     | 类型                  | 必填 | 说明                 |
1368| -------- | --------------------- | ---- | -------------------- |
1369| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。           |
1370| enable   | boolean               | 是   | 使能状态。             |
1371| callback | AsyncCallback\<void\> | 是   | 设定角标使能回调函数。 |
1372
1373**错误码:**
1374
1375错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1376
1377| 错误码ID | 错误信息                                 |
1378| -------- | ---------------------------------------- |
1379| 1600001  | Internal error.                          |
1380| 1600002  | Marshalling or unmarshalling error.      |
1381| 1600003  | Failed to connect service.               |
1382| 17700001 | The specified bundle name was not found. |
1383
1384**示例:**
1385
1386```js
1387function displayBadgeCallback(err) {
1388    if (err) {
1389        console.info("displayBadge failed " + JSON.stringify(err));
1390    } else {
1391        console.info("displayBadge success");
1392    }
1393}
1394let bundle = {
1395    bundle: "bundleName1",
1396};
1397Notification.displayBadge(bundle, false, displayBadgeCallback);
1398```
1399
1400
1401
1402## Notification.displayBadge
1403
1404displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
1405
1406设定指定应用的角标使能状态(Promise形式)。
1407
1408**系统能力**:SystemCapability.Notification.Notification
1409
1410**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1411
1412**系统API**: 此接口为系统接口,三方应用不支持调用。
1413
1414**参数:**
1415
1416| 参数名   | 类型         | 必填 | 说明       |
1417| ------ | ------------ | ---- | ---------- |
1418| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1419| enable | boolean      | 是   | 使能状态。   |
1420
1421**错误码:**
1422
1423错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1424
1425| 错误码ID | 错误信息                                 |
1426| -------- | ---------------------------------------- |
1427| 1600001  | Internal error.                          |
1428| 1600002  | Marshalling or unmarshalling error.      |
1429| 1600003  | Failed to connect service.               |
1430| 17700001 | The specified bundle name was not found. |
1431
1432**示例:**
1433
1434```js
1435let bundle = {
1436    bundle: "bundleName1",
1437};
1438Notification.displayBadge(bundle, false).then(() => {
1439	console.info("displayBadge success");
1440});
1441```
1442
1443
1444
1445## Notification.isBadgeDisplayed
1446
1447isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
1448
1449获取指定应用的角标使能状态(Callback形式)。
1450
1451**系统能力**:SystemCapability.Notification.Notification
1452
1453**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1454
1455**系统API**: 此接口为系统接口,三方应用不支持调用。
1456
1457**参数:**
1458
1459| 参数名     | 类型                  | 必填 | 说明                     |
1460| -------- | --------------------- | ---- | ------------------------ |
1461| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。               |
1462| callback | AsyncCallback\<void\> | 是   | 获取角标使能状态回调函数。 |
1463
1464**错误码:**
1465
1466错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1467
1468| 错误码ID | 错误信息                                 |
1469| -------- | ---------------------------------------- |
1470| 1600001  | Internal error.                          |
1471| 1600002  | Marshalling or unmarshalling error.      |
1472| 1600003  | Failed to connect service.               |
1473| 17700001 | The specified bundle name was not found. |
1474
1475**示例:**
1476
1477```js
1478function isBadgeDisplayedCallback(err, data) {
1479    if (err) {
1480        console.info("isBadgeDisplayed failed " + JSON.stringify(err));
1481    } else {
1482        console.info("isBadgeDisplayed success");
1483    }
1484}
1485let bundle = {
1486    bundle: "bundleName1",
1487};
1488Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
1489```
1490
1491
1492
1493## Notification.isBadgeDisplayed
1494
1495isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
1496
1497获取指定应用的角标使能状态(Promise形式)。
1498
1499**系统能力**:SystemCapability.Notification.Notification
1500
1501**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1502
1503**系统API**: 此接口为系统接口,三方应用不支持调用。
1504
1505**参数:**
1506
1507| 参数名   | 类型         | 必填 | 说明       |
1508| ------ | ------------ | ---- | ---------- |
1509| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1510
1511**返回值:**
1512
1513| 类型                                                        | 说明                                                         |
1514| ----------------------------------------------------------- | ------------------------------------------------------------ |
1515| Promise\<boolean\> | 以Promise形式返回获取指定应用的角标使能状态。 |
1516
1517**错误码:**
1518
1519错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1520
1521| 错误码ID | 错误信息                                 |
1522| -------- | ---------------------------------------- |
1523| 1600001  | Internal error.                          |
1524| 1600002  | Marshalling or unmarshalling error.      |
1525| 1600003  | Failed to connect service.               |
1526| 17700001 | The specified bundle name was not found. |
1527
1528**示例:**
1529
1530```js
1531let bundle = {
1532    bundle: "bundleName1",
1533};
1534Notification.isBadgeDisplayed(bundle).then((data) => {
1535	console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
1536});
1537```
1538
1539## notificationManager.setSlotByBundle
1540
1541setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
1542
1543设定指定应用的通知通道(Callback形式)。
1544
1545**系统能力**:SystemCapability.Notification.Notification
1546
1547**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1548
1549**系统API**: 此接口为系统接口,三方应用不支持调用。
1550
1551**参数:**
1552
1553| 参数名     | 类型                  | 必填 | 说明                 |
1554| -------- | --------------------- | ---- | -------------------- |
1555| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。           |
1556| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot.md)      | 是   | 通知通道。             |
1557| callback | AsyncCallback\<void\> | 是   | 设定通知通道回调函数。 |
1558
1559**错误码:**
1560
1561错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1562
1563| 错误码ID | 错误信息                                 |
1564| -------- | ---------------------------------------- |
1565| 1600001  | Internal error.                          |
1566| 1600002  | Marshalling or unmarshalling error.      |
1567| 1600003  | Failed to connect service.               |
1568| 17700001 | The specified bundle name was not found. |
1569
1570
1571
1572**示例:**
1573
1574```js
1575function setSlotByBundleCallback(err) {
1576    if (err) {
1577        console.info("setSlotByBundle failed " + JSON.stringify(err));
1578    } else {
1579        console.info("setSlotByBundle success");
1580    }
1581}
1582let bundle = {
1583    bundle: "bundleName1",
1584};
1585let notificationSlot = {
1586    type: Notification.SlotType.SOCIAL_COMMUNICATION
1587};
1588Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
1589```
1590
1591
1592
1593## Notification.setSlotByBundle
1594
1595setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
1596
1597设定指定应用的通知通道(Promise形式)。
1598
1599**系统能力**:SystemCapability.Notification.Notification
1600
1601**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1602
1603**系统API**: 此接口为系统接口,三方应用不支持调用。
1604
1605**参数:**
1606
1607| 参数名   | 类型         | 必填 | 说明       |
1608| ------ | ------------ | ---- | ---------- |
1609| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1610| slot   | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是   | 通知通道。 |
1611
1612**错误码:**
1613
1614错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1615
1616| 错误码ID | 错误信息                                 |
1617| -------- | ---------------------------------------- |
1618| 1600001  | Internal error.                          |
1619| 1600002  | Marshalling or unmarshalling error.      |
1620| 1600003  | Failed to connect service.               |
1621| 17700001 | The specified bundle name was not found. |
1622
1623**示例:**
1624
1625```js
1626let bundle = {
1627    bundle: "bundleName1",
1628};
1629let notificationSlot = {
1630    type: Notification.SlotType.SOCIAL_COMMUNICATION
1631};
1632Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
1633	console.info("setSlotByBundle success");
1634});
1635```
1636
1637
1638
1639## Notification.getSlotsByBundle
1640
1641getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
1642
1643获取指定应用的所有通知通道(Callback形式)。
1644
1645**系统能力**:SystemCapability.Notification.Notification
1646
1647**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1648
1649**系统API**: 此接口为系统接口,三方应用不支持调用。
1650
1651**参数:**
1652
1653| 参数名     | 类型                                     | 必填 | 说明                 |
1654| -------- | ---------------------------------------- | ---- | -------------------- |
1655| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)                             | 是   | 指定应用的包信息。           |
1656| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | 是   | 获取通知通道回调函数。 |
1657
1658**错误码:**
1659
1660错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1661
1662| 错误码ID | 错误信息                                 |
1663| -------- | ---------------------------------------- |
1664| 1600001  | Internal error.                          |
1665| 1600002  | Marshalling or unmarshalling error.      |
1666| 1600003  | Failed to connect service.               |
1667| 17700001 | The specified bundle name was not found. |
1668
1669**示例:**
1670
1671```js
1672function getSlotsByBundleCallback(err, data) {
1673    if (err) {
1674        console.info("getSlotsByBundle failed " + JSON.stringify(err));
1675    } else {
1676        console.info("getSlotsByBundle success");
1677    }
1678}
1679let bundle = {
1680    bundle: "bundleName1",
1681};
1682Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
1683```
1684
1685
1686
1687## Notification.getSlotsByBundle
1688
1689getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
1690
1691获取指定应用的所有通知通道(Promise形式)。
1692
1693**系统能力**:SystemCapability.Notification.Notification
1694
1695**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1696
1697**系统API**: 此接口为系统接口,三方应用不支持调用。
1698
1699**参数:**
1700
1701| 参数名   | 类型         | 必填 | 说明       |
1702| ------ | ------------ | ---- | ---------- |
1703| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1704
1705**返回值:**
1706
1707| 类型                                                        | 说明                                                         |
1708| ----------------------------------------------------------- | ------------------------------------------------------------ |
1709| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | 以Promise形式返回获取指定应用的通知通道。 |
1710
1711**错误码:**
1712
1713错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1714
1715| 错误码ID | 错误信息                                 |
1716| -------- | ---------------------------------------- |
1717| 1600001  | Internal error.                          |
1718| 1600002  | Marshalling or unmarshalling error.      |
1719| 1600003  | Failed to connect service.               |
1720| 17700001 | The specified bundle name was not found. |
1721
1722**示例:**
1723
1724```js
1725let bundle = {
1726    bundle: "bundleName1",
1727};
1728Notification.getSlotsByBundle(bundle).then((data) => {
1729	console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
1730});
1731```
1732
1733
1734
1735## Notification.getSlotNumByBundle
1736
1737getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
1738
1739获取指定应用的通知通道数量(Callback形式)。
1740
1741**系统能力**:SystemCapability.Notification.Notification
1742
1743**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1744
1745**系统API**: 此接口为系统接口,三方应用不支持调用。
1746
1747**参数:**
1748
1749| 参数名     | 类型                      | 必填 | 说明                   |
1750| -------- | ------------------------- | ---- | ---------------------- |
1751| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)              | 是   | 指定应用的包信息。             |
1752| callback | AsyncCallback\<number\> | 是   | 获取通知通道数量回调函数。 |
1753
1754**错误码:**
1755
1756错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1757
1758| 错误码ID | 错误信息                                 |
1759| -------- | ---------------------------------------- |
1760| 1600001  | Internal error.                          |
1761| 1600002  | Marshalling or unmarshalling error.      |
1762| 1600003  | Failed to connect service.               |
1763| 17700001 | The specified bundle name was not found. |
1764
1765**示例:**
1766
1767```js
1768function getSlotNumByBundleCallback(err, data) {
1769    if (err) {
1770        console.info("getSlotNumByBundle failed " + JSON.stringify(err));
1771    } else {
1772        console.info("getSlotNumByBundle success");
1773    }
1774}
1775let bundle = {
1776    bundle: "bundleName1",
1777};
1778Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
1779```
1780
1781
1782
1783## Notification.getSlotNumByBundle
1784
1785getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
1786
1787获取指定应用的通知通道数量(Promise形式)。
1788
1789**系统能力**:SystemCapability.Notification.Notification
1790
1791**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1792
1793**系统API**: 此接口为系统接口,三方应用不支持调用。
1794
1795**参数:**
1796
1797| 参数名   | 类型         | 必填 | 说明       |
1798| ------ | ------------ | ---- | ---------- |
1799| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1800
1801**返回值:**
1802
1803| 类型                                                        | 说明                                                         |
1804| ----------------------------------------------------------- | ------------------------------------------------------------ |
1805| Promise\<number\> | 以Promise形式返回获取指定应用的通知通道数量。 |
1806
1807**错误码:**
1808
1809错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1810
1811| 错误码ID | 错误信息                                 |
1812| -------- | ---------------------------------------- |
1813| 1600001  | Internal error.                          |
1814| 1600002  | Marshalling or unmarshalling error.      |
1815| 1600003  | Failed to connect service.               |
1816| 17700001 | The specified bundle name was not found. |
1817
1818**示例:**
1819
1820```js
1821let bundle = {
1822    bundle: "bundleName1",
1823};
1824Notification.getSlotNumByBundle(bundle).then((data) => {
1825	console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
1826});
1827```
1828
1829
1830
1831
1832## Notification.getAllActiveNotifications
1833
1834getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
1835
1836获取当前未删除的所有通知(Callback形式)。
1837
1838**系统能力**:SystemCapability.Notification.Notification
1839
1840**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1841
1842**系统API**: 此接口为系统接口,三方应用不支持调用。
1843
1844**参数:**
1845
1846| 参数名     | 类型                                                         | 必填 | 说明                 |
1847| -------- | ------------------------------------------------------------ | ---- | -------------------- |
1848| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | 是   | 获取活动通知回调函数。 |
1849
1850**错误码:**
1851
1852错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1853
1854| 错误码ID | 错误信息                            |
1855| -------- | ----------------------------------- |
1856| 1600001  | Internal error.                     |
1857| 1600002  | Marshalling or unmarshalling error. |
1858| 1600003  | Failed to connect service.          |
1859
1860**示例:**
1861
1862```js
1863function getAllActiveNotificationsCallback(err, data) {
1864    if (err) {
1865        console.info("getAllActiveNotifications failed " + JSON.stringify(err));
1866    } else {
1867        console.info("getAllActiveNotifications success");
1868    }
1869}
1870
1871Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
1872```
1873
1874
1875
1876## Notification.getAllActiveNotifications
1877
1878getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\>
1879
1880获取当前未删除的所有通知(Promise形式)。
1881
1882**系统能力**:SystemCapability.Notification.Notification
1883
1884**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
1885
1886**系统API**: 此接口为系统接口,三方应用不支持调用。
1887
1888**返回值:**
1889
1890| 类型                                                        | 说明                                                         |
1891| ----------------------------------------------------------- | ------------------------------------------------------------ |
1892| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | 以Promise形式返回获取活动通知。 |
1893
1894**错误码:**
1895
1896错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1897
1898| 错误码ID | 错误信息                            |
1899| -------- | ----------------------------------- |
1900| 1600001  | Internal error.                     |
1901| 1600002  | Marshalling or unmarshalling error. |
1902| 1600003  | Failed to connect service.          |
1903
1904**示例:**
1905
1906```js
1907Notification.getAllActiveNotifications().then((data) => {
1908	console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
1909});
1910```
1911
1912
1913
1914## Notification.getActiveNotificationCount
1915
1916getActiveNotificationCount(callback: AsyncCallback\<number\>): void
1917
1918获取当前应用未删除的通知数(Callback形式)。
1919
1920**系统能力**:SystemCapability.Notification.Notification
1921
1922**参数:**
1923
1924| 参数名     | 类型                   | 必填 | 说明                   |
1925| -------- | ---------------------- | ---- | ---------------------- |
1926| callback | AsyncCallback\<number\> | 是   | 获取未删除通知数回调函数。 |
1927
1928**错误码:**
1929
1930错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1931
1932| 错误码ID | 错误信息                            |
1933| -------- | ----------------------------------- |
1934| 1600001  | Internal error.                     |
1935| 1600002  | Marshalling or unmarshalling error. |
1936| 1600003  | Failed to connect service.          |
1937
1938**示例:**
1939
1940```js
1941function getActiveNotificationCountCallback(err, data) {
1942    if (err) {
1943        console.info("getActiveNotificationCount failed " + JSON.stringify(err));
1944    } else {
1945        console.info("getActiveNotificationCount success");
1946    }
1947}
1948
1949Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
1950```
1951
1952
1953
1954## Notification.getActiveNotificationCount
1955
1956getActiveNotificationCount(): Promise\<number\>
1957
1958获取当前应用未删除的通知数(Promise形式)。
1959
1960**系统能力**:SystemCapability.Notification.Notification
1961
1962**返回值:**
1963
1964| 类型              | 说明                                        |
1965| ----------------- | ------------------------------------------- |
1966| Promise\<number\> | 以Promise形式返回获取当前应用未删除通知数。 |
1967
1968**错误码:**
1969
1970错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
1971
1972| 错误码ID | 错误信息                            |
1973| -------- | ----------------------------------- |
1974| 1600001  | Internal error.                     |
1975| 1600002  | Marshalling or unmarshalling error. |
1976| 1600003  | Failed to connect service.          |
1977
1978**示例:**
1979
1980```js
1981Notification.getActiveNotificationCount().then((data) => {
1982	console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
1983});
1984```
1985
1986
1987
1988## Notification.getActiveNotifications
1989
1990getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
1991
1992获取当前应用未删除的通知列表(Callback形式)。
1993
1994**系统能力**:SystemCapability.Notification.Notification
1995
1996**参数:**
1997
1998| 参数名     | 类型                                                         | 必填 | 说明                           |
1999| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
2000| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | 是   | 获取当前应用通知列表回调函数。 |
2001
2002**错误码:**
2003
2004错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2005
2006| 错误码ID | 错误信息                            |
2007| -------- | ----------------------------------- |
2008| 1600001  | Internal error.                     |
2009| 1600002  | Marshalling or unmarshalling error. |
2010| 1600003  | Failed to connect service.          |
2011
2012**示例:**
2013
2014```js
2015function getActiveNotificationsCallback(err, data) {
2016    if (err) {
2017        console.info("getActiveNotifications failed " + JSON.stringify(err));
2018    } else {
2019        console.info("getActiveNotifications success");
2020    }
2021}
2022
2023Notification.getActiveNotifications(getActiveNotificationsCallback);
2024```
2025
2026
2027
2028## Notification.getActiveNotifications
2029
2030getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\>
2031
2032获取当前应用未删除的通知列表(Promise形式)。
2033
2034**系统能力**:SystemCapability.Notification.Notification
2035
2036**返回值:**
2037
2038| 类型                                                         | 说明                                    |
2039| ------------------------------------------------------------ | --------------------------------------- |
2040| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | 以Promise形式返回获取当前应用通知列表。 |
2041
2042**错误码:**
2043
2044错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2045
2046| 错误码ID | 错误信息                            |
2047| -------- | ----------------------------------- |
2048| 1600001  | Internal error.                     |
2049| 1600002  | Marshalling or unmarshalling error. |
2050| 1600003  | Failed to connect service.          |
2051
2052**示例:**
2053
2054```js
2055Notification.getActiveNotifications().then((data) => {
2056	console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
2057});
2058```
2059
2060
2061
2062## Notification.cancelGroup
2063
2064cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
2065
2066取消本应用指定组下的通知(Callback形式)。
2067
2068**系统能力**:SystemCapability.Notification.Notification
2069
2070**参数:**
2071
2072| 参数名      | 类型                  | 必填 | 说明                         |
2073| --------- | --------------------- | ---- | ---------------------------- |
2074| groupName | string                | 是   | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)对象指定。 |
2075| callback  | AsyncCallback\<void\> | 是   | 取消本应用指定组下通知的回调函数。 |
2076
2077**错误码:**
2078
2079错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2080
2081| 错误码ID | 错误信息                            |
2082| -------- | ----------------------------------- |
2083| 1600001  | Internal error.                     |
2084| 1600002  | Marshalling or unmarshalling error. |
2085| 1600003  | Failed to connect service.          |
2086
2087**示例:**
2088
2089```js
2090function cancelGroupCallback(err) {
2091    if (err) {
2092        console.info("cancelGroup failed " + JSON.stringify(err));
2093    } else {
2094        console.info("cancelGroup success");
2095    }
2096}
2097
2098let groupName = "GroupName";
2099
2100Notification.cancelGroup(groupName, cancelGroupCallback);
2101```
2102
2103
2104
2105## Notification.cancelGroup
2106
2107cancelGroup(groupName: string): Promise\<void\>
2108
2109取消本应用指定组下的通知(Promise形式)。
2110
2111**系统能力**:SystemCapability.Notification.Notification
2112
2113**参数:**
2114
2115| 参数名      | 类型   | 必填 | 说明           |
2116| --------- | ------ | ---- | -------------- |
2117| groupName | string | 是   | 通知组名称。 |
2118
2119**错误码:**
2120
2121错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2122
2123| 错误码ID | 错误信息                            |
2124| -------- | ----------------------------------- |
2125| 1600001  | Internal error.                     |
2126| 1600002  | Marshalling or unmarshalling error. |
2127| 1600003  | Failed to connect service.          |
2128
2129**示例:**
2130
2131```js
2132let groupName = "GroupName";
2133Notification.cancelGroup(groupName).then(() => {
2134	console.info("cancelGroup success");
2135});
2136```
2137
2138
2139
2140## Notification.removeGroupByBundle
2141
2142removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
2143
2144删除指定应用的指定组下的通知(Callback形式)。
2145
2146**系统能力**:SystemCapability.Notification.Notification
2147
2148**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2149
2150**系统API**: 此接口为系统接口,三方应用不支持调用。
2151
2152**参数:**
2153
2154| 参数名      | 类型                  | 必填 | 说明                         |
2155| --------- | --------------------- | ---- | ---------------------------- |
2156| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 应用的包信息。                   |
2157| groupName | string                | 是   | 通知组名称。               |
2158| callback  | AsyncCallback\<void\> | 是   | 删除指定应用指定组下通知的回调函数。 |
2159
2160**错误码:**
2161
2162错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2163
2164| 错误码ID | 错误信息                                 |
2165| -------- | ---------------------------------------- |
2166| 1600001  | Internal error.                          |
2167| 1600002  | Marshalling or unmarshalling error.      |
2168| 1600003  | Failed to connect service.               |
2169| 17700001 | The specified bundle name was not found. |
2170
2171**示例:**
2172
2173```js
2174function removeGroupByBundleCallback(err) {
2175    if (err) {
2176        console.info("removeGroupByBundle failed " + JSON.stringify(err));
2177    } else {
2178        console.info("removeGroupByBundle success");
2179    }
2180}
2181
2182let bundleOption = {bundle: "Bundle"};
2183let groupName = "GroupName";
2184
2185Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
2186```
2187
2188
2189
2190## Notification.removeGroupByBundle
2191
2192removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
2193
2194删除指定应用的指定组下的通知(Promise形式)。
2195
2196**系统能力**:SystemCapability.Notification.Notification
2197
2198**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2199
2200**系统API**: 此接口为系统接口,三方应用不支持调用。
2201
2202**参数:**
2203
2204| 参数名      | 类型         | 必填 | 说明           |
2205| --------- | ------------ | ---- | -------------- |
2206| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。     |
2207| groupName | string       | 是   | 通知组名称。 |
2208
2209**错误码:**
2210
2211错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2212
2213| 错误码ID | 错误信息                                 |
2214| -------- | ---------------------------------------- |
2215| 1600001  | Internal error.                          |
2216| 1600002  | Marshalling or unmarshalling error.      |
2217| 1600003  | Failed to connect service.               |
2218| 17700001 | The specified bundle name was not found. |
2219
2220**示例:**
2221
2222```js
2223let bundleOption = {bundle: "Bundle"};
2224let groupName = "GroupName";
2225Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
2226	console.info("removeGroupByBundle success");
2227});
2228```
2229
2230
2231
2232## Notification.setDoNotDisturbDate
2233
2234setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
2235
2236设置免打扰时间(Callback形式)。
2237
2238**系统能力**:SystemCapability.Notification.Notification
2239
2240**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2241
2242**系统API**: 此接口为系统接口,三方应用不支持调用。
2243
2244**参数:**
2245
2246| 参数名     | 类型                  | 必填 | 说明                   |
2247| -------- | --------------------- | ---- | ---------------------- |
2248| date     | [DoNotDisturbDate](#donotdisturbdate)      | 是   | 免打扰时间选项。         |
2249| callback | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |
2250
2251**错误码:**
2252
2253错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2254
2255| 错误码ID | 错误信息                            |
2256| -------- | ----------------------------------- |
2257| 1600001  | Internal error.                     |
2258| 1600002  | Marshalling or unmarshalling error. |
2259| 1600003  | Failed to connect service.          |
2260
2261**示例:**
2262
2263```js
2264function setDoNotDisturbDateCallback(err) {
2265    if (err) {
2266        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
2267    } else {
2268        console.info("setDoNotDisturbDate success");
2269    }
2270}
2271
2272let doNotDisturbDate = {
2273    type: Notification.DoNotDisturbType.TYPE_ONCE,
2274    begin: new Date(),
2275    end: new Date(2021, 11, 15, 18, 0)
2276};
2277
2278Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
2279```
2280
2281
2282
2283## Notification.setDoNotDisturbDate
2284
2285setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
2286
2287设置免打扰时间(Promise形式)。
2288
2289**系统能力**:SystemCapability.Notification.Notification
2290
2291**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2292
2293**系统API**: 此接口为系统接口,三方应用不支持调用。
2294
2295**参数:**
2296
2297| 参数名 | 类型             | 必填 | 说明           |
2298| ---- | ---------------- | ---- | -------------- |
2299| date | [DoNotDisturbDate](#donotdisturbdate) | 是   | 免打扰时间选项。 |
2300
2301**错误码:**
2302
2303错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2304
2305| 错误码ID | 错误信息                            |
2306| -------- | ----------------------------------- |
2307| 1600001  | Internal error.                     |
2308| 1600002  | Marshalling or unmarshalling error. |
2309| 1600003  | Failed to connect service.          |
2310
2311**示例:**
2312
2313```js
2314let doNotDisturbDate = {
2315    type: Notification.DoNotDisturbType.TYPE_ONCE,
2316    begin: new Date(),
2317    end: new Date(2021, 11, 15, 18, 0)
2318};
2319Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
2320	console.info("setDoNotDisturbDate success");
2321});
2322```
2323
2324
2325## Notification.setDoNotDisturbDate
2326
2327setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void
2328
2329指定用户设置免打扰时间(Callback形式)。
2330
2331**系统能力**:SystemCapability.Notification.Notification
2332
2333**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2334
2335**系统API**: 此接口为系统接口,三方应用不支持调用。
2336
2337**参数:**
2338
2339| 参数名     | 类型                  | 必填 | 说明                   |
2340| -------- | --------------------- | ---- | ---------------------- |
2341| date     | [DoNotDisturbDate](#donotdisturbdate)      | 是   | 免打扰时间选项。         |
2342| userId   | number                | 是   | 设置免打扰时间的用户ID。 |
2343| callback | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |
2344
2345**错误码:**
2346
2347错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2348
2349| 错误码ID | 错误信息                            |
2350| -------- | ----------------------------------- |
2351| 1600001  | Internal error.                     |
2352| 1600002  | Marshalling or unmarshalling error. |
2353| 1600003  | Failed to connect service.          |
2354| 1600008  | The user is not exist.              |
2355
2356**示例:**
2357
2358```js
2359function setDoNotDisturbDateCallback(err) {
2360    if (err) {
2361        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
2362    } else {
2363        console.info("setDoNotDisturbDate success");
2364    }
2365}
2366
2367let doNotDisturbDate = {
2368    type: Notification.DoNotDisturbType.TYPE_ONCE,
2369    begin: new Date(),
2370    end: new Date(2021, 11, 15, 18, 0)
2371};
2372
2373let userId = 1;
2374
2375Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
2376```
2377
2378
2379
2380## Notification.setDoNotDisturbDate
2381
2382setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
2383
2384指定用户设置免打扰时间(Promise形式)。
2385
2386**系统能力**:SystemCapability.Notification.Notification
2387
2388**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2389
2390**系统API**: 此接口为系统接口,三方应用不支持调用。
2391
2392**参数:**
2393
2394| 参数名   | 类型             | 必填 | 说明           |
2395| ------ | ---------------- | ---- | -------------- |
2396| date   | [DoNotDisturbDate](#donotdisturbdate) | 是   | 免打扰时间选项。 |
2397| userId | number           | 是   | 设置免打扰时间的用户ID。 |
2398
2399**错误码:**
2400
2401错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2402
2403| 错误码ID | 错误信息                            |
2404| -------- | ----------------------------------- |
2405| 1600001  | Internal error.                     |
2406| 1600002  | Marshalling or unmarshalling error. |
2407| 1600003  | Failed to connect service.          |
2408| 1600008  | The user is not exist.              |
2409
2410**示例:**
2411
2412```js
2413let doNotDisturbDate = {
2414    type: Notification.DoNotDisturbType.TYPE_ONCE,
2415    begin: new Date(),
2416    end: new Date(2021, 11, 15, 18, 0)
2417};
2418
2419let userId = 1;
2420
2421Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
2422	console.info("setDoNotDisturbDate success");
2423});
2424```
2425
2426
2427## Notification.getDoNotDisturbDate
2428
2429getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
2430
2431查询免打扰时间(Callback形式)。
2432
2433**系统能力**:SystemCapability.Notification.Notification
2434
2435**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2436
2437**系统API**: 此接口为系统接口,三方应用不支持调用。
2438
2439**参数:**
2440
2441| 参数名     | 类型                              | 必填 | 说明                   |
2442| -------- | --------------------------------- | ---- | ---------------------- |
2443| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是   | 查询免打扰时间回调函数。 |
2444
2445**错误码:**
2446
2447错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2448
2449| 错误码ID | 错误信息                            |
2450| -------- | ----------------------------------- |
2451| 1600001  | Internal error.                     |
2452| 1600002  | Marshalling or unmarshalling error. |
2453| 1600003  | Failed to connect service.          |
2454
2455**示例:**
2456
2457```js
2458function getDoNotDisturbDateCallback(err,data) {
2459    if (err) {
2460        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
2461    } else {
2462        console.info("getDoNotDisturbDate success");
2463    }
2464}
2465
2466Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
2467```
2468
2469
2470
2471## Notification.getDoNotDisturbDate
2472
2473getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
2474
2475查询免打扰时间(Promise形式)。
2476
2477**系统能力**:SystemCapability.Notification.Notification
2478
2479**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2480
2481**系统API**: 此接口为系统接口,三方应用不支持调用。
2482
2483**返回值:**
2484
2485| 类型                                             | 说明                                      |
2486| ------------------------------------------------ | ----------------------------------------- |
2487| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
2488
2489**错误码:**
2490
2491错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2492
2493| 错误码ID | 错误信息                            |
2494| -------- | ----------------------------------- |
2495| 1600001  | Internal error.                     |
2496| 1600002  | Marshalling or unmarshalling error. |
2497| 1600003  | Failed to connect service.          |
2498
2499**示例:**
2500
2501```js
2502Notification.getDoNotDisturbDate().then((data) => {
2503	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
2504});
2505```
2506
2507
2508## Notification.getDoNotDisturbDate
2509
2510getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
2511
2512查询指定用户的免打扰时间(Callback形式)。
2513
2514**系统能力**:SystemCapability.Notification.Notification
2515
2516**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2517
2518**系统API**: 此接口为系统接口,三方应用不支持调用。
2519
2520**参数:**
2521
2522| 参数名     | 类型                              | 必填 | 说明                   |
2523| -------- | --------------------------------- | ---- | ---------------------- |
2524| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是   | 查询免打扰时间回调函数。 |
2525| userId   | number                            | 是   | 用户ID。 |
2526
2527**错误码:**
2528
2529错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2530
2531| 错误码ID | 错误信息                            |
2532| -------- | ----------------------------------- |
2533| 1600001  | Internal error.                     |
2534| 1600002  | Marshalling or unmarshalling error. |
2535| 1600003  | Failed to connect service.          |
2536| 1600008  | The user is not exist.              |
2537
2538**示例:**
2539
2540```js
2541function getDoNotDisturbDateCallback(err,data) {
2542    if (err) {
2543        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
2544    } else {
2545        console.info("getDoNotDisturbDate success");
2546    }
2547}
2548
2549let userId = 1;
2550
2551Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
2552```
2553
2554
2555
2556## Notification.getDoNotDisturbDate
2557
2558getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
2559
2560查询指定用户的免打扰时间(Promise形式)。
2561
2562**系统能力**:SystemCapability.Notification.Notification
2563
2564**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2565
2566**系统API**: 此接口为系统接口,三方应用不支持调用。
2567
2568**参数:**
2569
2570| 参数名     | 类型                              | 必填 | 说明                   |
2571| -------- | --------------------------------- | ---- | ---------------------- |
2572| userId   | number                            | 是   | 用户ID。 |
2573
2574**返回值:**
2575
2576| 类型                                             | 说明                                      |
2577| ------------------------------------------------ | ----------------------------------------- |
2578| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
2579
2580**错误码:**
2581
2582错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2583
2584| 错误码ID | 错误信息                            |
2585| -------- | ----------------------------------- |
2586| 1600001  | Internal error.                     |
2587| 1600002  | Marshalling or unmarshalling error. |
2588| 1600003  | Failed to connect service.          |
2589| 1600008  | The user is not exist.              |
2590
2591**示例:**
2592
2593```js
2594let userId = 1;
2595
2596Notification.getDoNotDisturbDate(userId).then((data) => {
2597	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
2598});
2599```
2600
2601
2602## Notification.isSupportDoNotDisturbMode
2603
2604isSupportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
2605
2606查询是否支持免打扰功能(Callback形式)。
2607
2608**系统能力**:SystemCapability.Notification.Notification
2609
2610**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2611
2612**系统API**: 此接口为系统接口,三方应用不支持调用。
2613
2614**参数:**
2615
2616| 参数名     | 类型                     | 必填 | 说明                             |
2617| -------- | ------------------------ | ---- | -------------------------------- |
2618| callback | AsyncCallback\<boolean\> | 是   | 查询是否支持免打扰功能回调函数。 |
2619
2620**错误码:**
2621
2622错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2623
2624| 错误码ID | 错误信息                            |
2625| -------- | ----------------------------------- |
2626| 1600001  | Internal error.                     |
2627| 1600002  | Marshalling or unmarshalling error. |
2628| 1600003  | Failed to connect service.          |
2629
2630**示例:**
2631
2632```js
2633function isSupportDoNotDisturbModeCallback(err,data) {
2634    if (err) {
2635        console.info("isSupportDoNotDisturbMode failed " + JSON.stringify(err));
2636    } else {
2637        console.info("isSupportDoNotDisturbMode success");
2638    }
2639}
2640
2641Notification.isSupportDoNotDisturbMode(supportDoNotDisturbModeCallback);
2642```
2643
2644
2645
2646## Notification.isSupportDoNotDisturbMode
2647
2648isSupportDoNotDisturbMode(): Promise\<boolean\>
2649
2650查询是否支持勿扰模式功能(Promise形式)。
2651
2652**系统能力**:SystemCapability.Notification.Notification
2653
2654**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2655
2656**系统API**: 此接口为系统接口,三方应用不支持调用。
2657
2658**返回值:**
2659
2660| 类型                                                        | 说明                                                         |
2661| ----------------------------------------------------------- | ------------------------------------------------------------ |
2662| Promise\<boolean\> | 以Promise形式返回获取是否支持免打扰功能的结果。 |
2663
2664**错误码:**
2665
2666错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2667
2668| 错误码ID | 错误信息                            |
2669| -------- | ----------------------------------- |
2670| 1600001  | Internal error.                     |
2671| 1600002  | Marshalling or unmarshalling error. |
2672| 1600003  | Failed to connect service.          |
2673
2674**示例:**
2675
2676```js
2677Notification.isSupportDoNotDisturbMode().then((data) => {
2678	console.info("isSupportDoNotDisturbMode success, data: " + JSON.stringify(data));
2679});
2680```
2681
2682
2683
2684## Notification.isSupportTemplate
2685
2686isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void
2687
2688查询模板是否存在(Callback形式)。
2689
2690**系统能力**:SystemCapability.Notification.Notification
2691
2692**参数:**
2693
2694| 参数名       | 类型                     | 必填 | 说明                       |
2695| ------------ | ------------------------ | ---- | -------------------------- |
2696| templateName | string                   | 是   | 模板名称。                   |
2697| callback     | AsyncCallback\<boolean\> | 是   | 查询模板是否存在的回调函数。 |
2698
2699**错误码:**
2700
2701错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2702
2703| 错误码ID | 错误信息                            |
2704| -------- | ----------------------------------- |
2705| 1600001  | Internal error.                     |
2706| 1600002  | Marshalling or unmarshalling error. |
2707| 1600003  | Failed to connect service.          |
2708
2709**示例:**
2710
2711```javascript
2712let templateName = 'process';
2713function isSupportTemplateCallback(err, data) {
2714    if (err) {
2715        console.info("isSupportTemplate failed " + JSON.stringify(err));
2716    } else {
2717        console.info("isSupportTemplate success");
2718    }
2719}
2720
2721Notification.isSupportTemplate(templateName, isSupportTemplateCallback);
2722```
2723
2724
2725
2726## Notification.isSupportTemplate
2727
2728isSupportTemplate(templateName: string): Promise\<boolean\>
2729
2730查询模板是否存在(Promise形式)。
2731
2732**系统能力**:SystemCapability.Notification.Notification
2733
2734**参数:**
2735
2736| 参数名       | 类型   | 必填 | 说明     |
2737| ------------ | ------ | ---- | -------- |
2738| templateName | string | 是   | 模板名称。 |
2739
2740**返回值:**
2741
2742| 类型               | 说明            |
2743| ------------------ | --------------- |
2744| Promise\<boolean\> | Promise方式返回模板是否存在的结果。 |
2745
2746**错误码:**
2747
2748错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2749
2750| 错误码ID | 错误信息                            |
2751| -------- | ----------------------------------- |
2752| 1600001  | Internal error.                     |
2753| 1600002  | Marshalling or unmarshalling error. |
2754| 1600003  | Failed to connect service.          |
2755
2756**示例:**
2757
2758```javascript
2759let templateName = 'process';
2760
2761Notification.isSupportTemplate(templateName).then((data) => {
2762    console.info("isSupportTemplate success, data: " + JSON.stringify(data));
2763});
2764```
2765
2766
2767
2768## Notification.requestEnableNotification
2769
2770requestEnableNotification(callback: AsyncCallback\<void\>): void
2771
2772应用请求通知使能(Callback形式)。
2773
2774**系统能力**:SystemCapability.Notification.Notification
2775
2776**参数:**
2777
2778| 参数名   | 类型                     | 必填 | 说明                       |
2779| -------- | ------------------------ | ---- | -------------------------- |
2780| callback | AsyncCallback\<void\> | 是   | 应用请求通知使能的回调函数。 |
2781
2782**错误码:**
2783
2784错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2785
2786| 错误码ID | 错误信息                            |
2787| -------- | ----------------------------------- |
2788| 1600001  | Internal error.                     |
2789| 1600002  | Marshalling or unmarshalling error. |
2790| 1600003  | Failed to connect service.          |
2791
2792**示例:**
2793
2794```javascript
2795function requestEnableNotificationCallback(err) {
2796    if (err) {
2797        console.info("requestEnableNotification failed " + JSON.stringify(err));
2798    } else {
2799        console.info("requestEnableNotification success");
2800    }
2801};
2802
2803Notification.requestEnableNotification(requestEnableNotificationCallback);
2804```
2805
2806
2807
2808## Notification.requestEnableNotification
2809
2810requestEnableNotification(): Promise\<void\>
2811
2812应用请求通知使能(Promise形式)。
2813
2814**系统能力**:SystemCapability.Notification.Notification
2815
2816**错误码:**
2817
2818错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2819
2820| 错误码ID | 错误信息                            |
2821| -------- | ----------------------------------- |
2822| 1600001  | Internal error.                     |
2823| 1600002  | Marshalling or unmarshalling error. |
2824| 1600003  | Failed to connect service.          |
2825
2826**示例:**
2827
2828```javascript
2829Notification.requestEnableNotification().then(() => {
2830    console.info("requestEnableNotification success");
2831});
2832```
2833
2834
2835
2836## Notification.setDistributedEnable
2837
2838setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
2839
2840设置设备是否支持分布式通知(Callback形式)。
2841
2842**系统能力**:SystemCapability.Notification.Notification
2843
2844**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2845
2846**系统API**: 此接口为系统接口,三方应用不支持调用。
2847
2848**参数:**
2849
2850| 参数名   | 类型                     | 必填 | 说明                       |
2851| -------- | ------------------------ | ---- | -------------------------- |
2852| enable   | boolean                  | 是   | 是否支持。 |
2853| callback | AsyncCallback\<void\> | 是   | 设置设备是否支持分布式通知的回调函数。 |
2854
2855**错误码:**
2856
2857错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2858
2859| 错误码ID | 错误信息                            |
2860| -------- | ----------------------------------- |
2861| 1600001  | Internal error.                     |
2862| 1600002  | Marshalling or unmarshalling error. |
2863| 1600003  | Failed to connect service.          |
2864| 1600010  | Distributed operation failed.       |
2865
2866**示例:**
2867
2868```javascript
2869function setDistributedEnableCallback(err) {
2870    if (err) {
2871        console.info("setDistributedEnable failed " + JSON.stringify(err));
2872    } else {
2873        console.info("setDistributedEnable success");
2874    }
2875};
2876
2877let enable = true;
2878
2879Notification.setDistributedEnable(enable, setDistributedEnableCallback);
2880```
2881
2882
2883
2884## Notification.setDistributedEnable
2885
2886setDistributedEnable(enable: boolean): Promise\<void>
2887
2888设置设备是否支持分布式通知(Promise形式)。
2889
2890**系统能力**:SystemCapability.Notification.Notification
2891
2892**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
2893
2894**系统API**: 此接口为系统接口,三方应用不支持调用。
2895
2896**参数:**
2897
2898| 参数名   | 类型                     | 必填 | 说明                       |
2899| -------- | ------------------------ | ---- | -------------------------- |
2900| enable   | boolean                  | 是   | 是否支持。 |
2901
2902**错误码:**
2903
2904错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2905
2906| 错误码ID | 错误信息                            |
2907| -------- | ----------------------------------- |
2908| 1600001  | Internal error.                     |
2909| 1600002  | Marshalling or unmarshalling error. |
2910| 1600003  | Failed to connect service.          |
2911| 1600010  | Distributed operation failed.       |
2912
2913**示例:**
2914
2915```javascript
2916let enable = true;
2917
2918Notification.setDistributedEnable(enable).then(() => {
2919        console.info("setDistributedEnable success");
2920    });
2921```
2922
2923
2924## Notification.isDistributedEnabled
2925
2926isDistributedEnabled(callback: AsyncCallback\<boolean>): void
2927
2928查询设备是否支持分布式通知(Callback形式)。
2929
2930**系统能力**:SystemCapability.Notification.Notification
2931
2932**参数:**
2933
2934| 参数名   | 类型                     | 必填 | 说明                       |
2935| -------- | ------------------------ | ---- | -------------------------- |
2936| callback | AsyncCallback\<boolean\> | 是   | 设备是否支持分布式通知的回调函数。 |
2937
2938**错误码:**
2939
2940错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2941
2942| 错误码ID | 错误信息                            |
2943| -------- | ----------------------------------- |
2944| 1600001  | Internal error.                     |
2945| 1600002  | Marshalling or unmarshalling error. |
2946| 1600003  | Failed to connect service.          |
2947| 1600010  | Distributed operation failed.       |
2948
2949**示例:**
2950
2951```javascript
2952function isDistributedEnabledCallback(err, data) {
2953    if (err) {
2954        console.info("isDistributedEnabled failed " + JSON.stringify(err));
2955    } else {
2956        console.info("isDistributedEnabled success " + JSON.stringify(data));
2957    }
2958};
2959
2960Notification.isDistributedEnabled(isDistributedEnabledCallback);
2961```
2962
2963
2964
2965## Notification.isDistributedEnabled
2966
2967isDistributedEnabled(): Promise\<boolean>
2968
2969查询设备是否支持分布式通知(Promise形式)。
2970
2971**系统能力**:SystemCapability.Notification.Notification
2972
2973**返回值:**
2974
2975| 类型               | 说明                                          |
2976| ------------------ | --------------------------------------------- |
2977| Promise\<boolean\> | Promise方式返回设备是否支持分布式通知的结果。 |
2978
2979**错误码:**
2980
2981错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
2982
2983| 错误码ID | 错误信息                            |
2984| -------- | ----------------------------------- |
2985| 1600001  | Internal error.                     |
2986| 1600002  | Marshalling or unmarshalling error. |
2987| 1600003  | Failed to connect service.          |
2988| 1600010  | Distributed operation failed.       |
2989
2990**示例:**
2991
2992```javascript
2993Notification.isDistributedEnabled()
2994    .then((data) => {
2995        console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
2996    });
2997```
2998
2999
3000## Notification.setDistributedEnableByBundle
3001
3002setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
3003
3004设置指定应用是否支持分布式通知(Callback形式)。
3005
3006**系统能力**:SystemCapability.Notification.Notification
3007
3008**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
3009
3010**系统API**: 此接口为系统接口,三方应用不支持调用。
3011
3012**参数:**
3013
3014| 参数名   | 类型                     | 必填 | 说明                       |
3015| -------- | ------------------------ | ---- | -------------------------- |
3016| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包信息。                   |
3017| enable   | boolean                  | 是   | 是否支持。                       |
3018| callback | AsyncCallback\<void\> | 是   | 应用程序是否支持分布式通知的回调函数。 |
3019
3020**错误码:**
3021
3022错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3023
3024| 错误码ID | 错误信息                                 |
3025| -------- | ---------------------------------------- |
3026| 1600001  | Internal error.                          |
3027| 1600002  | Marshalling or unmarshalling error.      |
3028| 1600003  | Failed to connect service.               |
3029| 1600010  | Distributed operation failed.            |
3030| 17700001 | The specified bundle name was not found. |
3031
3032**示例:**
3033
3034```javascript
3035function setDistributedEnableByBundleCallback(err) {
3036    if (err) {
3037        console.info("enableDistributedByBundle failed " + JSON.stringify(err));
3038    } else {
3039        console.info("enableDistributedByBundle success");
3040    }
3041};
3042
3043let bundle = {
3044    bundle: "bundleName1",
3045};
3046
3047let enable = true
3048
3049Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback);
3050```
3051
3052
3053
3054## Notification.setDistributedEnableByBundle
3055
3056setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
3057
3058设置指定应用是否支持分布式通知(Promise形式)。
3059
3060**系统能力**:SystemCapability.Notification.Notification
3061
3062**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
3063
3064**系统API**: 此接口为系统接口,三方应用不支持调用。
3065
3066**参数:**
3067
3068| 参数名   | 类型                     | 必填 | 说明                       |
3069| -------- | ------------------------ | ---- | -------------------------- |
3070| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                |
3071| enable   | boolean                  | 是   | 是否支持。                  |
3072
3073**错误码:**
3074
3075错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3076
3077| 错误码ID | 错误信息                                 |
3078| -------- | ---------------------------------------- |
3079| 1600001  | Internal error.                          |
3080| 1600002  | Marshalling or unmarshalling error.      |
3081| 1600003  | Failed to connect service.               |
3082| 1600010  | Distributed operation failed.            |
3083| 17700001 | The specified bundle name was not found. |
3084
3085**示例:**
3086
3087```javascript
3088let bundle = {
3089    bundle: "bundleName1",
3090};
3091
3092let enable = true
3093
3094Notification.setDistributedEnableByBundle(bundle, enable).then(() => {
3095        console.info("setDistributedEnableByBundle success");
3096    });
3097```
3098
3099## Notification.isDistributedEnabledByBundle
3100
3101isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
3102
3103根据应用的包获取应用程序是否支持分布式通知(Callback形式)。
3104
3105**系统能力**:SystemCapability.Notification.Notification
3106
3107**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
3108
3109**系统API**: 此接口为系统接口,三方应用不支持调用。
3110
3111**参数:**
3112
3113| 参数名   | 类型                     | 必填 | 说明                       |
3114| -------- | ------------------------ | ---- | -------------------------- |
3115| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                     |
3116| callback | AsyncCallback\<boolean\> | 是   | 查询指定应用是否支持分布式通知的回调函数。 |
3117
3118**错误码:**
3119
3120错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3121
3122| 错误码ID | 错误信息                                 |
3123| -------- | ---------------------------------------- |
3124| 1600001  | Internal error.                          |
3125| 1600002  | Marshalling or unmarshalling error.      |
3126| 1600003  | Failed to connect service.               |
3127| 1600010  | Distributed operation failed.            |
3128| 17700001 | The specified bundle name was not found. |
3129
3130**示例:**
3131
3132```javascript
3133function isDistributedEnabledByBundleCallback(err, data) {
3134    if (err) {
3135        console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
3136    } else {
3137        console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
3138    }
3139};
3140
3141let bundle = {
3142    bundle: "bundleName1",
3143};
3144
3145Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
3146```
3147
3148
3149
3150## Notification.isDistributedEnabledByBundle
3151
3152isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
3153
3154查询指定应用是否支持分布式通知(Promise形式)。
3155
3156**系统能力**:SystemCapability.Notification.Notification
3157
3158**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
3159
3160**系统API**: 此接口为系统接口,三方应用不支持调用。
3161
3162**参数:**
3163
3164| 参数名   | 类型                     | 必填 | 说明                       |
3165| -------- | ------------------------ | ---- | -------------------------- |
3166| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                |
3167
3168**返回值:**
3169
3170| 类型               | 说明                                              |
3171| ------------------ | ------------------------------------------------- |
3172| Promise\<boolean\> | Promise方式返回指定应用是否支持分布式通知的结果。 |
3173
3174**错误码:**
3175
3176错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3177
3178| 错误码ID | 错误信息                                 |
3179| -------- | ---------------------------------------- |
3180| 1600001  | Internal error.                          |
3181| 1600002  | Marshalling or unmarshalling error.      |
3182| 1600003  | Failed to connect service.               |
3183| 1600010  | Distributed operation failed.            |
3184| 17700001 | The specified bundle name was not found. |
3185
3186**示例:**
3187
3188```javascript
3189let bundle = {
3190    bundle: "bundleName1",
3191};
3192
3193Notification.isDistributedEnabledByBundle(bundle).then((data) => {
3194    console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
3195});
3196```
3197
3198
3199## Notification.getDeviceRemindType
3200
3201getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
3202
3203获取通知的提醒方式(Callback形式)。
3204
3205**系统能力**:SystemCapability.Notification.Notification
3206
3207**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
3208
3209**系统API**: 此接口为系统接口,三方应用不支持调用。
3210
3211**参数:**
3212
3213| 参数名   | 类型                               | 必填 | 说明                       |
3214| -------- | --------------------------------- | ---- | -------------------------- |
3215| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | 是   | 获取通知提醒方式的回调函数。 |
3216
3217**错误码:**
3218
3219错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3220
3221| 错误码ID | 错误信息                            |
3222| -------- | ----------------------------------- |
3223| 1600001  | Internal error.                     |
3224| 1600002  | Marshalling or unmarshalling error. |
3225| 1600003  | Failed to connect service.          |
3226
3227**示例:**
3228
3229```javascript
3230function getDeviceRemindTypeCallback(err, data) {
3231    if (err) {
3232        console.info("getDeviceRemindType failed " + JSON.stringify(err));
3233    } else {
3234        console.info("getDeviceRemindType success");
3235    }
3236};
3237
3238Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
3239```
3240
3241
3242
3243## Notification.getDeviceRemindType
3244
3245getDeviceRemindType(): Promise\<DeviceRemindType\>
3246
3247获取通知的提醒方式(Promise形式)。
3248
3249**系统能力**:SystemCapability.Notification.Notification
3250
3251**需要权限**: ohos.permission.NOTIFICATION_CONTROLLER
3252
3253**系统API**: 此接口为系统接口,三方应用不支持调用。
3254
3255**返回值:**
3256
3257| 类型               | 说明            |
3258| ------------------ | --------------- |
3259| Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise方式返回获取通知提醒方式的结果。 |
3260
3261**错误码:**
3262
3263错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3264
3265| 错误码ID | 错误信息                            |
3266| -------- | ----------------------------------- |
3267| 1600001  | Internal error.                     |
3268| 1600002  | Marshalling or unmarshalling error. |
3269| 1600003  | Failed to connect service.          |
3270
3271**示例:**
3272
3273```javascript
3274Notification.getDeviceRemindType().then((data) => {
3275    console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
3276});
3277```
3278
3279
3280## Notification.publishAsBundle
3281
3282publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
3283
3284发布代理通知(callback形式)。
3285
3286**系统能力**:SystemCapability.Notification.Notification
3287
3288**需要权限**: ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3289
3290**系统API**: 此接口为系统接口,三方应用不支持调用。
3291
3292**参数:**
3293
3294| 参数名               | 类型                                        | 必填 | 说明                                     |
3295| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
3296| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
3297| representativeBundle | string                                      | 是   | 被代理应用的包名。                       |
3298| userId               | number                                      | 是   | 用户ID。                                 |
3299| callback             | AsyncCallback                               | 是   | 发布代理通知的回调方法。                 |
3300
3301**错误码:**
3302
3303错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3304
3305| 错误码ID | 错误信息                                  |
3306| -------- | ----------------------------------------- |
3307| 1600001  | Internal error.                           |
3308| 1600002  | Marshalling or unmarshalling error.       |
3309| 1600003  | Failed to connect service.                |
3310| 1600004  | Notification is not enabled.              |
3311| 1600005  | Notification slot is not enabled.         |
3312| 1600008  | The user is not exist.                    |
3313| 1600009  | Over max number notifications per second. |
3314
3315**示例:**
3316
3317```js
3318//publishAsBundle回调
3319function callback(err) {
3320    if (err) {
3321        console.info("publishAsBundle failed " + JSON.stringify(err));
3322    } else {
3323        console.info("publishAsBundle success");
3324    }
3325}
3326// 被代理应用的包名
3327let representativeBundle = "com.example.demo";
3328// 用户ID
3329let userId = 100;
3330// NotificationRequest对象
3331let request = {
3332    id: 1,
3333    content: {
3334        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
3335        normal: {
3336            title: "test_title",
3337            text: "test_text",
3338            additionalText: "test_additionalText"
3339        }
3340    }
3341};
3342
3343Notification.publishAsBundle(request, representativeBundle, userId, callback);
3344```
3345
3346## Notification.publishAsBundle
3347
3348publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
3349
3350发布代理通知(Promise形式)。
3351
3352**系统能力**:SystemCapability.Notification.Notification
3353
3354**需要权限**: ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3355
3356**系统API**: 此接口为系统接口,三方应用不支持调用。
3357
3358**参数:**
3359
3360
3361| 参数名               | 类型                                        | 必填 | 说明                                          |
3362| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
3363| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
3364| representativeBundle | string                                      | 是   | 被代理应用的包名。                            |
3365| userId               | number                                      | 是   | 用户ID。                            |
3366
3367**错误码:**
3368
3369错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3370
3371| 错误码ID | 错误信息                                  |
3372| -------- | ----------------------------------------- |
3373| 1600001  | Internal error.                           |
3374| 1600002  | Marshalling or unmarshalling error.       |
3375| 1600003  | Failed to connect service.                |
3376| 1600004  | Notification is not enabled.              |
3377| 1600005  | Notification slot is not enabled.         |
3378| 1600008  | The user is not exist.                    |
3379| 1600009  | Over max number notifications per second. |
3380
3381**示例:**
3382
3383```js
3384// 被代理应用的包名
3385let representativeBundle = "com.example.demo";
3386// 用户ID
3387let userId = 100;
3388// NotificationRequest对象
3389let request = {
3390    id: 1,
3391    content: {
3392        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
3393        normal: {
3394            title: "test_title",
3395            text: "test_text",
3396            additionalText: "test_additionalText"
3397        }
3398    }
3399};
3400
3401Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
3402	console.info("publishAsBundle success");
3403});
3404```
3405
3406## Notification.cancelAsBundle
3407
3408cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
3409
3410取消代理通知(callback形式)。
3411
3412**系统能力**:SystemCapability.Notification.Notification
3413
3414**系统API**:此接口为系统接口,三方应用不支持调用。
3415
3416**需要权限**: ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3417
3418**系统API**: 此接口为系统接口,三方应用不支持调用。
3419
3420**参数:**
3421
3422| 参数名               | 类型          | 必填 | 说明                     |
3423| -------------------- | ------------- | ---- | ------------------------ |
3424| id                   | number        | 是   | 通知ID。                 |
3425| representativeBundle | string        | 是   | 被代理应用的包名。       |
3426| userId               | number        | 是   | 用户ID。       |
3427| callback             | AsyncCallback | 是   | 取消代理通知的回调方法。 |
3428
3429**错误码:**
3430
3431错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3432
3433| 错误码ID | 错误信息                            |
3434| -------- | ----------------------------------- |
3435| 1600001  | Internal error.                     |
3436| 1600002  | Marshalling or unmarshalling error. |
3437| 1600003  | Failed to connect service.          |
3438| 1600007  | The notification is not exist.      |
3439| 1600008  | The user is not exist.              |
3440
3441**示例:**
3442
3443```js
3444// cancelAsBundle
3445function cancelAsBundleCallback(err) {
3446    if (err) {
3447        console.info("cancelAsBundle failed " + JSON.stringify(err));
3448    } else {
3449        console.info("cancelAsBundle success");
3450    }
3451}
3452// 被代理应用的包名
3453let representativeBundle = "com.example.demo";
3454// 用户ID
3455let userId = 100;
3456
3457Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
3458```
3459
3460## Notification.cancelAsBundle
3461
3462cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
3463
3464取消代理通知(Promise形式)。
3465
3466**系统能力**:SystemCapability.Notification.Notification
3467
3468**系统API**:此接口为系统接口,三方应用不支持调用。
3469
3470**需要权限**: ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3471
3472**系统API**: 此接口为系统接口,三方应用不支持调用。
3473
3474**参数:**
3475
3476| 参数名               | 类型   | 必填 | 说明               |
3477| -------------------- | ------ | ---- | ------------------ |
3478| id                   | number | 是   | 通知ID。           |
3479| representativeBundle | string | 是   | 被代理应用的包名。 |
3480| userId               | number | 是   | 用户ID。 |
3481
3482**错误码:**
3483
3484错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3485
3486| 错误码ID | 错误信息                            |
3487| -------- | ----------------------------------- |
3488| 1600001  | Internal error.                     |
3489| 1600002  | Marshalling or unmarshalling error. |
3490| 1600003  | Failed to connect service.          |
3491| 1600007  | The notification is not exist.      |
3492| 1600008  | The user is not exist.              |
3493
3494**示例:**
3495
3496```js
3497// 被代理应用的包名
3498let representativeBundle = "com.example.demo";
3499// 用户ID
3500let userId = 100;
3501
3502Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
3503	console.info("cancelAsBundle success");
3504});
3505```
3506
3507## Notification.setNotificationEnableSlot
3508
3509setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
3510
3511设置指定应用的指定渠道类型的使能状态(Callback形式)。
3512
3513**系统能力**:SystemCapability.Notification.Notification
3514
3515**系统API**:此接口为系统接口,三方应用不支持调用。
3516
3517**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3518
3519**参数:**
3520
3521| 参数名   | 类型                          | 必填 | 说明                   |
3522| -------- | ----------------------------- | ---- | ---------------------- |
3523| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3524| type     | [SlotType](#slottype)         | 是   | 指定渠道类型。         |
3525| enable   | boolean                       | 是   | 使能状态。             |
3526| callback | AsyncCallback\<void\>         | 是   | 设置渠道使能回调函数。 |
3527
3528**错误码:**
3529
3530错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3531
3532| 错误码ID | 错误信息                                 |
3533| -------- | ---------------------------------------- |
3534| 1600001  | Internal error.                          |
3535| 1600002  | Marshalling or unmarshalling error.      |
3536| 1600003  | Failed to connect service.               |
3537| 17700001 | The specified bundle name was not found. |
3538
3539**示例:**
3540
3541```js
3542// setNotificationEnableSlot
3543function setNotificationEnableSlotCallback(err) {
3544    if (err) {
3545        console.info("setNotificationEnableSlot failed " + JSON.stringify(err));
3546    } else {
3547        console.info("setNotificationEnableSlot success");
3548    }
3549};
3550
3551Notification.setNotificationEnableSlot(
3552    { bundle: "ohos.samples.notification", },
3553    Notification.SlotType.SOCIAL_COMMUNICATION,
3554    true,
3555    setNotificationEnableSlotCallback);
3556```
3557
3558## Notification.setNotificationEnableSlot
3559
3560setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void>
3561
3562设置指定应用的指定渠道类型的使能状态(Promise形式)。
3563
3564**系统能力**:SystemCapability.Notification.Notification
3565
3566**系统API**:此接口为系统接口,三方应用不支持调用。
3567
3568**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3569
3570**参数:**
3571
3572| 参数名 | 类型                          | 必填 | 说明           |
3573| ------ | ----------------------------- | ---- | -------------- |
3574| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。   |
3575| type   | [SlotType](#slottype)         | 是   | 渠道类型。 |
3576| enable | boolean                       | 是   | 使能状态。     |
3577
3578**错误码:**
3579
3580错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3581
3582| 错误码ID | 错误信息                                 |
3583| -------- | ---------------------------------------- |
3584| 1600001  | Internal error.                          |
3585| 1600002  | Marshalling or unmarshalling error.      |
3586| 1600003  | Failed to connect service.               |
3587| 17700001 | The specified bundle name was not found. |
3588
3589**示例:**
3590
3591```js
3592// setNotificationEnableSlot
3593Notification.setNotificationEnableSlot(
3594    { bundle: "ohos.samples.notification", },
3595    Notification.SlotType.SOCIAL_COMMUNICATION,
3596    true).then(() => {
3597        console.info("setNotificationEnableSlot success");
3598    });
3599```
3600
3601## Notification.isNotificationSlotEnabled
3602
3603isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
3604
3605获取指定应用的指定渠道类型的使能状态(Callback形式)。
3606
3607**系统能力**:SystemCapability.Notification.Notification
3608
3609**系统API**:此接口为系统接口,三方应用不支持调用。
3610
3611**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3612
3613**参数:**
3614
3615| 参数名   | 类型                          | 必填 | 说明                   |
3616| -------- | ----------------------------- | ---- | ---------------------- |
3617| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3618| type     | [SlotType](#slottype)         | 是   | 渠道类型。         |
3619| callback | AsyncCallback\<boolean\>         | 是   | 获取渠道使能状态回调函数。 |
3620
3621**错误码:**
3622
3623错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3624
3625| 错误码ID | 错误信息                                 |
3626| -------- | ---------------------------------------- |
3627| 1600001  | Internal error.                          |
3628| 1600002  | Marshalling or unmarshalling error.      |
3629| 1600003  | Failed to connect service.               |
3630| 17700001 | The specified bundle name was not found. |
3631
3632**示例:**
3633
3634```js
3635// isNotificationSlotEnabled
3636function getEnableSlotCallback(err, data) {
3637    if (err) {
3638        console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
3639    } else {
3640        console.info("isNotificationSlotEnabled success");
3641    }
3642};
3643
3644Notification.isNotificationSlotEnabled(
3645    { bundle: "ohos.samples.notification", },
3646    Notification.SlotType.SOCIAL_COMMUNICATION,
3647    getEnableSlotCallback);
3648```
3649
3650## Notification.isNotificationSlotEnabled
3651
3652isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
3653
3654获取指定应用的指定渠道类型的使能状态(Promise形式)。
3655
3656**系统能力**:SystemCapability.Notification.Notification
3657
3658**系统API**:此接口为系统接口,三方应用不支持调用。
3659
3660**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3661
3662**参数:**
3663
3664| 参数名 | 类型                          | 必填 | 说明           |
3665| ------ | ----------------------------- | ---- | -------------- |
3666| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。   |
3667| type   | [SlotType](#slottype)         | 是   | 渠道类型。 |
3668
3669**返回值:**
3670
3671| 类型                                                        | 说明                                                         |
3672| ----------------------------------------------------------- | ------------------------------------------------------------ |
3673| Promise\<boolean\> | 以Promise形式返回指定类型的渠道使能状态。 |
3674
3675**错误码:**
3676
3677错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3678
3679| 错误码ID | 错误信息                                 |
3680| -------- | ---------------------------------------- |
3681| 1600001  | Internal error.                          |
3682| 1600002  | Marshalling or unmarshalling error.      |
3683| 1600003  | Failed to connect service.               |
3684| 17700001 | The specified bundle name was not found. |
3685
3686**示例:**
3687
3688```js
3689// isNotificationSlotEnabled
3690Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
3691    Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
3692    console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
3693});
3694```
3695
3696
3697## Notification.setSyncNotificationEnabledWithoutApp
3698
3699setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
3700
3701设置是否将通知同步到未安装应用程序的设备(callback形式)。
3702
3703**系统能力**:SystemCapability.Notification.Notification
3704
3705**系统API**:此接口为系统接口,三方应用不支持调用。
3706
3707**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3708
3709**参数:**
3710
3711| 参数名 | 类型                          | 必填 | 说明           |
3712| ------ | ----------------------------- | ---- | -------------- |
3713| userId | number | 是   | 用户ID。   |
3714| enable | boolean | 是   | 是否启用。   |
3715| callback | AsyncCallback\<void\>    | 是   | 设置是否将通知同步到未安装应用程序的设备的回调函数。 |
3716
3717**错误码:**
3718
3719错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3720
3721| 错误码ID | 错误信息                            |
3722| -------- | ----------------------------------- |
3723| 1600001  | Internal error.                     |
3724| 1600002  | Marshalling or unmarshalling error. |
3725| 1600003  | Failed to connect service.          |
3726| 1600008  | The user is not exist.              |
3727
3728**示例:**
3729
3730```js
3731let userId = 100;
3732let enable = true;
3733
3734function callback(err) {
3735    if (err) {
3736        console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
3737    } else {
3738        console.info("setSyncNotificationEnabledWithoutApp success");
3739    }
3740}
3741
3742Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
3743```
3744
3745
3746## Notification.setSyncNotificationEnabledWithoutApp
3747
3748setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
3749
3750设置是否将通知同步到未安装应用程序的设备(Promise形式)。
3751
3752**系统能力**:SystemCapability.Notification.Notification
3753
3754**系统API**:此接口为系统接口,三方应用不支持调用。
3755
3756**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3757
3758**参数:**
3759
3760| 参数名 | 类型                          | 必填 | 说明           |
3761| ------ | ----------------------------- | ---- | -------------- |
3762| userId | number | 是   | 用户ID。   |
3763| enable | boolean | 是   | 是否启用。   |
3764
3765**返回值:**
3766
3767| 类型                                                        | 说明                                                         |
3768| ----------------------------------------------------------- | ------------------------------------------------------------ |
3769| Promise\<void\> | 以Promise形式返回设置是否将通知同步到未安装应用程序的设备的结果。 |
3770
3771**错误码:**
3772
3773错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3774
3775| 错误码ID | 错误信息                            |
3776| -------- | ----------------------------------- |
3777| 1600001  | Internal error.                     |
3778| 1600002  | Marshalling or unmarshalling error. |
3779| 1600003  | Failed to connect service.          |
3780| 1600008  | The user is not exist.              |
3781
3782**示例:**
3783
3784```js
3785let userId = 100;
3786let enable = true;
3787
3788Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
3789    console.info('setSyncNotificationEnabledWithoutApp success');
3790}).catch((err) => {
3791    console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
3792});
3793```
3794
3795
3796## Notification.getSyncNotificationEnabledWithoutApp
3797
3798getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
3799
3800获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。
3801
3802**系统能力**:SystemCapability.Notification.Notification
3803
3804**系统API**:此接口为系统接口,三方应用不支持调用。
3805
3806**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3807
3808**参数:**
3809
3810| 参数名 | 类型                          | 必填 | 说明           |
3811| ------ | ----------------------------- | ---- | -------------- |
3812| userId | number | 是   | 用户ID。   |
3813| callback | AsyncCallback\<boolean\>         | 是   | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数。 |
3814
3815**错误码:**
3816
3817错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3818
3819| 错误码ID | 错误信息                            |
3820| -------- | ----------------------------------- |
3821| 1600001  | Internal error.                     |
3822| 1600002  | Marshalling or unmarshalling error. |
3823| 1600003  | Failed to connect service.          |
3824| 1600008  | The user is not exist.              |
3825
3826**示例:**
3827
3828```js
3829let userId = 100;
3830
3831function getSyncNotificationEnabledWithoutAppCallback(err, data) {
3832    if (err) {
3833        console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
3834    } else {
3835        console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
3836    }
3837}
3838
3839Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
3840```
3841
3842
3843## Notification.getSyncNotificationEnabledWithoutApp
3844
3845getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
3846
3847获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。
3848
3849**系统能力**:SystemCapability.Notification.Notification
3850
3851**系统API**:此接口为系统接口,三方应用不支持调用。
3852
3853**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3854
3855**参数:**
3856
3857| 参数名 | 类型                          | 必填 | 说明           |
3858| ------ | ----------------------------- | ---- | -------------- |
3859| userId | number | 是   | 用户ID。   |
3860
3861**返回值:**
3862
3863| 类型               | 说明                                                         |
3864| ------------------ | ------------------------------------------------------------ |
3865| Promise\<boolean\> | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果。 |
3866
3867**错误码:**
3868
3869错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。
3870
3871| 错误码ID | 错误信息                            |
3872| -------- | ----------------------------------- |
3873| 1600001  | Internal error.                     |
3874| 1600002  | Marshalling or unmarshalling error. |
3875| 1600003  | Failed to connect service.          |
3876| 1600008  | The user is not exist.              |
3877
3878**示例:**
3879
3880```js
3881let userId = 100;
3882Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
3883    console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
3884}).catch((err) => {
3885    console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
3886});
3887    .catch((err) => {
3888        console.info('getSyncNotificationEnabledWithoutApp, err:', err);
3889    });
3890```
3891
3892
3893
3894
3895## DoNotDisturbDate
3896
3897**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
3898
3899**系统API**:此接口为系统接口,三方应用不支持调用。
3900
3901| 名称  | 类型                                  | 可读 | 可写 | 说明                   |
3902| ----- | ------------------------------------- | ---- | ---- | ---------------------- |
3903| type  | [DoNotDisturbType](#donotdisturbtype) | 是   | 是   | 免打扰设置的时间类型。 |
3904| begin | Date                                  | 是   | 是   | 免打扰设置的起点时间。 |
3905| end   | Date                                  | 是   | 是   | 免打扰设置的终点时间。 |
3906
3907
3908
3909## DoNotDisturbType
3910
3911**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
3912
3913**系统API**: 此接口为系统接口,三方应用不支持调用。
3914
3915| 名称         | 值               | 说明                                       |
3916| ------------ | ---------------- | ------------------------------------------ |
3917| TYPE_NONE    | 0 | 非通知勿扰类型。                           |
3918| TYPE_ONCE    | 1 | 以设置时间段(只看小时和分钟)一次执行勿扰。 |
3919| TYPE_DAILY   | 2 | 以设置时间段(只看小时和分钟)每天执行勿扰。 |
3920| TYPE_CLEARLY | 3 | 以设置时间段(明确年月日时分)执行勿扰。     |
3921
3922
3923## ContentType
3924
3925**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
3926
3927| 名称                              | 值          | 说明               |
3928| --------------------------------- | ----------- | ------------------ |
3929| NOTIFICATION_CONTENT_BASIC_TEXT   | NOTIFICATION_CONTENT_BASIC_TEXT | 普通类型通知。     |
3930| NOTIFICATION_CONTENT_LONG_TEXT    | NOTIFICATION_CONTENT_LONG_TEXT | 长文本类型通知。   |
3931| NOTIFICATION_CONTENT_PICTURE      | NOTIFICATION_CONTENT_PICTURE | 图片类型通知。     |
3932| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | 社交类型通知。     |
3933| NOTIFICATION_CONTENT_MULTILINE    | NOTIFICATION_CONTENT_MULTILINE | 多行文本类型通知。 |
3934
3935## SlotLevel
3936
3937**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
3938
3939| 名称                              | 值          | 说明               |
3940| --------------------------------- | ----------- | ------------------ |
3941| LEVEL_NONE                        | 0           | 表示关闭通知功能。     |
3942| LEVEL_MIN                         | 1           | 表示通知功能已启用,但状态栏中不显示通知图标,且没有横幅或提示音。 |
3943| LEVEL_LOW                         | 2           | 表示通知功能已启用,且状态栏中显示通知图标,但没有横幅或提示音。 |
3944| LEVEL_DEFAULT                     | 3           | 表示通知功能已启用,状态栏中显示通知图标,没有横幅但有提示音。 |
3945| LEVEL_HIGH                        | 4           | 表示通知功能已启用,状态栏中显示通知图标,有横幅和提示音。 |
3946
3947
3948## SlotType
3949
3950**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
3951
3952| 名称                 | 值       | 说明       |
3953| -------------------- | -------- | ---------- |
3954| UNKNOWN_TYPE         | 0 | 未知类型。 |
3955| SOCIAL_COMMUNICATION | 1 | 社交类型。 |
3956| SERVICE_INFORMATION  | 2 | 服务类型。 |
3957| CONTENT_INFORMATION  | 3 | 内容类型。 |
3958| OTHER_TYPES          | 0xFFFF | 其他类型。 |
3959
3960
3961
3962
3963## DeviceRemindType
3964
3965**系统能力**:SystemCapability.Notification.Notification
3966
3967**系统API**: 此接口为系统接口,三方应用不支持调用。
3968
3969| 名称                 | 值  | 说明                               |
3970| -------------------- | --- | --------------------------------- |
3971| IDLE_DONOT_REMIND    | 0   | 设备未被使用,无需提醒。            |
3972| IDLE_REMIND          | 1   | 提醒设备未被使用。                 |
3973| ACTIVE_DONOT_REMIND  | 2   | 设备正在使用,无需提醒。            |
3974| ACTIVE_REMIND        | 3   | 提醒设备正在使用。                 |
3975
3976
3977## SourceType
3978
3979**系统能力**:SystemCapability.Notification.Notification
3980
3981**系统API**: 此接口为系统接口,三方应用不支持调用。
3982
3983| 名称                 | 值  | 说明                  |
3984| -------------------- | --- | -------------------- |
3985| TYPE_NORMAL          | 0   | 一般通知。            |
3986| TYPE_CONTINUOUS      | 1   | 连续通知。            |
3987| TYPE_TIMER           | 2   | 计划通知。            |
3988