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