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