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