• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Notification
2
3> **NOTE**<br>
4> 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.
5
6## Modules to Import
7
8```js
9import Notification from '@ohos.notification';
10```
11
12## Notification.publish
13
14publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
15
16Publishes a notification. This API uses an asynchronous callback to return the result.
17
18**System capability**: SystemCapability.Notification.Notification
19
20**Parameters**
21
22| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
23| -------- | ---- | ---- | ------------------------------------------- | ---- | ------------------------------------------- |
24| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
25| callback | Yes  | No  |AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                           |
26
27**Example**
28
29```js
30// publish callback
31function publishCallback(err) {
32	console.info("==========================>publishCallback=======================>");
33}
34// NotificationRequest object
35var notificationRequest = {
36    id: 1,
37    content: {
38        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
39        normal: {
40            title: "test_title",
41            text: "test_text",
42            additionalText: "test_additionalText"
43        }
44    }
45}
46Notification.publish(notificationRequest, publishCallback)
47```
48
49
50
51## Notification.publish
52
53publish(request: NotificationRequest): Promise\<void\>
54
55Publishes a notification. This API uses a promise to return the result.
56
57**System capability**: SystemCapability.Notification.Notification
58
59**Example**
60
61```js
62// NotificationRequest object
63var notificationRequest = {
64    notificationId: 1,
65    content: {
66        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
67        normal: {
68            title: "test_title",
69            text: "test_text",
70            additionalText: "test_additionalText"
71        }
72    }
73}
74Notification.publish(notificationRequest).then(() => {
75	console.info("==========================>publishCallback=======================>");
76});
77
78```
79
80## Notification.publish<sup>8+</sup>
81
82publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
83
84Publishes a notification. This API uses an asynchronous callback to return the result.
85
86**System capability**: SystemCapability.Notification.Notification
87
88**Parameters**
89
90| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
91| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
92| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
93| userId   | Yes  | No  |number                                      | Yes  | ID of the user who receives the notification.                          |
94| callback | Yes  | No  |AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |
95
96**Example**
97
98```js
99// publish callback
100function publishCallback(err) {
101	console.info("==========================>publishCallback=======================>");
102}
103// ID of the user who receives the notification.
104var userId = 1
105// NotificationRequest object
106var notificationRequest = {
107    id: 1,
108    content: {
109        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
110        normal: {
111            title: "test_title",
112            text: "test_text",
113            additionalText: "test_additionalText"
114        }
115    }
116}
117Notification.publish(notificationRequest, userId, publishCallback);
118```
119
120## Notification.publish<sup>8+</sup>
121
122publish(request: NotificationRequest, userId: number): Promise\<void\>
123
124Publishes a notification. This API uses a promise to return the result.
125
126**System capability**: SystemCapability.Notification.Notification
127
128**Parameters**
129
130| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
131| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
132| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
133| userId   | Yes  | No  |number                                      | Yes  | ID of the user who receives the notification.                          |
134
135**Example**
136
137```js
138var notificationRequest = {
139    notificationId: 1,
140    content: {
141        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
142        normal: {
143            title: "test_title",
144            text: "test_text",
145            additionalText: "test_additionalText"
146        }
147    }
148}
149
150var userId = 1
151
152Notification.publish(notificationRequest, userId).then(() => {
153	console.info("==========================>publishCallback=======================>");
154});
155```
156
157
158## Notification.cancel
159
160cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
161
162Cancels a notification with the specified ID and label. This API uses an asynchronous callback to return the result.
163
164**System capability**: SystemCapability.Notification.Notification
165
166**Parameters**
167
168| Name    | Readable| Writable| Type                 | Mandatory| Description                |
169| -------- | --- | ---- | --------------------- | ---- | -------------------- |
170| id       | Yes  | No  | number                | Yes  | Notification ID.              |
171| label    | Yes  | No  | string                | Yes  | Notification label.            |
172| callback | Yes  | No  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
173
174**Example**
175
176```js
177// cancel callback
178function cancelCallback(err) {
179	console.info("==========================>cancelCallback=======================>");
180}
181Notification.cancel(0, "label", cancelCallback)
182```
183
184
185
186## Notification.cancel
187
188cancel(id: number, label?: string): Promise\<void\>
189
190Cancels a notification with the specified ID and label. This API uses a promise to return the result.
191
192**System capability**: SystemCapability.Notification.Notification
193
194**Parameters**
195
196| Name | Readable| Writable| Type  | Mandatory| Description    |
197| ----- | --- | ---- | ------ | ---- | -------- |
198| id    | Yes  | No  | number | Yes  | Notification ID.  |
199| label | Yes  | No  | string | No  | Notification label.|
200
201**Example**
202
203```js
204Notification.cancel(0).then(() => {
205	console.info("==========================>cancelCallback=======================>");
206});
207```
208
209
210
211## Notification.cancel
212
213cancel(id: number, callback: AsyncCallback\<void\>): void
214
215Cancels a notification with the specified ID. This API uses an asynchronous callback to return the result.
216
217**System capability**: SystemCapability.Notification.Notification
218
219**Parameters**
220
221| Name    | Readable| Writable| Type                 | Mandatory| Description                |
222| -------- | ---- | --- | --------------------- | ---- | -------------------- |
223| id       | Yes  | No | number                | Yes  | Notification ID.              |
224| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
225
226**Example**
227
228```js
229// cancel callback
230function cancelCallback(err) {
231	console.info("==========================>cancelCallback=======================>");
232}
233Notification.cancel(0, cancelCallback)
234```
235
236
237
238## Notification.cancelAll
239
240cancelAll(callback: AsyncCallback\<void\>): void
241
242Cancels all notifications. This API uses an asynchronous callback to return the result.
243
244**System capability**: SystemCapability.Notification.Notification
245
246**Parameters**
247
248| Name    | Readable| Writable| Type                 | Mandatory| Description                |
249| -------- | ---- | --- | --------------------- | ---- | -------------------- |
250| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
251
252**Example**
253
254```js
255// cancel callback
256function cancelAllCallback(err) {
257	console.info("==========================>cancelAllCallback=======================>");
258}
259Notification.cancelAll(cancelAllCallback)
260```
261
262
263
264## Notification.cancelAll
265
266cancelAll(): Promise\<void\>
267
268Cancels all notifications. This API uses a promise to return the result.
269
270**System capability**: SystemCapability.Notification.Notification
271
272**Example**
273
274```js
275Notification.cancelAll().then(() => {
276	console.info("==========================>cancelAllCallback=======================>");
277});
278```
279
280
281
282## Notification.addSlot
283
284addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
285
286Adds a notification slot. This API uses an asynchronous callback to return the result.
287
288**System capability**: SystemCapability.Notification.Notification
289
290**Parameters**
291
292| Name    | Readable| Writable| Type                 | Mandatory| Description                |
293| -------- | ---- | --- | --------------------- | ---- | -------------------- |
294| slot     | Yes  | No | [NotificationSlot](#notificationslot)       | Yes  | Notification slot to add.|
295| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
296
297**Example**
298
299```js
300// addSlot callback
301function addSlotCallBack(err) {
302	console.info("==========================>addSlotCallBack=======================>");
303}
304// NotificationSlot object
305var notificationSlot = {
306    type: Notification.SlotType.SOCIAL_COMMUNICATION
307}
308Notification.addSlot(notificationSlot, addSlotCallBack)
309```
310
311
312
313## Notification.addSlot
314
315addSlot(slot: NotificationSlot): Promise\<void\>
316
317Adds a notification slot. This API uses a promise to return the result.
318
319**System capability**: SystemCapability.Notification.Notification
320
321**Parameters**
322
323| Name| Readable| Writable| Type            | Mandatory| Description                |
324| ---- | ---- | --- | ---------------- | ---- | -------------------- |
325| slot | Yes  | No | [NotificationSlot](#notificationslot) | Yes  | Notification slot to add.|
326
327**Example**
328
329```js
330// NotificationSlot object
331var notificationSlot = {
332    type: Notification.SlotType.SOCIAL_COMMUNICATION
333}
334Notification.addSlot(notificationSlot).then(() => {
335	console.info("==========================>addSlotCallback=======================>");
336});
337```
338
339
340
341## Notification.addSlot
342
343addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
344
345Adds a notification slot. This API uses an asynchronous callback to return the result.
346
347**System capability**: SystemCapability.Notification.Notification
348
349**Parameters**
350
351| Name    | Readable| Writable| Type                 | Mandatory| Description                  |
352| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
353| type     | Yes  | No | [SlotType](#slottype)              | Yes  | Type of the notification slot to add.|
354| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.  |
355
356**Example**
357
358```js
359// addSlot callback
360function addSlotCallBack(err) {
361	console.info("==========================>addSlotCallBack=======================>");
362}
363Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack)
364```
365
366
367
368## Notification.addSlot
369
370addSlot(type: SlotType): Promise\<void\>
371
372Adds a notification slot. This API uses a promise to return the result.
373
374**System capability**: SystemCapability.Notification.Notification
375
376**Parameters**
377
378| Name| Readable| Writable| Type    | Mandatory| Description                  |
379| ---- | ---- | --- | -------- | ---- | ---------------------- |
380| type | Yes  | No | [SlotType](#slottype) | Yes  | Type of the notification slot to add.|
381
382**Example**
383
384```js
385Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
386	console.info("==========================>addSlotCallback=======================>");
387});
388```
389
390
391
392## Notification.addSlots
393
394addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
395
396Adds multiple notification slots. This API uses an asynchronous callback to return the result.
397
398**System capability**: SystemCapability.Notification.Notification
399
400**Parameters**
401
402| Name    | Readable| Writable| Type                     | Mandatory| Description                    |
403| -------- | ---- | --- | ------------------------- | ---- | ------------------------ |
404| slots    | Yes  | No | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
405| callback | Yes  | No | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |
406
407**Example**
408
409```js
410// addSlots callback
411function addSlotsCallBack(err) {
412	console.info("==========================>addSlotsCallBack=======================>");
413}
414// NotificationSlot object
415var notificationSlot = {
416    type: Notification.SlotType.SOCIAL_COMMUNICATION
417}
418// NotificationSlotArray object
419var notificationSlotArray = new Array();
420notificationSlotArray[0] = notificationSlot;
421
422Notification.addSlots(notificationSlotArray, addSlotsCallBack)
423```
424
425
426
427## Notification.addSlots
428
429addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
430
431Adds multiple notification slots. This API uses a promise to return the result.
432
433**System capability**: SystemCapability.Notification.Notification
434
435**Parameters**
436
437| Name | Readable| Writable| Type                     | Mandatory| Description                    |
438| ----- | ---- | --- | ------------------------- | ---- | ------------------------ |
439| slots | Yes  | No | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
440
441**Example**
442
443```js
444// NotificationSlot object
445var notificationSlot = {
446    type: Notification.SlotType.SOCIAL_COMMUNICATION
447}
448// NotificationSlotArray object
449var notificationSlotArray = new Array();
450notificationSlotArray[0] = notificationSlot;
451
452Notification.addSlots(notificationSlotArray).then(() => {
453	console.info("==========================>addSlotCallback=======================>");
454});
455```
456
457
458
459## Notification.getSlot
460
461getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
462
463Obtains a notification slot of the specified type. This API uses an asynchronous callback to return the result.
464
465**System capability**: SystemCapability.Notification.Notification
466
467**Parameters**
468
469| Name    | Readable| Writable| Type                             | Mandatory| Description                                                       |
470| -------- | ---- | --- | --------------------------------- | ---- | ----------------------------------------------------------- |
471| slotType | Yes  | No | [SlotType](#slottype)                          | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
472| callback | Yes  | No | AsyncCallback\<[NotificationSlot](#notificationslot)\> | Yes  | Callback used to return the result.                                       |
473
474**Example**
475
476```js
477// getSlot callback
478function getSlotCallback(err,data) {
479	console.info("==========================>getSlotCallback=======================>");
480}
481var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
482Notification.getSlot(slotType, getSlotCallback)
483```
484
485
486
487## Notification.getSlot
488
489getSlot(slotType: SlotType): Promise\<NotificationSlot\>
490
491Obtains a notification slot of the specified type. This API uses a promise to return the result.
492
493**System capability**: SystemCapability.Notification.Notification
494
495**Parameters**
496
497| Name    | Readable| Writable| Type    | Mandatory| Description                                                       |
498| -------- | ---- | --- | -------- | ---- | ----------------------------------------------------------- |
499| slotType | Yes  | No | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
500
501**Return value**
502
503| Type                                                       | Description                                                        |
504| ----------------------------------------------------------- | ------------------------------------------------------------ |
505| Promise\<NotificationSlot\> | Promise used to return the result.|
506
507**Example**
508
509```js
510var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
511Notification.getSlot(slotType).then((data) => {
512	console.info("==========================>getSlotCallback=======================>");
513});
514```
515
516
517
518## Notification.getSlots
519
520getSlots(callback: AsyncCallback\<Array\<NotificationSlot\>>): void
521
522Obtains all notification slots. This API uses an asynchronous callback to return the result.
523
524**System capability**: SystemCapability.Notification.Notification
525
526**Parameters**
527
528| Name    | Readable| Writable| Type                             | Mandatory| Description                |
529| -------- | ---- | --- | --------------------------------- | ---- | -------------------- |
530| callback | Yes  | No | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | Yes  | Callback used to return the result.|
531
532**Example**
533
534```js
535// getSlots callback
536function getSlotsCallback(err,data) {
537	console.info("==========================>getSlotsCallback=======================>");
538}
539Notification.getSlots(getSlotsCallback)
540```
541
542
543
544## Notification.getSlots
545
546getSlots(): Promise\<Array\<NotificationSlot\>>
547
548Obtains all notification slots of this application. This API uses a promise to return the result.
549
550**System capability**: SystemCapability.Notification.Notification
551
552**Return value**
553
554| Type                                                       | Description                                                        |
555| ----------------------------------------------------------- | ------------------------------------------------------------ |
556| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.|
557
558**Example**
559
560```js
561Notification.getSlots().then((data) => {
562	console.info("==========================>getSlotsCallback=======================>");
563});
564```
565
566
567
568## Notification.removeSlot
569
570removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
571
572Removes a notification slot of the specified type. This API uses an asynchronous callback to return the result.
573
574**System capability**: SystemCapability.Notification.Notification
575
576**Parameters**
577
578| Name    | Readable| Writable| Type                 | Mandatory| Description                                                       |
579| -------- | ---- | --- | --------------------- | ---- | ----------------------------------------------------------- |
580| slotType | Yes  | No | [SlotType](#slottype)              | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
581| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.                                       |
582
583**Example**
584
585```js
586// removeSlot callback
587function removeSlotCallback(err) {
588	console.info("==========================>removeSlotCallback=======================>");
589}
590var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
591Notification.removeSlot(slotType,removeSlotCallback)
592```
593
594
595
596## Notification.removeSlot
597
598removeSlot(slotType: SlotType): Promise\<void\>
599
600Removes a notification slot of the specified type. This API uses a promise to return the result.
601
602**System capability**: SystemCapability.Notification.Notification
603
604**Parameters**
605
606| Name    | Readable| Writable| Type    | Mandatory| Description                                                       |
607| -------- | ---- | --- | -------- | ---- | ----------------------------------------------------------- |
608| slotType | Yes  | No | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
609
610**Example**
611
612```js
613var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
614Notification.removeSlot(slotType).then(() => {
615	console.info("==========================>removeSlotCallback=======================>");
616});
617```
618
619
620
621## Notification.removeAllSlots
622
623removeAllSlots(callback: AsyncCallback\<void\>): void
624
625Removes all notification slots. This API uses an asynchronous callback to return the result.
626
627**System capability**: SystemCapability.Notification.Notification
628
629**Parameters**
630
631| Name    | Readable| Writable| Type                 | Mandatory| Description                |
632| -------- | ---- | --- | --------------------- | ---- | -------------------- |
633| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
634
635**Example**
636
637```js
638function removeAllCallBack(err) {
639	console.info("================>removeAllCallBack=======================>");
640}
641Notification.removeAllSlots(removeAllCallBack)
642```
643
644
645
646## Notification.removeAllSlots
647
648removeAllSlots(): Promise\<void\>
649
650Removes all notification slots. This API uses a promise to return the result.
651
652**System capability**: SystemCapability.Notification.Notification
653
654**Example**
655
656```js
657Notification.removeAllSlots().then(() => {
658	console.info("==========================>removeAllCallBack=======================>");
659});
660```
661
662
663
664## Notification.subscribe
665
666subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\<void\>): void
667
668Subscribes to a notification with the subscription information specified. This API uses an asynchronous callback to return the result.
669
670**System capability**: SystemCapability.Notification.Notification
671
672**Parameters**
673
674| Name      | Readable| Writable| Type                     | Mandatory| Description            |
675| ---------- | ---- | --- | ------------------------- | ---- | ---------------- |
676| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.    |
677| info       | Yes  | No | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes  | Subscription information.        |
678| callback   | Yes  | No | AsyncCallback\<void\>     | Yes  | Callback used to return the result.|
679
680**Example**
681
682```js
683// subscribe callback
684function subscribeCallback(err) {
685	console.info("==========================>subscribeCallback=======================>");
686}
687function onConsumeCallback(err, data) {
688	console.info("==========================>onConsumeCallback=======================>");
689}
690var subscriber = {
691    onConsume: onConsumeCallback
692}
693var info = {
694    bundleNames: ["bundleName1","bundleName2"]
695}
696Notification.subscribe(subscriber, info, subscribeCallback);
697```
698
699
700
701## Notification.subscribe
702
703subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
704
705Subscribes to a notification with the subscription information specified. This API uses an asynchronous callback to return the result.
706
707**System capability**: SystemCapability.Notification.Notification
708
709**Parameters**
710
711| Name      | Readable| Writable| Type                  | Mandatory| Description            |
712| ---------- | ---- | --- | ---------------------- | ---- | ---------------- |
713| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.    |
714| callback   | Yes  | No | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
715
716**Example**
717
718```js
719function subscribeCallback(err) {
720	console.info("==========================>subscribeCallback=======================>");
721}
722function onConsumeCallback(err, data) {
723	console.info("==========================>onConsumeCallback=======================>");
724}
725var subscriber = {
726    onConsume: onConsumeCallback
727}
728Notification.subscribe(subscriber, subscribeCallback);
729```
730
731
732
733## Notification.subscribe
734
735subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise\<void\>
736
737Subscribes to a notification with the subscription information specified. This API uses a promise to return the result.
738
739**System capability**: SystemCapability.Notification.Notification
740
741**Parameters**
742
743| Name      | Readable| Writable| Type                     | Mandatory| Description        |
744| ---------- | ---- | --- | ------------------------- | ---- | ------------ |
745| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.|
746| info       | Yes  | No | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No  | Subscription information.    |
747
748**Example**
749
750```js
751function onConsumeCallback(err, data) {
752	console.info("==========================>onConsumeCallback=======================>");
753}
754var subscriber = {
755    onConsume: onConsumeCallback
756};
757Notification.subscribe(subscriber).then(() => {
758	console.info("==========================>subscribeCallback=======================>");
759});
760```
761
762
763
764## Notification.unsubscribe
765
766unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
767
768Unsubscribes from a notification. This API uses an asynchronous callback to return the result.
769
770**System capability**: SystemCapability.Notification.Notification
771
772**Parameters**
773
774| Name      | Readable| Writable| Type                  | Mandatory| Description                |
775| ---------- | ---- | --- | ---------------------- | ---- | -------------------- |
776| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.        |
777| callback   | Yes  | No | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
778
779**Example**
780
781```js
782function unsubscribeCallback(err) {
783	console.info("==========================>unsubscribeCallback=======================>");
784}
785function onConsumeCallback(err, data) {
786	console.info("==========================>onConsumeCallback=======================>");
787}
788var subscriber = {
789    onConsume: onConsumeCallback
790}
791Notification.unsubscribe(subscriber, unsubscribeCallback);
792```
793
794
795
796## Notification.unsubscribe
797
798unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
799
800Unsubscribes from a notification. This API uses a promise to return the result.
801
802**System capability**: SystemCapability.Notification.Notification
803
804**Parameters**
805
806| Name      | Readable| Writable| Type                  | Mandatory| Description        |
807| ---------- | ---- | --- | ---------------------- | ---- | ------------ |
808| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
809
810**Example**
811
812```js
813function onConsumeCallback(err, data) {
814	console.info("==========================>onConsumeCallback=======================>");
815}
816var subscriber = {
817    onConsume: onConsumeCallback
818};
819Notification.unsubscribe(subscriber).then(() => {
820	console.info("==========================>unsubscribeCallback=======================>");
821});
822```
823
824
825
826## Notification.enableNotification
827
828enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
829
830Sets whether to enable notification for a specified bundle. This API uses an asynchronous callback to return the result.
831
832**System capability**: SystemCapability.Notification.Notification
833
834**Parameters**
835
836| Name    | Readable| Writable| Type                 | Mandatory| Description                |
837| -------- | ---- | --- | --------------------- | ---- | -------------------- |
838| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
839| enable   | Yes  | No | boolean               | Yes  | Whether to enable notification.            |
840| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
841
842**Example**
843
844```js
845function enableNotificationCallback(err) {
846	console.info("==========================>enableNotificationCallback=======================>");
847}
848var bundle = {
849    bundle: "bundleName1",
850}
851Notification.enableNotification(bundle, false, enableNotificationCallback);
852```
853
854
855
856## Notification.enableNotification
857
858enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\>
859
860Sets whether to enable notification for a specified bundle. This API uses a promise to return the result.
861
862**System capability**: SystemCapability.Notification.Notification
863
864**Parameters**
865
866| Name  | Readable| Writable| Type        | Mandatory| Description      |
867| ------ | ---- | --- | ------------ | ---- | ---------- |
868| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
869| enable | Yes  | No | boolean      | Yes  | Whether to enable notification.  |
870
871**Example**
872
873```js
874var bundle = {
875    bundle: "bundleName1",
876}
877Notification.enableNotification(bundle, false).then(() => {
878	console.info("==========================>enableNotificationCallback=======================>");
879});
880```
881
882
883
884## Notification.isNotificationEnabled
885
886isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
887
888Checks whether notification is enabled for a specified bundle. This API uses an asynchronous callback to return the result.
889
890**System capability**: SystemCapability.Notification.Notification
891
892**Parameters**
893
894| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
895| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
896| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.              |
897| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
898
899**Example**
900
901```js
902function isNotificationEnabledCallback(err, data) {
903	console.info("==========================>isNotificationEnabledCallback=======================>");
904}
905var bundle = {
906    bundle: "bundleName1",
907}
908Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
909```
910
911
912
913## Notification.isNotificationEnabled
914
915isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
916
917Checks whether notification is enabled for a specified bundle. This API uses a promise to return the result.
918
919**System capability**: SystemCapability.Notification.Notification
920
921**Parameters**
922
923| Name  | Readable| Writable| Type        | Mandatory| Description      |
924| ------ | ---- | --- | ------------ | ---- | ---------- |
925| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
926
927**Return value**
928
929| Type                                                       | Description                                                        |
930| ----------------------------------------------------------- | ------------------------------------------------------------ |
931| Promise\<boolean\> | Promise used to return the result.|
932
933**Example**
934
935```js
936var bundle = {
937    bundle: "bundleName1",
938}
939Notification.isNotificationEnabled(bundle).then((data) => {
940	console.info("==========================>isNotificationEnabledCallback=======================>");
941});
942```
943
944
945
946## Notification.isNotificationEnabled
947
948isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
949
950Checks whether notification is enabled for this application. This API uses an asynchronous callback to return the result.
951
952**System capability**: SystemCapability.Notification.Notification
953
954**Parameters**
955
956| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
957| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
958| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
959
960**Example**
961
962```js
963function isNotificationEnabledCallback(err, data) {
964	console.info("==========================>isNotificationEnabledCallback=======================>");
965}
966
967Notification.isNotificationEnabled(isNotificationEnabledCallback);
968```
969
970
971
972## Notification.isNotificationEnabled
973
974isNotificationEnabled(): Promise\<boolean\>
975
976Checks whether notification is enabled for this application. This API uses a promise to return the result.
977
978**System capability**: SystemCapability.Notification.Notification
979
980**Parameters**
981
982| Name  | Readable| Writable| Type        | Mandatory| Description      |
983| ------ | ---- | --- | ------------ | ---- | ---------- |
984| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
985
986**Return value**
987
988| Type                                                       | Description                                                        |
989| ----------------------------------------------------------- | ------------------------------------------------------------ |
990| Promise\<boolean\> | Promise used to return the result.|
991
992**Example**
993
994```js
995Notification.isNotificationEnabled().then((data) => {
996	console.info("==========================>isNotificationEnabledCallback=======================>");
997});
998```
999
1000
1001
1002## Notification.displayBadge
1003
1004displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
1005
1006Sets whether to enable the notification badge for a specified bundle. This API uses an asynchronous callback to return the result.
1007
1008**System capability**: SystemCapability.Notification.Notification
1009
1010**Parameters**
1011
1012| Name    | Readable| Writable| Type                 | Mandatory| Description                |
1013| -------- | ---- | --- | --------------------- | ---- | -------------------- |
1014| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
1015| enable   | Yes  | No | boolean               | Yes  | Whether to enable notification.            |
1016| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1017
1018**Example**
1019
1020```js
1021function displayBadgeCallback(err) {
1022	console.info("==========================>displayBadgeCallback=======================>");
1023}
1024var bundle = {
1025    bundle: "bundleName1",
1026}
1027Notification.displayBadge(bundle, false, displayBadgeCallback);
1028```
1029
1030
1031
1032## Notification.displayBadge
1033
1034displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
1035
1036Sets the notification slot for a specified bundle. This API uses a promise to return the result.
1037
1038**System capability**: SystemCapability.Notification.Notification
1039
1040**Parameters**
1041
1042| Name  | Readable| Writable| Type        | Mandatory| Description      |
1043| ------ | ---- | --- | ------------ | ---- | ---------- |
1044| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
1045| enable | Yes  | No | boolean      | Yes  | Whether to enable notification.  |
1046
1047**Example**
1048
1049```js
1050var bundle = {
1051    bundle: "bundleName1",
1052}
1053Notification.displayBadge(bundle, false).then(() => {
1054	console.info("==========================>displayBadgeCallback=======================>");
1055});
1056```
1057
1058
1059
1060## Notification.isBadgeDisplayed
1061
1062isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
1063
1064Checks whether the notification badge is enabled for a specified bundle. This API uses an asynchronous callback to return the result.
1065
1066**System capability**: SystemCapability.Notification.Notification
1067
1068**Parameters**
1069
1070| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
1071| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
1072| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.              |
1073| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1074
1075**Example**
1076
1077```js
1078function isBadgeDisplayedCallback(err, data) {
1079	console.info("==========================>isBadgeDisplayedCallback=======================>");
1080}
1081var bundle = {
1082    bundle: "bundleName1",
1083}
1084Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
1085```
1086
1087
1088
1089## Notification.isBadgeDisplayed
1090
1091isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
1092
1093Checks whether the notification badge is enabled for a specified bundle. This API uses a promise to return the result.
1094
1095**System capability**: SystemCapability.Notification.Notification
1096
1097**Parameters**
1098
1099| Name  | Readable| Writable| Type        | Mandatory| Description      |
1100| ------ | ---- | --- | ------------ | ---- | ---------- |
1101| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
1102
1103**Return value**
1104
1105| Type                                                       | Description                                                        |
1106| ----------------------------------------------------------- | ------------------------------------------------------------ |
1107| Promise\<boolean\> | Promise used to return the result.|
1108
1109**Example**
1110
1111```js
1112var bundle = {
1113    bundle: "bundleName1",
1114}
1115Notification.isBadgeDisplayed(bundle).then((data) => {
1116	console.info("==========================>isBadgeDisplayedCallback=======================>");
1117});
1118```
1119
1120
1121
1122## Notification.setSlotByBundle
1123
1124setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
1125
1126Sets the notification slot for a specified bundle. This API uses an asynchronous callback to return the result.
1127
1128**System capability**: SystemCapability.Notification.Notification
1129
1130**Parameters**
1131
1132| Name    | Readable| Writable| Type                 | Mandatory| Description                |
1133| -------- | ---- | --- | --------------------- | ---- | -------------------- |
1134| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
1135| slot     | Yes  | No | [NotificationSlot](#notificationslot)      | Yes  | Notification slot.            |
1136| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1137
1138**Example**
1139
1140```js
1141function setSlotByBundleCallback(err) {
1142	console.info("==========================>setSlotByBundleCallback=======================>");
1143}
1144var bundle = {
1145    bundle: "bundleName1",
1146}
1147var notificationSlot = {
1148    type: Notification.SlotType.SOCIAL_COMMUNICATION
1149}
1150Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
1151```
1152
1153
1154
1155## Notification.setSlotByBundle
1156
1157setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
1158
1159Sets the notification slot for a specified bundle. This API uses a promise to return the result.
1160
1161**System capability**: SystemCapability.Notification.Notification
1162
1163**Parameters**
1164
1165| Name  | Readable| Writable| Type        | Mandatory| Description      |
1166| ------ | ---- | --- | ------------ | ---- | ---------- |
1167| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
1168| slot   | Yes  | No | [NotificationSlot](#notificationslot) | Yes  | Whether to enable notification.  |
1169
1170**Example**
1171
1172```js
1173var bundle = {
1174    bundle: "bundleName1",
1175}
1176var notificationSlot = {
1177    type: Notification.SlotType.SOCIAL_COMMUNICATION
1178}
1179Notification.displayBadge(bundle, notificationSlot).then(() => {
1180	console.info("==========================>setSlotByBundleCallback=======================>");
1181});
1182```
1183
1184
1185
1186## Notification.getSlotsByBundle
1187
1188getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
1189
1190Obtains the notification slots of a specified bundle. This API uses an asynchronous callback to return the result.
1191
1192**System capability**: SystemCapability.Notification.Notification
1193
1194**Parameters**
1195
1196| Name    | Readable| Writable| Type                                    | Mandatory| Description                |
1197| -------- | ---- | --- | ---------------------------------------- | ---- | -------------------- |
1198| bundle   | Yes  | No | [BundleOption](#bundleoption)                             | Yes  | Bundle information.          |
1199| callback | Yes  | No | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes  | Callback used to return the result.|
1200
1201**Example**
1202
1203```js
1204function getSlotsByBundleCallback(err, data) {
1205	console.info("==========================>getSlotsByBundleCallback=======================>");
1206}
1207var bundle = {
1208    bundle: "bundleName1",
1209}
1210Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
1211```
1212
1213
1214
1215## Notification.getSlotsByBundle
1216
1217getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
1218
1219Obtains the notification slots of a specified bundle. This API uses a promise to return the result.
1220
1221**System capability**: SystemCapability.Notification.Notification
1222
1223**Parameters**
1224
1225| Name  | Readable| Writable| Type        | Mandatory| Description      |
1226| ------ | ---- | --- | ------------ | ---- | ---------- |
1227| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
1228
1229**Return value**
1230
1231| Type                                                       | Description                                                        |
1232| ----------------------------------------------------------- | ------------------------------------------------------------ |
1233| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|
1234
1235**Example**
1236
1237```js
1238var bundle = {
1239    bundle: "bundleName1",
1240}
1241Notification.getSlotsByBundle(bundle).then((data) => {
1242	console.info("==========================>getSlotsByBundleCallback=======================>");
1243});
1244```
1245
1246
1247
1248## Notification.getSlotNumByBundle
1249
1250getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
1251
1252Obtains the number of notification slots of a specified bundle. This API uses an asynchronous callback to return the result.
1253
1254**System capability**: SystemCapability.Notification.Notification
1255
1256**Parameters**
1257
1258| Name    | Readable| Writable| Type                     | Mandatory| Description                  |
1259| -------- | ---- | --- | ------------------------- | ---- | ---------------------- |
1260| bundle   | Yes  | No | [BundleOption](#bundleoption)              | Yes  | Bundle information.            |
1261| callback | Yes  | No | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
1262
1263**Example**
1264
1265```js
1266function getSlotNumByBundle(err, data) {
1267	console.info("==========================>getSlotNumByBundleCallback=======================>");
1268}
1269var bundle = {
1270    bundle: "bundleName1",
1271}
1272Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
1273```
1274
1275
1276
1277## Notification.getSlotNumByBundle
1278
1279getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
1280
1281Obtains the number of notification slots of a specified bundle. This API uses a promise to return the result.
1282
1283**System capability**: SystemCapability.Notification.Notification
1284
1285**Parameters**
1286
1287| Name  | Readable| Writable| Type        | Mandatory| Description      |
1288| ------ | ---- | --- | ------------ | ---- | ---------- |
1289| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
1290
1291**Return value**
1292
1293| Type                                                       | Description                                                        |
1294| ----------------------------------------------------------- | ------------------------------------------------------------ |
1295| Promise\<number\> | Promise used to return the result.|
1296
1297**Example**
1298
1299```js
1300var bundle = {
1301    bundle: "bundleName1",
1302}
1303Notification.getSlotNumByBundle(bundle).then((data) => {
1304	console.info("==========================>getSlotNumByBundleCallback=======================>");
1305});
1306```
1307
1308
1309
1310## Notification.remove
1311
1312remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback\<void\>): void
1313
1314Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result.
1315
1316**System capability**: SystemCapability.Notification.Notification
1317
1318**Parameters**
1319
1320| Name           | Readable| Writable| Type                               | Mandatory| Description                |
1321| --------------- | ---- | --- | ----------------------------------- | ---- | -------------------- |
1322| bundle          | Yes  | No | [BundleOption](#bundleoption)       | Yes  | Bundle information.          |
1323| notificationKey | Yes  | No | [NotificationKey](#notificationkey) | Yes  | Notification key.            |
1324| callback        | Yes  | No | AsyncCallback\<void\>               | Yes  | Callback used to return the result.|
1325
1326**Example**
1327
1328```js
1329function removeCallback(err) {
1330	console.info("==========================>removeCallback=======================>");
1331}
1332var bundle = {
1333    bundle: "bundleName1",
1334}
1335var notificationKey = {
1336    id: 0,
1337    label: "label",
1338}
1339Notification.remove(bundle, notificationKey, removeCallback);
1340```
1341
1342
1343
1344## Notification.remove
1345
1346remove(bundle: BundleOption, notificationKey: NotificationKey): Promise\<void\>
1347
1348Removes a notification for a specified bundle. This API uses a promise to return the result.
1349
1350**System capability**: SystemCapability.Notification.Notification
1351
1352**Parameters**
1353
1354| Name           | Readable| Writable| Type           | Mandatory| Description      |
1355| --------------- | ---- | --- | --------------- | ---- | ---------- |
1356| bundle          | Yes  | No | [BundleOption](#bundleoption)    | Yes  | Bundle information.|
1357| notificationKey | Yes  | No | [NotificationKey](#notificationkey) | Yes  | Notification key.  |
1358
1359**Example**
1360
1361```js
1362var bundle = {
1363    bundle: "bundleName1",
1364}
1365var notificationKey = {
1366    id: 0,
1367    label: "label",
1368}
1369Notification.remove(bundle, notificationKey).then(() => {
1370	console.info("==========================>removeCallback=======================>");
1371});
1372```
1373
1374
1375
1376## Notification.remove
1377
1378remove(hashCode: string, callback: AsyncCallback\<void\>): void
1379
1380Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result.
1381
1382**System capability**: SystemCapability.Notification.Notification
1383
1384**Parameters**
1385
1386| Name    | Readable| Writable| Type                 | Mandatory| Description                |
1387| -------- | ---- | --- | --------------------- | ---- | -------------------- |
1388| hashCode | Yes  | No | string                | Yes  | Unique notification ID.          |
1389| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1390
1391**Example**
1392
1393```js
1394function removeCallback(err) {
1395	console.info("==========================>removeCallback=======================>");
1396}
1397
1398Notification.remove(hashCode, removeCallback);
1399```
1400
1401
1402
1403## Notification.remove
1404
1405remove(hashCode: string): Promise\<void\>
1406
1407Removes a notification for a specified bundle. This API uses a promise to return the result.
1408
1409**System capability**: SystemCapability.Notification.Notification
1410
1411**Parameters**
1412
1413| Name    | Readable| Writable| Type      | Mandatory| Description      |
1414| -------- | ---- | --- | ---------- | ---- | ---------- |
1415| hashCode | Yes  | No | string | Yes  | Unique notification ID.|
1416
1417**Example**
1418
1419```js
1420Notification.remove(hashCode).then(() => {
1421	console.info("==========================>removeCallback=======================>");
1422});
1423```
1424
1425
1426
1427## Notification.removeAll
1428
1429removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
1430
1431Removes all notifications for a specified bundle. This API uses an asynchronous callback to return the result.
1432
1433**System capability**: SystemCapability.Notification.Notification
1434
1435**Parameters**
1436
1437| Name    | Readable| Writable| Type                 | Mandatory| Description                        |
1438| -------- | ---- | --- | --------------------- | ---- | ---------------------------- |
1439| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
1440| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1441
1442**Example**
1443
1444```js
1445function removeAllCallback(err) {
1446	console.info("==========================>removeAllCallback=======================>");
1447}
1448var bundle = {
1449    bundle: "bundleName1",
1450}
1451Notification.removeAll(bundle, removeAllCallback);
1452```
1453
1454
1455
1456## Notification.removeAll
1457
1458removeAll(callback: AsyncCallback\<void\>): void
1459
1460Removes all notifications. This API uses an asynchronous callback to return the result.
1461
1462**System capability**: SystemCapability.Notification.Notification
1463
1464**Parameters**
1465
1466| Name    | Readable| Writable| Type                 | Mandatory| Description                |
1467| -------- | ---- | --- | --------------------- | ---- | -------------------- |
1468| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1469
1470**Example**
1471
1472```js
1473function removeAllCallback(err) {
1474	console.info("==========================>removeAllCallback=======================>");
1475}
1476
1477Notification.removeAll(removeAllCallback);
1478```
1479
1480
1481
1482## Notification.removeAll
1483
1484removeAll(bundle?: BundleOption): Promise\<void\>
1485
1486Removes all notifications for a specified user. This API uses a promise to return the result.
1487
1488**System capability**: SystemCapability.Notification.Notification
1489
1490**Parameters**
1491
1492| Name  | Readable| Writable| Type        | Mandatory| Description      |
1493| ------ | ---- | --- | ------------ | ---- | ---------- |
1494| bundle | Yes  | No | [BundleOption](#bundleoption) | No  | Bundle information.|
1495
1496**Example**
1497
1498```js
1499Notification.removeAll().then(() => {
1500	console.info("==========================>removeAllCallback=======================>");
1501});
1502```
1503
1504## Notification.removeAll<sup>8+</sup>
1505
1506removeAll(userId: number, callback: AsyncCallback\<void>): void
1507
1508Removes all notifications for a specified user. This API uses an asynchronous callback to return the result.
1509
1510**System capability**: SystemCapability.Notification.Notification
1511
1512**Parameters**
1513
1514| Name  | Readable| Writable| Type        | Mandatory| Description      |
1515| ------ | ---- | --- | ------------ | ---- | ---------- |
1516| userId | Yes  | No | number | Yes  | ID of the user who receives the notification.|
1517| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1518
1519**Example**
1520
1521```js
1522function removeAllCallback(err) {
1523	console.info("==========================>removeAllCallback=======================>");
1524}
1525
1526var userId = 1
1527
1528Notification.removeAll(userId, removeAllCallback);
1529```
1530
1531## Notification.removeAll<sup>8+</sup>
1532
1533removeAll(userId: number): Promise\<void>
1534
1535Removes all notifications for a specified user. This API uses a promise to return the result.
1536
1537**System capability**: SystemCapability.Notification.Notification
1538
1539**Parameters**
1540
1541| Name  | Readable| Writable| Type        | Mandatory| Description      |
1542| ------ | ---- | --- | ------------ | ---- | ---------- |
1543| userId | Yes  | No | number | Yes  | ID of the user who receives the notification.|
1544
1545**Example**
1546
1547```js
1548function removeAllCallback(err) {
1549	console.info("==========================>removeAllCallback=======================>");
1550}
1551
1552var userId = 1
1553
1554Notification.removeAll(userId, removeAllCallback);
1555```
1556
1557
1558## Notification.getAllActiveNotifications
1559
1560getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
1561
1562Obtains all active notifications. This API uses an asynchronous callback to return the result.
1563
1564**System capability**: SystemCapability.Notification.Notification
1565
1566**Parameters**
1567
1568| Name    | Readable| Writable| Type                                                        | Mandatory| Description                |
1569| -------- | ---- | --- | ------------------------------------------------------------ | ---- | -------------------- |
1570| callback | Yes  | No | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
1571
1572**Example**
1573
1574```js
1575function getAllActiveNotificationsCallback(err, data) {
1576	console.info("==========================>getAllActiveNotificationsCallback=======================>");
1577}
1578
1579Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
1580```
1581
1582
1583
1584## Notification.getAllActiveNotifications
1585
1586getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
1587
1588Obtains all active notifications. This API uses a promise to return the result.
1589
1590**System capability**: SystemCapability.Notification.Notification
1591
1592**Return value**
1593
1594| Type                                                       | Description                                                        |
1595| ----------------------------------------------------------- | ------------------------------------------------------------ |
1596| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
1597
1598**Example**
1599
1600```js
1601Notification.getAllActiveNotifications().then((data) => {
1602	console.info("==========================>getAllActiveNotificationsCallback=======================>");
1603});
1604```
1605
1606
1607
1608## Notification.getActiveNotificationCount
1609
1610getActiveNotificationCount(callback: AsyncCallback\<number\>): void
1611
1612Obtains the number of active notifications. This API uses an asynchronous callback to return the result.
1613
1614**System capability**: SystemCapability.Notification.Notification
1615
1616**Parameters**
1617
1618| Name    | Readable| Writable| Type                  | Mandatory| Description                  |
1619| -------- | ---- | --- | ---------------------- | ---- | ---------------------- |
1620| callback | Yes  | No | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
1621
1622**Example**
1623
1624```js
1625function getActiveNotificationCountCallback(err, data) {
1626	console.info("==========================>getActiveNotificationCountCallback=======================>");
1627}
1628
1629Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
1630```
1631
1632
1633
1634## Notification.getActiveNotificationCount
1635
1636getActiveNotificationCount(): Promise\<number\>
1637
1638Obtains the number of active notifications. This API uses a promise to return the result.
1639
1640**System capability**: SystemCapability.Notification.Notification
1641
1642**Return value**
1643
1644| Type                                                       | Description                                                        |
1645| ----------------------------------------------------------- | ------------------------------------------------------------ |
1646| Promise\<number\> | Promise used to return the result.|
1647
1648**Example**
1649
1650```js
1651Notification.getActiveNotificationCount().then((data) => {
1652	console.info("==========================>getActiveNotificationCountCallback=======================>");
1653});
1654```
1655
1656
1657
1658## Notification.getActiveNotifications
1659
1660getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
1661
1662Obtains active notifications of this application. This API uses an asynchronous callback to return the result.
1663
1664**System capability**: SystemCapability.Notification.Notification
1665
1666**Parameters**
1667
1668| Name    | Readable| Writable| Type                                                        | Mandatory| Description                          |
1669| -------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------------------ |
1670| callback | Yes  | No | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
1671
1672**Example**
1673
1674```js
1675function getActiveNotificationsCallback(err, data) {
1676	console.info("==========================>getActiveNotificationsCallback=======================>");
1677}
1678
1679Notification.getActiveNotifications(getActiveNotificationsCallback);
1680```
1681
1682
1683
1684## Notification.getActiveNotifications
1685
1686getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
1687
1688Obtains active notifications of this application. This API uses a promise to return the result.
1689
1690**System capability**: SystemCapability.Notification.Notification
1691
1692**Return value**
1693
1694| Type                                                       | Description                                                        |
1695| ----------------------------------------------------------- | ------------------------------------------------------------ |
1696| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
1697
1698**Example**
1699
1700```js
1701Notification.getActiveNotifications().then((data) => {
1702	console.info("==========================>getActiveNotificationsCallback=======================>");
1703});
1704```
1705
1706
1707
1708## Notification.cancelGroup<sup>8+</sup>
1709
1710cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
1711
1712Cancels a notification group of this application. This API uses an asynchronous callback to return the result.
1713
1714**System capability**: SystemCapability.Notification.Notification
1715
1716**Parameters**
1717
1718| Name     | Readable| Writable| Type                 | Mandatory| Description                        |
1719| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
1720| groupName | Yes  | No | string                | Yes  | Name of the notification group.              |
1721| callback  | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1722
1723**Example**
1724
1725```js
1726function cancelGroupCallback(err) {
1727   console.info("==========================>cancelGroupCallback=======================>");
1728}
1729
1730var groupName = "GroupName";
1731
1732Notification.cancelGroup(groupName, cancelGroupCallback);
1733```
1734
1735
1736
1737## Notification.cancelGroup<sup>8+</sup>
1738
1739cancelGroup(groupName: string): Promise\<void\>
1740
1741Cancels a notification group of this application. This API uses a promise to return the result.
1742
1743**System capability**: SystemCapability.Notification.Notification
1744
1745**Parameters**
1746
1747| Name     | Readable| Writable| Type  | Mandatory| Description          |
1748| --------- | ---- | --- | ------ | ---- | -------------- |
1749| groupName | Yes  | No | string | Yes  | Name of the notification group.|
1750
1751**Example**
1752
1753```js
1754var groupName = "GroupName";
1755Notification.cancelGroup(groupName).then(() => {
1756	console.info("==========================>cancelGroupPromise=======================>");
1757});
1758```
1759
1760
1761
1762## Notification.removeGroupByBundle<sup>8+</sup>
1763
1764removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
1765
1766Removes a notification group for a specified bundle. This API uses an asynchronous callback to return the result.
1767
1768**System capability**: SystemCapability.Notification.Notification
1769
1770**Parameters**
1771
1772| Name     | Readable| Writable| Type                 | Mandatory| Description                        |
1773| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
1774| bundle    | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
1775| groupName | Yes  | No | string                | Yes  | Name of the notification group.              |
1776| callback  | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1777
1778**Example**
1779
1780```js
1781function removeGroupByBundleCallback(err) {
1782   console.info("==========================>removeGroupByBundleCallback=======================>");
1783}
1784
1785var bundleOption = {bundle: "Bundle"};
1786var groupName = "GroupName";
1787
1788Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
1789```
1790
1791
1792
1793## Notification.removeGroupByBundle<sup>8+</sup>
1794
1795removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
1796
1797Removes a notification group for a specified bundle. This API uses a promise to return the result.
1798
1799**System capability**: SystemCapability.Notification.Notification
1800
1801**Parameters**
1802
1803| Name     | Readable| Writable| Type        | Mandatory| Description          |
1804| --------- | ---- | --- | ------------ | ---- | -------------- |
1805| bundle    | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.    |
1806| groupName | Yes  | No | string       | Yes  | Name of the notification group.|
1807
1808**Example**
1809
1810```js
1811var bundleOption = {bundle: "Bundle"};
1812var groupName = "GroupName";
1813Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
1814	console.info("==========================>removeGroupByBundlePromise=======================>");
1815});
1816```
1817
1818
1819
1820## Notification.setDoNotDisturbDate<sup>8+</sup>
1821
1822setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
1823
1824Sets the DND time. This API uses an asynchronous callback to return the result.
1825
1826**System capability**: SystemCapability.Notification.Notification
1827
1828**Parameters**
1829
1830| Name    | Readable| Writable| Type                 | Mandatory| Description                  |
1831| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
1832| date     | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
1833| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1834
1835**Example**
1836
1837```js
1838function setDoNotDisturbDateCallback(err) {
1839   console.info("==========================>setDoNotDisturbDateCallback=======================>");
1840}
1841
1842var doNotDisturbDate = {
1843    type: Notification.DoNotDisturbType.TYPE_ONCE,
1844    begin: new Date(),
1845    end: new Date(2021, 11, 15, 18, 0)
1846}
1847
1848Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
1849```
1850
1851
1852
1853## Notification.setDoNotDisturbDate<sup>8+</sup>
1854
1855setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
1856
1857Sets the DND time. This API uses a promise to return the result.
1858
1859**System capability**: SystemCapability.Notification.Notification
1860
1861**Parameters**
1862
1863| Name| Readable| Writable| Type            | Mandatory| Description          |
1864| ---- | ---- | --- | ---------------- | ---- | -------------- |
1865| date | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
1866
1867**Example**
1868
1869```js
1870var doNotDisturbDate = {
1871    type: Notification.DoNotDisturbType.TYPE_ONCE,
1872    begin: new Date(),
1873    end: new Date(2021, 11, 15, 18, 0)
1874}
1875Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
1876	console.info("==========================>setDoNotDisturbDatePromise=======================>");
1877});
1878```
1879
1880
1881## Notification.setDoNotDisturbDate<sup>8+</sup>
1882
1883setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void
1884
1885Sets the DND time for a specified user. This API uses an asynchronous callback to return the result.
1886
1887**System capability**: SystemCapability.Notification.Notification
1888
1889**Parameters**
1890
1891| Name    | Readable| Writable| Type                 | Mandatory| Description                  |
1892| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
1893| date     | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
1894| userId   | Yes  | No | number                | Yes  | User ID.|
1895| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1896
1897**Example**
1898
1899```js
1900function setDoNotDisturbDateCallback(err) {
1901   console.info("==========================>setDoNotDisturbDateCallback=======================>");
1902}
1903
1904var doNotDisturbDate = {
1905    type: Notification.DoNotDisturbType.TYPE_ONCE,
1906    begin: new Date(),
1907    end: new Date(2021, 11, 15, 18, 0)
1908}
1909
1910var userId = 1
1911
1912Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
1913```
1914
1915
1916
1917## Notification.setDoNotDisturbDate<sup>8+</sup>
1918
1919setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
1920
1921Sets the DND time for a specified user. This API uses a promise to return the result.
1922
1923**System capability**: SystemCapability.Notification.Notification
1924
1925**Parameters**
1926
1927| Name  | Readable| Writable| Type            | Mandatory| Description          |
1928| ------ | ---- | --- | ---------------- | ---- | -------------- |
1929| date   | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
1930| userId | Yes  | No | number           | Yes  | User ID.|
1931
1932**Example**
1933
1934```js
1935var doNotDisturbDate = {
1936    type: Notification.DoNotDisturbType.TYPE_ONCE,
1937    begin: new Date(),
1938    end: new Date(2021, 11, 15, 18, 0)
1939}
1940
1941var userId = 1
1942
1943Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
1944	console.info("==========================>setDoNotDisturbDatePromise=======================>");
1945});
1946```
1947
1948
1949## Notification.getDoNotDisturbDate<sup>8+</sup>
1950
1951getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
1952
1953Obtains the DND time. This API uses an asynchronous callback to return the result.
1954
1955**System capability**: SystemCapability.Notification.Notification
1956
1957**Parameters**
1958
1959| Name    | Readable| Writable| Type                             | Mandatory| Description                  |
1960| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
1961| callback | Yes  | No | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
1962
1963**Example**
1964
1965```js
1966function getDoNotDisturbDateCallback(err,data) {
1967   console.info("==========================>getDoNotDisturbDateCallback=======================>");
1968}
1969
1970Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
1971```
1972
1973
1974
1975## Notification.getDoNotDisturbDate<sup>8+</sup>
1976
1977getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
1978
1979Obtains the DND time. This API uses a promise to return the result.
1980
1981**System capability**: SystemCapability.Notification.Notification
1982
1983**Return value**
1984
1985| Type                                                       | Description                                                        |
1986| ----------------------------------------------------------- | ------------------------------------------------------------ |
1987| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
1988
1989**Example**
1990
1991```js
1992Notification.getDoNotDisturbDate().then((data) => {
1993	console.info("==========================>getDoNotDisturbDatePromise=======================>");
1994});
1995```
1996
1997
1998## Notification.getDoNotDisturbDate<sup>8+</sup>
1999
2000getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
2001
2002Obtains the DND time of a specified user. This API uses an asynchronous callback to return the result.
2003
2004**System capability**: SystemCapability.Notification.Notification
2005
2006**Parameters**
2007
2008| Name    | Readable| Writable| Type                             | Mandatory| Description                  |
2009| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
2010| callback | Yes  | No | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
2011| userId   | Yes  | No | number                            | Yes  | User ID.|
2012
2013**Example**
2014
2015```js
2016function getDoNotDisturbDateCallback(err,data) {
2017   console.info("==========================>getDoNotDisturbDateCallback=======================>");
2018}
2019
2020var userId = 1
2021
2022Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
2023```
2024
2025
2026
2027## Notification.getDoNotDisturbDate<sup>8+</sup>
2028
2029getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
2030
2031Obtains the DND time of a specified user. This API uses a promise to return the result.
2032
2033**System capability**: SystemCapability.Notification.Notification
2034
2035**Parameters**
2036
2037| Name    | Readable| Writable| Type                             | Mandatory| Description                  |
2038| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
2039| userId   | Yes  | No | number                            | Yes  | User ID.|
2040
2041**Return value**
2042
2043| Type                                                       | Description                                                        |
2044| ----------------------------------------------------------- | ------------------------------------------------------------ |
2045| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
2046
2047**Example**
2048
2049```js
2050var userId = 1
2051
2052Notification.getDoNotDisturbDate(userId).then((data) => {
2053	console.info("==========================>getDoNotDisturbDatePromise=======================>");
2054});
2055```
2056
2057
2058## Notification.supportDoNotDisturbMode<sup>8+</sup>
2059
2060supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
2061
2062Checks whether the DND mode is supported. This API uses an asynchronous callback to return the result.
2063
2064**System capability**: SystemCapability.Notification.Notification
2065
2066**Parameters**
2067
2068| Name    | Readable| Writable| Type                    | Mandatory| Description                            |
2069| -------- | ---- | --- | ------------------------ | ---- | -------------------------------- |
2070| callback | Yes  | No | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
2071
2072**Example**
2073
2074```js
2075function supportDoNotDisturbModeCallback(err,data) {
2076   console.info("==========================>supportDoNotDisturbModeCallback=======================>");
2077}
2078
2079Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
2080```
2081
2082
2083
2084## Notification.supportDoNotDisturbMode<sup>8+</sup>
2085
2086supportDoNotDisturbMode(): Promise\<boolean\>
2087
2088Checks whether the DND mode is supported. This API uses a promise to return the result.
2089
2090**System capability**: SystemCapability.Notification.Notification
2091
2092**Return value**
2093
2094| Type                                                       | Description                                                        |
2095| ----------------------------------------------------------- | ------------------------------------------------------------ |
2096| Promise\<boolean\> | Promise used to return the result.|
2097
2098**Example**
2099
2100```js
2101Notification.supportDoNotDisturbMode().then((data) => {
2102	console.info("==========================>supportDoNotDisturbModePromise=======================>");
2103});
2104```
2105
2106
2107
2108## Notification.isSupportTemplate<sup>8+</sup>
2109
2110isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void
2111
2112Checks whether a specified template exists. This API uses an asynchronous callback to return the result.
2113
2114**System capability**: SystemCapability.Notification.Notification
2115
2116**Parameters**
2117
2118| Name      | Type                    | Mandatory| Description                      |
2119| ------------ | ------------------------ | ---- | -------------------------- |
2120| templateName | string                   | Yes  | Template name.                  |
2121| callback     | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
2122
2123**Example**
2124
2125```javascript
2126var templateName = 'process';
2127function isSupportTemplateCallback(err, data) {
2128    console.info("isSupportTemplateCallback");
2129}
2130
2131Notification.isSupportTemplate(templateName, isSupportTemplateCallback);
2132```
2133
2134
2135
2136## Notification.isSupportTemplate<sup>8+</sup>
2137
2138isSupportTemplate(templateName: string): Promise\<boolean\>
2139
2140Checks whether a specified template exists. This API uses a promise to return the result.
2141
2142**System capability**: SystemCapability.Notification.Notification
2143
2144**Parameters**
2145
2146| Name      | Type  | Mandatory| Description    |
2147| ------------ | ------ | ---- | -------- |
2148| templateName | string | Yes  | Template name.|
2149
2150**Return value**
2151
2152| Type              | Description           |
2153| ------------------ | --------------- |
2154| Promise\<boolean\> | Promise used to return the result.|
2155
2156**Example**
2157
2158```javascript
2159var templateName = 'process';
2160
2161Notification.isSupportTemplate(templateName).then((data) => {
2162    console.info("isSupportTemplateCallback");
2163});
2164```
2165
2166
2167
2168## Notification.requestEnableNotification<sup>8+</sup>
2169
2170requestEnableNotification(callback: AsyncCallback\<void\>): void
2171
2172Requests notification to be enabled for this application. This API uses an asynchronous callback to return the result.
2173
2174**System capability**: SystemCapability.Notification.Notification
2175
2176**Parameters**
2177
2178| Name  | Type                    | Mandatory| Description                      |
2179| -------- | ------------------------ | ---- | -------------------------- |
2180| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
2181
2182**Example**
2183
2184```javascript
2185function requestEnabledNotificationCallback() {
2186    console.log('------------- requestEnabledNotification --------------');
2187};
2188
2189Notification.requestEnabledNotification(requestEnabledNotificationCallback);
2190```
2191
2192
2193
2194## Notification.requestEnableNotification<sup>8+</sup>
2195
2196requestEnableNotification(): Promise\<void\>
2197
2198Requests notification to be enabled for this application. This API uses a promise to return the result.
2199
2200**System capability**: SystemCapability.Notification.Notification
2201
2202**Example**
2203
2204```javascript
2205Notification.requestEnableNotification()
2206    .then(() => {
2207        console.info("requestEnableNotification ");
2208	});
2209```
2210
2211
2212## Notification.enableDistributed<sup>8+</sup>
2213
2214enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void
2215
2216Sets whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.
2217
2218**System capability**: SystemCapability.Notification.Notification
2219
2220**Parameters**
2221
2222| Name  | Type                    | Mandatory| Description                      |
2223| -------- | ------------------------ | ---- | -------------------------- |
2224| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|
2225| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
2226
2227**Example**
2228
2229```javascript
2230function enabledNotificationCallback() {
2231    console.log('----------- enableDistributed ------------');
2232};
2233
2234var enable = true
2235
2236Notification.enableDistributed(enable, enabledNotificationCallback);
2237```
2238
2239
2240
2241## Notification.enableDistributed<sup>8+</sup>
2242
2243enableDistributed(enable: boolean): Promise\<void>
2244
2245Sets whether this device supports distributed notifications. This API uses a promise to return the result.
2246
2247**System capability**: SystemCapability.Notification.Notification
2248
2249**Parameters**
2250
2251| Name  | Type                    | Mandatory| Description                      |
2252| -------- | ------------------------ | ---- | -------------------------- |
2253| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|
2254
2255**Example**
2256
2257```javascript
2258var enable = true
2259
2260Notification.enableDistributed(enable)
2261    .then(() => {
2262        console.log('-------- enableDistributed ----------');
2263    });
2264```
2265
2266
2267## Notification.isDistributedEnabled<sup>8+</sup>
2268
2269isDistributedEnabled(callback: AsyncCallback\<boolean>): void
2270
2271Obtains whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.
2272
2273**System capability**: SystemCapability.Notification.Notification
2274
2275**Parameters**
2276
2277| Name  | Type                    | Mandatory| Description                      |
2278| -------- | ------------------------ | ---- | -------------------------- |
2279| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
2280
2281**Example**
2282
2283```javascript
2284function isDistributedEnabledCallback() {
2285    console.log('----------- isDistributedEnabled ------------');
2286};
2287
2288Notification.enableDistributed(isDistributedEnabledCallback);
2289```
2290
2291
2292
2293## Notification.isDistributedEnabled<sup>8+</sup>
2294
2295isDistributedEnabled(): Promise\<boolean>
2296
2297Obtains whether this device supports distributed notifications. This API uses a promise to return the result.
2298
2299**System capability**: SystemCapability.Notification.Notification
2300
2301**Return value**
2302
2303| Type              | Description           |
2304| ------------------ | --------------- |
2305| Promise\<boolean\> | Promise used to return the result.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|
2306
2307**Example**
2308
2309```javascript
2310Notification.isDistributedEnabled()
2311    .then((data) => {
2312        console.log('-------- isDistributedEnabled ----------');
2313    });
2314```
2315
2316
2317## Notification.enableDistributedByBundle<sup>8+</sup>
2318
2319enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
2320
2321Sets whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result.
2322
2323**System capability**: SystemCapability.Notification.Notification
2324
2325**Parameters**
2326
2327| Name  | Type                    | Mandatory| Description                      |
2328| -------- | ------------------------ | ---- | -------------------------- |
2329| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
2330| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                      |
2331| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
2332
2333**Example**
2334
2335```javascript
2336function enableDistributedByBundleCallback() {
2337    console.log('----------- enableDistributedByBundle ------------');
2338};
2339
2340var bundle = {
2341    bundle: "bundleName1",
2342}
2343
2344var enable = true
2345
2346Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
2347```
2348
2349
2350
2351## Notification.enableDistributedByBundle<sup>8+</sup>
2352
2353bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
2354
2355Sets whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result.
2356
2357**System capability**: SystemCapability.Notification.Notification
2358
2359**Parameters**
2360
2361| Name  | Type                    | Mandatory| Description                      |
2362| -------- | ------------------------ | ---- | -------------------------- |
2363| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.               |
2364| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                 |
2365
2366**Example**
2367
2368```javascript
2369var bundle = {
2370    bundle: "bundleName1",
2371}
2372
2373var enable = true
2374
2375Notification.enableDistributedByBundle(bundle, enable)
2376    .then(() => {
2377        console.log('-------- enableDistributedByBundle ----------');
2378    });
2379```
2380
2381## Notification.isDistributedEnabledByBundle<sup>8+</sup>
2382
2383isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
2384
2385Obtains whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result.
2386
2387**System capability**: SystemCapability.Notification.Notification
2388
2389**Parameters**
2390
2391| Name  | Type                    | Mandatory| Description                      |
2392| -------- | ------------------------ | ---- | -------------------------- |
2393| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
2394| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
2395
2396**Example**
2397
2398```javascript
2399function isDistributedEnabledByBundleCallback(data) {
2400    console.log('----------- isDistributedEnabledByBundle ------------', data);
2401};
2402
2403var bundle = {
2404    bundle: "bundleName1",
2405}
2406
2407Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallback);
2408```
2409
2410
2411
2412## Notification.isDistributedEnabledByBundle<sup>8+</sup>
2413
2414isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
2415
2416Obtains whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result.
2417
2418**System capability**: SystemCapability.Notification.Notification
2419
2420**Parameters**
2421
2422| Name  | Type                    | Mandatory| Description                      |
2423| -------- | ------------------------ | ---- | -------------------------- |
2424| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.               |
2425
2426**Return value**
2427
2428| Type              | Description           |
2429| ------------------ | --------------- |
2430| Promise\<boolean\> | Promise used to return the result.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|
2431
2432**Example**
2433
2434```javascript
2435var bundle = {
2436    bundle: "bundleName1",
2437}
2438
2439Notification.isDistributedEnabledByBundle(bundle)
2440    .then((data) => {
2441        console.log('-------- isDistributedEnabledByBundle ----------', data);
2442    });
2443```
2444
2445
2446## Notification.getDeviceRemindType<sup>8+</sup>
2447
2448getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
2449
2450Obtains the notification reminder type. This API uses an asynchronous callback to return the result.
2451
2452**System capability**: SystemCapability.Notification.Notification
2453
2454**Parameters**
2455
2456| Name  | Type                              | Mandatory| Description                      |
2457| -------- | --------------------------------- | ---- | -------------------------- |
2458| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | Yes  | Callback used to return the result.|
2459
2460**Example**
2461
2462```javascript
2463function getDeviceRemindTypeCallback(data) {
2464    console.log('----------- getDeviceRemindType ------------', data);
2465};
2466
2467Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
2468```
2469
2470
2471
2472## Notification.getDeviceRemindType<sup>8+</sup>
2473
2474getDeviceRemindType(): Promise\<DeviceRemindType\>
2475
2476Obtains the notification reminder type. This API uses a promise to return the result.
2477
2478**System capability**: SystemCapability.Notification.Notification
2479
2480**Return value**
2481
2482| Type              | Description           |
2483| ------------------ | --------------- |
2484| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise used to return the result.|
2485
2486**Example**
2487
2488```javascript
2489Notification.getDeviceRemindType()
2490    .then((data) => {
2491        console.log('-------- getDeviceRemindType ----------', data);
2492    });
2493```
2494
2495## NotificationSubscriber
2496
2497### onConsume
2498
2499onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata))
2500
2501Callback for receiving notifications.
2502
2503**System capability**: SystemCapability.Notification.Notification
2504
2505**Parameters**
2506
2507| Name| Type| Mandatory| Description|
2508| ------------ | ------------------------ | ---- | -------------------------- |
2509| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|
2510
2511**Example**
2512
2513```javascript
2514function subscribeCallback(err) {
2515    if (err.code) {
2516        console.info("subscribe failed " + JSON.stringify(err));
2517    } else {
2518        console.info("subscribeCallback");
2519    }
2520};
2521
2522function onConsumeCallback(data) {
2523    console.info('===> onConsume in test');
2524    let req = data.request;
2525    console.info('===> onConsume callback req.id:' + req.id);
2526    let wantAgent = data.wantAgent;
2527    wantAgent .getWant(wantAgent)
2528        .then((data1) => {
2529            console.log('===> getWant success want:' + JSON.stringify(data1));
2530        })
2531        .catch((err) => {
2532            console.error('===> getWant failed because' + JSON.stringify(err));
2533        });
2534    console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
2535};
2536
2537var subscriber = {
2538    onConsume: onConsumeCallback
2539};
2540
2541Notification.subscribe(subscriber, subscribeCallback);
2542```
2543
2544### onCancel
2545
2546onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata))
2547
2548Callback for removing notifications.
2549
2550**System capability**: SystemCapability.Notification.Notification
2551
2552**Parameters**
2553
2554| Name| Type| Mandatory| Description|
2555| ------------ | ------------------------ | ---- | -------------------------- |
2556| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|
2557
2558**Example**
2559
2560```javascript
2561function subscribeCallback(err) {
2562    if (err.code) {
2563        console.info("subscribe failed " + JSON.stringify(err));
2564    } else {
2565        console.info("subscribeCallback");
2566    }
2567};
2568
2569function onCancelCallback(data) {
2570    console.info('===> onCancel in test');
2571    let req = data.request;
2572    console.info('===> onCancel callback req.id:' + req.id);
2573}
2574
2575var subscriber = {
2576    onCancel: onCancelCallback
2577};
2578
2579Notification.subscribe(subscriber, subscribeCallback);
2580```
2581
2582### onUpdate
2583
2584onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap))
2585
2586Callback for notification sorting updates.
2587
2588**System capability**: SystemCapability.Notification.Notification
2589
2590**Parameters**
2591
2592| Name| Type| Mandatory| Description|
2593| ------------ | ------------------------ | ---- | -------------------------- |
2594| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.|
2595
2596**Example**
2597
2598```javascript
2599function subscribeCallback(err) {
2600    if (err.code) {
2601        console.info("subscribe failed " + JSON.stringify(err));
2602    } else {
2603        console.info("subscribeCallback");
2604    }
2605};
2606
2607function onUpdateCallback() {
2608    console.info('===> onUpdate in test');
2609}
2610
2611var subscriber = {
2612    onUpdate: onUpdateCallback
2613};
2614
2615Notification.subscribe(subscriber, subscribeCallback);
2616```
2617
2618### onConnect
2619
2620onConnect?:void
2621
2622Callback for subscription.
2623
2624**System capability**: SystemCapability.Notification.Notification
2625
2626**Example**
2627
2628```javascript
2629function subscribeCallback(err) {
2630    if (err.code) {
2631        console.info("subscribe failed " + JSON.stringify(err));
2632    } else {
2633        console.info("subscribeCallback");
2634    }
2635};
2636
2637function onConnectCallback() {
2638    console.info('===> onConnect in test');
2639}
2640
2641var subscriber = {
2642    onConnect: onConnectCallback
2643};
2644
2645Notification.subscribe(subscriber, subscribeCallback);
2646```
2647
2648### onDisconnect
2649
2650onDisconnect?:void
2651
2652Callback for unsubscription.
2653
2654**System capability**: SystemCapability.Notification.Notification
2655
2656**Example**
2657
2658```javascript
2659function subscribeCallback(err) {
2660    if (err.code) {
2661        console.info("subscribe failed " + JSON.stringify(err));
2662    } else {
2663        console.info("subscribeCallback");
2664    }
2665};
2666
2667function onDisconnectCallback() {
2668    console.info('===> onDisconnect in test');
2669}
2670
2671var subscriber = {
2672    onDisconnect: onDisconnectCallback
2673};
2674
2675Notification.subscribe(subscriber, subscribeCallback);
2676```
2677
2678### onDestroy
2679
2680onDestroy?:void
2681
2682Callback for service disconnection.
2683
2684**System capability**: SystemCapability.Notification.Notification
2685
2686**Example**
2687
2688```javascript
2689function subscribeCallback(err) {
2690    if (err.code) {
2691        console.info("subscribe failed " + JSON.stringify(err));
2692    } else {
2693        console.info("subscribeCallback");
2694    }
2695};
2696
2697function onDestroyCallback() {
2698    console.info('===> onDestroy in test');
2699}
2700
2701var subscriber = {
2702    onDestroy: onDestroyCallback
2703};
2704
2705Notification.subscribe(subscriber, subscribeCallback);
2706```
2707
2708### onDoNotDisturbDateChange<sup>8+</sup>
2709
2710onDoNotDisturbDateChange?:(mode: Notification.[DoNotDisturbDate](#donotdisturbdate8))
2711
2712Callback for DND time setting updates.
2713
2714**System capability**: SystemCapability.Notification.Notification
2715
2716**Parameters**
2717
2718| Name| Type| Mandatory| Description|
2719| ------------ | ------------------------ | ---- | -------------------------- |
2720| mode | Notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
2721
2722**Example**
2723```javascript
2724function subscribeCallback(err) {
2725    if (err.code) {
2726        console.info("subscribe failed " + JSON.stringify(err));
2727    } else {
2728        console.info("subscribeCallback");
2729    }
2730};
2731
2732function onDoNotDisturbDateChangeCallback() {
2733    console.info('===> onDoNotDisturbDateChange in test');
2734}
2735
2736var subscriber = {
2737    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
2738};
2739
2740Notification.subscribe(subscriber, subscribeCallback);
2741```
2742
2743
2744### onEnabledNotificationChanged<sup>8+</sup>
2745
2746onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8))
2747
2748Listens for the notification enable status changes. This API uses an asynchronous callback to return the result.
2749
2750**System capability**: SystemCapability.Notification.Notification
2751
2752**Parameters**
2753
2754| Name| Type| Mandatory| Description|
2755| ------------ | ------------------------ | ---- | -------------------------- |
2756| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
2757
2758**Example**
2759
2760```javascript
2761function subscribeCallback(err) {
2762    if (err.code) {
2763        console.info("subscribe failed " + JSON.stringify(err));
2764    } else {
2765        console.info("subscribeCallback");
2766    }
2767};
2768
2769function onEnabledNotificationChangedCallback(err, callbackData) {
2770    if (err.code) {
2771        console.info("subscribe failed " + JSON.stringify(err));
2772    } else {
2773        console.info("bundle: ", callbackData.bundle);
2774        console.info("uid: ", callbackData.uid);
2775        console.info("enable: ", callbackData.enable);
2776    }
2777};
2778
2779var subscriber = {
2780    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
2781};
2782
2783Notification.subscribe(subscriber, subscribeCallback);
2784```
2785
2786## SubscribeCallbackData
2787
2788**System capability**: SystemCapability.Notification.Notification
2789
2790| Name           | Readable| Writable| Type                                             | Mandatory| Description    |
2791| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- |
2792| request         | Yes | No | [NotificationRequest](#notificationrequest)       | Yes  | Notification content.|
2793| sortingMap      | Yes | No | [NotificationSortingMap](#notificationsortingmap) | No  | Notification sorting information.|
2794| reason          | Yes | No | number                                            | No  | Reason for deletion.|
2795| sound           | Yes | No | string                                            | No  | Sound used for notification.|
2796| vibrationValues | Yes | No | Array\<number\>                                   | No  | Vibration used for notification.|
2797
2798
2799## EnabledNotificationCallbackData<sup>8+</sup>
2800
2801**System capability**: SystemCapability.Notification.Notification
2802
2803| Name  | Readable| Writable| Type   | Mandatory| Description            |
2804| ------ | ---- | --- | ------- | ---- | ---------------- |
2805| bundle | Yes | No | string  | Yes  | Bundle name of the application.      |
2806| uid    | Yes | No | number  | Yes  | UID of the application.       |
2807| enable | Yes | No | boolean | Yes  | Notification enable status of the application.|
2808
2809
2810## DoNotDisturbDate<sup>8+</sup>
2811
2812**System capability**: SystemCapability.Notification.Notification
2813
2814| Name | Readable| Writable| Type                                 | Description                    |
2815| ----- | ---- | --- | ------------------------------------- | ------------------------ |
2816| type  | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.|
2817| begin | Yes | No | Date                                  | DND start time.|
2818| end   | Yes | No | Date                                  | DND end time.|
2819
2820
2821
2822## DoNotDisturbType<sup>8+</sup>
2823
2824**System capability**: SystemCapability.Notification.Notification
2825
2826
2827| Name        | Value              | Description                                      |
2828| ------------ | ---------------- | ------------------------------------------ |
2829| TYPE_NONE    | DoNotDisturbType | Non-DND.                          |
2830| TYPE_ONCE    | DoNotDisturbType | One-shot DND at the specified time segment (only considering the hour and minute).|
2831| TYPE_DAILY   | DoNotDisturbType | Daily DND at the specified time segment (only considering the hour and minute).|
2832| TYPE_CLEARLY | DoNotDisturbType | DND at the specified time segment (considering the year, month, day, hour, and minute).    |
2833
2834
2835## ContentType
2836
2837**System capability**: SystemCapability.Notification.Notification
2838
2839| Name                             | Value         | Description              |
2840| --------------------------------- | ----------- | ------------------ |
2841| NOTIFICATION_CONTENT_BASIC_TEXT   | ContentType | Normal text notification.    |
2842| NOTIFICATION_CONTENT_LONG_TEXT    | ContentType | Long text notification.  |
2843| NOTIFICATION_CONTENT_PICTURE      | ContentType | Picture-attached notification.    |
2844| NOTIFICATION_CONTENT_CONVERSATION | ContentType | Conversation notification.    |
2845| NOTIFICATION_CONTENT_MULTILINE    | ContentType | Multi-line text notification.|
2846
2847## SlotLevel
2848
2849**System capability**: SystemCapability.Notification.Notification
2850
2851| Name                             | Value         | Description              |
2852| --------------------------------- | ----------- | ------------------ |
2853| LEVEL_NONE                        | 0           | The notification feature is disabled.    |
2854| LEVEL_MIN                         | 1           | The notification feature is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
2855| LEVEL_LOW                         | 2           | The notification feature is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
2856| 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.|
2857| LEVEL_HIGH                        | 4           | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.|
2858
2859
2860## BundleOption
2861
2862**System capability**: SystemCapability.Notification.Notification
2863
2864| Name  | Readable| Writable| Type  | Mandatory| Description  |
2865| ------ | ---- | --- | ------ | ---- | ------ |
2866| bundle | Yes | Yes | string | Yes  | Bundle name.  |
2867| uid    | Yes | Yes | number | No  | User ID.|
2868
2869
2870
2871## NotificationKey
2872
2873**System capability**: SystemCapability.Notification.Notification
2874
2875| Name | Readable| Writable| Type  | Mandatory| Description    |
2876| ----- | ---- | --- | ------ | ---- | -------- |
2877| id    | Yes | Yes | number | Yes  | Notification ID.  |
2878| label | Yes | Yes | string | No  | Notification label.|
2879
2880
2881## SlotType
2882
2883**System capability**: SystemCapability.Notification.Notification
2884
2885| Name                | Value      | Description      |
2886| -------------------- | -------- | ---------- |
2887| UNKNOWN_TYPE         | SlotType | Unknown type.|
2888| SOCIAL_COMMUNICATION | SlotType | Notification slot for social communication.|
2889| SERVICE_INFORMATION  | SlotType | Notification slot for service information.|
2890| CONTENT_INFORMATION  | SlotType | Notification slot for content consultation.|
2891| OTHER_TYPES          | SlotType | Notification slot for other purposes.|
2892
2893
2894## NotificationActionButton
2895
2896**System capability**: SystemCapability.Notification.Notification
2897
2898| Name     | Readable| Writable| Type                                           | Mandatory| Description                     |
2899| --------- | --- | ---- | ----------------------------------------------- | ---- | ------------------------- |
2900| title     | Yes | Yes | string                                          | Yes  | Button title.                 |
2901| wantAgent | Yes | Yes | WantAgent                                       | Yes  | **WantAgent** of the button.|
2902| extras    | Yes | Yes | { [key: string]: any }                          | No  | Extra information of the button.             |
2903| userInput | Yes | Yes | [NotificationUserInput](#notificationuserinput8) | No  | User input.            |
2904
2905
2906## NotificationBasicContent
2907
2908**System capability**: SystemCapability.Notification.Notification
2909
2910| Name          | Readable| Writable| Type  | Mandatory| Description                              |
2911| -------------- | ---- | ---- | ------ | ---- | ---------------------------------- |
2912| title          | Yes  | Yes  | string | Yes  | Notification title.                        |
2913| text           | Yes  | Yes  | string | Yes  | Notification content.                        |
2914| additionalText | Yes  | Yes  | string | No  | Additional information of the notification.|
2915
2916
2917## NotificationLongTextContent
2918
2919**System capability**: SystemCapability.Notification.Notification
2920
2921| Name          | Readable| Writable| Type  | Mandatory| Description                            |
2922| -------------- | ---- | --- | ------ | ---- | -------------------------------- |
2923| title          | Yes | Yes | string | Yes  | Notification title.                        |
2924| text           | Yes | Yes | string | Yes  | Notification content.                        |
2925| additionalText | Yes | Yes | string | No  | Additional information of the notification.|
2926| longText       | Yes | Yes | string | Yes  | Long text of the notification.                    |
2927| briefText      | Yes | Yes | string | Yes  | Brief text of the notification.|
2928| expandedTitle  | Yes | Yes | string | Yes  | Title of the notification in the expanded state.                |
2929
2930
2931## NotificationMultiLineContent
2932
2933**System capability**: SystemCapability.Notification.Notification
2934
2935| Name          | Readable| Writable| Type           | Mandatory| Description                            |
2936| -------------- | --- | --- | --------------- | ---- | -------------------------------- |
2937| title          | Yes | Yes | string          | Yes  | Notification title.                        |
2938| text           | Yes | Yes | string          | Yes  | Notification content.                        |
2939| additionalText | Yes | Yes | string          | No  | Additional information of the notification.|
2940| briefText      | Yes | Yes | string          | Yes  | Brief text of the notification.|
2941| longTitle      | Yes | Yes | string          | Yes  | Title of the notification in the expanded state.                |
2942| lines          | Yes | Yes | Array\<string\> | Yes  | Multi-line text of the notification.                  |
2943
2944
2945## NotificationPictureContent
2946
2947**System capability**: SystemCapability.Notification.Notification
2948
2949| Name          | Readable| Writable| Type          | Mandatory| Description                            |
2950| -------------- | ---- | --- | -------------- | ---- | -------------------------------- |
2951| title          | Yes | Yes | string         | Yes  | Notification title.                        |
2952| text           | Yes | Yes | string         | Yes  | Notification content.                        |
2953| additionalText | Yes | Yes | string         | No  | Additional information of the notification.|
2954| briefText      | Yes | Yes | string         | Yes  | Brief text of the notification.|
2955| expandedTitle  | Yes | Yes | string         | Yes  | Title of the notification in the expanded state.                |
2956| picture        | Yes | Yes | image.PixelMap | Yes  | Picture attached to the notification.                  |
2957
2958
2959## NotificationContent
2960
2961**System capability**: SystemCapability.Notification.Notification
2962
2963| Name       | Readable| Writable| Type                                                        | Mandatory| Description              |
2964| ----------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------ |
2965| contentType | Yes | Yes | [ContentType](#contenttype)                                  | Yes  | Notification content type.      |
2966| normal      | Yes | Yes | [NotificationBasicContent](#notificationbasiccontent)        | No  | Normal text.  |
2967| longText    | Yes | Yes | [NotificationLongTextContent](#notificationlongtextcontent)  | No  | Long text.|
2968| multiLine   | Yes | Yes | [NotificationMultiLineContent](#notificationmultilinecontent) | No  | Multi-line text.  |
2969| picture     | Yes | Yes | [NotificationPictureContent](#notificationpicturecontent)    | No  | Picture-attached.  |
2970
2971
2972## NotificationFlagStatus<sup>8+</sup>
2973
2974**System capability**: SystemCapability.Notification.Notification
2975
2976| Name          | Value | Description                              |
2977| -------------- | --- | --------------------------------- |
2978| TYPE_NONE      | 0   | The default flag is used.                        |
2979| TYPE_OPEN      | 1   | The notification flag is enabled.                    |
2980| TYPE_CLOSE     | 2   | The notification flag is disabled.                    |
2981
2982
2983## NotificationFlags<sup>8+</sup>
2984
2985**System capability**: SystemCapability.Notification.Notification
2986
2987| Name            | Readable| Writable| Type                   | Mandatory| Description                              |
2988| ---------------- | ---- | ---- | ---------------------- | ---- | --------------------------------- |
2989| soundEnabled     | Yes  | No  | NotificationFlagStatus | No  | Whether to enable the sound alert for the notification.                 |
2990| vibrationEnabled | Yes  | No  | NotificationFlagStatus | No  | Whether to enable vibration for the notification.              |
2991
2992
2993## NotificationRequest
2994
2995**System capability**: SystemCapability.Notification.Notification
2996
2997| Name                 | Readable| Writable| Type                                         | Mandatory| Description                      |
2998| --------------------- | ---- | --- | --------------------------------------------- | ---- | -------------------------- |
2999| content               | Yes | Yes | [NotificationContent](#notificationcontent)   | Yes  | Notification content.                  |
3000| id                    | Yes | Yes | number                                        | No  | Notification ID.                    |
3001| slotType              | Yes | Yes | [SlotType](#slottype)                                      | No  | Slot type.                  |
3002| isOngoing             | Yes | Yes | boolean                                       | No  | Whether the notification is an ongoing notification.            |
3003| isUnremovable         | Yes | Yes | boolean                                       | No  | Whether the notification can be removed.                |
3004| deliveryTime          | Yes | Yes | number                                        | No  | Time when the notification is sent.              |
3005| tapDismissed          | Yes | Yes | boolean                                       | No  | Whether the notification is automatically cleared.          |
3006| autoDeletedTime       | Yes | Yes | number                                        | No  | Time when the notification is automatically cleared.            |
3007| wantAgent             | Yes | Yes | WantAgent                                     | No  | **WantAgent** instance to which the notification will be redirected after being clicked.       |
3008| extraInfo             | Yes | Yes | {[key: string]: any}                          | No  | Extended parameters.                  |
3009| color                 | Yes | Yes | number                                        | No  | Background color of the notification.              |
3010| colorEnabled          | Yes | Yes | boolean                                       | No  | Whether the notification background color is enabled.      |
3011| isAlertOnce           | Yes | Yes | boolean                                       | No  | Whether the notification triggers an alert only once.|
3012| isStopwatch           | Yes | Yes | boolean                                       | No  | Whether to display the stopwatch.          |
3013| isCountDown           | Yes | Yes | boolean                                       | No  | Whether to display the countdown time.        |
3014| isFloatingIcon        | Yes | Yes | boolean                                       | No  | Whether the notification is displayed as a floating icon.        |
3015| label                 | Yes | Yes | string                                        | No  | Notification label.                  |
3016| badgeIconStyle        | Yes | Yes | number                                        | No  | Notification badge type.              |
3017| showDeliveryTime      | Yes | Yes | boolean                                       | No  | Whether to display the time when the notification is delivered.          |
3018| actionButtons         | Yes | Yes | Array\<[NotificationActionButton](#notificationactionbutton)\>             | No  | Buttons in the notification. Up to two buttons are allowed.    |
3019| smallIcon             | Yes | Yes | PixelMap                                      | No  | Small notification icon.                |
3020| largeIcon             | Yes | Yes | PixelMap                                      | No  | Large notification icon.                |
3021| creatorBundleName     | Yes | No | string                                        | No  | Name of the bundle that creates the notification.            |
3022| creatorUid            | Yes | No | number                                        | No  | UID used for creating the notification.             |
3023| creatorPid            | Yes | No | number                                        | No  | PID used for creating the notification.             |
3024| creatorUserId<sup>8+</sup>| Yes | No | number                                    | No  | ID of the user who creates a notification.          |
3025| hashCode              | Yes | No | string                                        | No  | Unique ID of the notification.              |
3026| classification        | Yes | Yes | string                                        | No  | Notification category.                  |
3027| groupName<sup>8+</sup>| Yes | Yes | string                                        | No  | Group notification name.                |
3028| template<sup>8+</sup> | Yes | Yes | [NotificationTemplate](#notificationtemplate8) | No  | Notification template.                  |
3029| isRemoveAllowed<sup>8+</sup> | Yes | No | boolean                                | No  | Whether the notification can be removed.                  |
3030| source<sup>8+</sup>   | Yes | No | number                                        | No  | Notification source.                  |
3031| distributedOption<sup>8+</sup>   | Yes | Yes | [DistributedOptions](#distributedoptions8)                 | No  | Option of distributed notification.         |
3032| deviceId<sup>8+</sup> | Yes | No | string                                        | No  | Device ID of the notification source.         |
3033| notificationFlags<sup>8+</sup> | Yes | No | [NotificationFlags](#notificationflags8)                    | No  | Notification flags.         |
3034
3035
3036## DistributedOptions<sup>8+</sup>
3037
3038**System capability**: SystemCapability.Notification.Notification
3039
3040| Name                  | Readable| Writable| Type           | Mandatory| Description                              |
3041| ---------------------- | ---- | ---- | -------------- | ---- | ---------------------------------- |
3042| isDistributed          | Yes  | Yes  | boolean        | No  | Whether the notification is a distributed notification.                 |
3043| supportDisplayDevices  | Yes  | Yes  | Array\<string> | Yes  | Types of the devices to which the notification can be synchronized.          |
3044| supportOperateDevices  | Yes  | Yes  | Array\<string> | No  | Devices on which notification can be enabled.               |
3045| remindType             | Yes  | No  | number         | No  | Notification reminder type.                   |
3046
3047
3048## NotificationSlot
3049
3050**System capability**: SystemCapability.Notification.Notification
3051
3052| Name                | Readable| Writable| Type                 | Mandatory| Description                                      |
3053| -------------------- | ---- | --- | --------------------- | ---- | ------------------------------------------ |
3054| type                 | Yes | Yes | [SlotType](#slottype) | Yes  | Slot type.                                  |
3055| level                | Yes | Yes | number                | No  | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
3056| desc                 | Yes | Yes | string                | No  | Notification slot description.                          |
3057| badgeFlag            | Yes | Yes | boolean               | No  | Whether to display the badge.                              |
3058| bypassDnd            | Yes | Yes | boolean               | No  | Whether to bypass the DND mode in the system.              |
3059| lockscreenVisibility | Yes | Yes | number                | No  | Mode for displaying the notification on the lock screen.                |
3060| vibrationEnabled     | Yes | Yes | boolean               | No  | Whether vibration is supported for the notification.                                |
3061| sound                | Yes | Yes | string                | No  | Notification alert tone.                                |
3062| lightEnabled         | Yes | Yes | boolean               | No  | Whether the indicator blinks for the notification.                                  |
3063| lightColor           | Yes | Yes | number                | No  | Indicator color of the notification.                                |
3064| vibrationValues      | Yes | Yes | Array\<number\>       | No  | Vibration mode of the notification.                              |
3065
3066
3067## NotificationSorting
3068
3069**System capability**: SystemCapability.Notification.Notification
3070
3071| Name    | Readable| Writable| Type                                 | Mandatory| Description        |
3072| -------- | ---- | --- | ------------------------------------- | ---- | ------------ |
3073| slot     | Yes | No | [NotificationSlot](#notificationslot) | Yes  | Notification slot content.|
3074| hashCode | Yes | No | string                                | Yes  | Unique ID of the notification.|
3075| ranking  | Yes | No | number                                | Yes  | Notification sequence number.|
3076
3077
3078## NotificationSortingMap
3079
3080**System capability**: SystemCapability.Notification.Notification
3081
3082| Name          | Readable| Writable| Type                                                        | Mandatory| Description            |
3083| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- |
3084| sortings       | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes  | Array of notification sorting information.|
3085| sortedHashCode | Yes | No | Array\<string\>                                              | Yes  | Array of unique notification IDs.|
3086
3087
3088## NotificationSubscribeInfo
3089
3090**System capability**: SystemCapability.Notification.Notification
3091
3092| Name       | Readable| Writable| Type           | Mandatory| Description                           |
3093| ----------- | --- | ---- | --------------- | ---- | ------------------------------- |
3094| bundleNames | Yes | Yes | Array\<string\> | No  | Bundle names of the applications whose notifications are to be subscribed to.|
3095| userId      | Yes | Yes | number          | No  | User whose notifications are to be subscribed to.   |
3096
3097
3098## NotificationTemplate<sup>8+</sup>
3099
3100**System capability**: SystemCapability.Notification.Notification
3101
3102| Name| Type              | Readable| Writable| Description      |
3103| ---- | ---------------------- | ---- | ---- | ---------- |
3104| name | string                 | Yes  | Yes  | Template name.|
3105| data | {[key:string]: Object} | Yes  | Yes  | Template data.|
3106
3107
3108## NotificationUserInput<sup>8+</sup>
3109
3110**System capability**: SystemCapability.Notification.Notification
3111
3112| Name    | Readable| Writable| Type  | Mandatory| Description                         |
3113| -------- | --- | ---- | ------ | ---- | ----------------------------- |
3114| inputKey | Yes | Yes | string | Yes  | Key to identify the user input.|
3115
3116
3117## DeviceRemindType<sup>8+</sup>
3118
3119**System capability**: SystemCapability.Notification.Notification
3120
3121| Name                | Value | Description                              |
3122| -------------------- | --- | --------------------------------- |
3123| IDLE_DONOT_REMIND    | 0   | The device is not in use. No notification is required.           |
3124| IDLE_REMIND          | 1   | The device is not in use.                |
3125| ACTIVE_DONOT_REMIND  | 2   | The device is in use. No notification is required.           |
3126| ACTIVE_REMIND        | 3   | The device is in use.                |
3127