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