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