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