1# @ohos.notification (Notification) (System API)
2
3The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status.
4
5> **NOTE**<br>
6>
7> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.notificationManager](js-apis-notificationManager.md).
8> 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.
9>
10> This topic describes only system APIs provided by the module. For details about its public APIs, see [Notification](./js-apis-notification.md).
11
12
13## Modules to Import
14
15```ts
16import Notification from '@ohos.notification';
17```
18
19## Notification.publish<sup>8+</sup>
20
21publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
22
23Publishes a notification to a specified user. This API uses an asynchronous callback to return the result.
24
25**System capability**: SystemCapability.Notification.Notification
26
27**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
28
29**System API**: This is a system API and cannot be called by third-party applications.
30
31**Parameters**
32
33| Name    | Type                                       | Mandatory| Description                                       |
34| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
35| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
36| userId   | number                                      | Yes  | User ID.                          |
37| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |
38
39**Example**
40
41```ts
42import NotificationManager from '@ohos.notificationManager';
43import Base from '@ohos.base';
44
45// publish callback
46let publishCallback = (err: Base.BusinessError) => {
47  if (err) {
48    console.error(`publish failed, code is ${err.code}`);
49  } else {
50    console.info("publish success");
51  }
52}
53// User ID
54let userId: number = 1;
55// NotificationRequest object
56let notificationRequest: NotificationManager.NotificationRequest = {
57  id: 1,
58  content: {
59    contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
60    normal: {
61      title: "test_title",
62      text: "test_text",
63      additionalText: "test_additionalText"
64    }
65  }
66};
67Notification.publish(notificationRequest, userId, publishCallback);
68```
69
70## Notification.publish<sup>8+</sup>
71
72publish(request: NotificationRequest, userId: number): Promise\<void\>
73
74Publishes a notification to a specified user. This API uses a promise to return the result.
75
76**System capability**: SystemCapability.Notification.Notification
77
78**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
79
80**System API**: This is a system API and cannot be called by third-party applications.
81
82**Parameters**
83
84| Name    |  Type                                       | Mandatory| Description                                       |
85| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
86| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
87| userId   | number                                      | Yes  | User ID.                          |
88
89**Return value**
90
91| Type    | Description        |
92| ------- |------------|
93| Promise\<void\> | Promise that returns no value.|
94
95**Example**
96
97```ts
98import NotificationManager from '@ohos.notificationManager';
99import Base from '@ohos.base';
100
101let notificationRequest: NotificationManager.NotificationRequest = {
102  id: 1,
103  content: {
104    contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
105    normal: {
106      title: "test_title",
107      text: "test_text",
108      additionalText: "test_additionalText"
109    }
110  }
111};
112
113let userId: number = 1;
114
115Notification.publish(notificationRequest, userId).then(() => {
116  console.info("publish success");
117}).catch((err: Base.BusinessError) => {
118  console.error(`publish failed, code is ${err}`);
119});
120```
121
122## Notification.addSlot
123
124addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
125
126Adds a notification slot. This API uses an asynchronous callback to return the result.
127
128**System capability**: SystemCapability.Notification.Notification
129
130**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
131
132**System API**: This is a system API and cannot be called by third-party applications.
133
134**Parameters**
135
136| Name    | Type                 | Mandatory| Description                |
137| -------- | --------------------- | ---- | -------------------- |
138| slot     | [NotificationSlot](./js-apis-notification.md#notificationslot)       | Yes  | Notification slot to add.|
139| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
140
141**Example**
142
143```ts
144import NotificationManager from '@ohos.notificationManager';
145import Base from '@ohos.base';
146
147// addSlot callback
148let addSlotCallBack = (err: Base.BusinessError) => {
149  if (err) {
150    console.info("addSlot failed " + JSON.stringify(err));
151  } else {
152    console.info("addSlot success");
153  }
154}
155// NotificationSlot object
156let notificationSlot: NotificationManager.NotificationSlot = {
157  type: Notification.SlotType.SOCIAL_COMMUNICATION
158};
159Notification.addSlot(notificationSlot, addSlotCallBack);
160```
161
162## Notification.addSlot
163
164addSlot(slot: NotificationSlot): Promise\<void\>
165
166Adds a notification slot. This API uses a promise to return the result.
167
168**System capability**: SystemCapability.Notification.Notification
169
170**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
171
172**System API**: This is a system API and cannot be called by third-party applications.
173
174**Parameters**
175
176| Name| Type            | Mandatory| Description                |
177| ---- | ---------------- | ---- | -------------------- |
178| slot | [NotificationSlot](./js-apis-notification.md#notificationslot) | Yes  | Notification slot to add.|
179
180**Return value**
181
182| Type    | Description        |
183| ------- |------------|
184| Promise\<void\> | Promise that returns no value.|
185
186**Example**
187
188```ts
189import NotificationManager from '@ohos.notificationManager';
190import Base from '@ohos.base';
191
192// NotificationSlot object
193let notificationSlot: NotificationManager.NotificationSlot = {
194    type: Notification.SlotType.SOCIAL_COMMUNICATION
195};
196Notification.addSlot(notificationSlot).then(() => {
197	console.info("addSlot success");
198}).catch((err: Base.BusinessError) => {
199  console.error(`addSlot failed, code is ${err}`);
200});
201```
202
203## Notification.addSlots
204
205addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
206
207Adds an array of notification slots. This API uses an asynchronous callback to return the result.
208
209**System capability**: SystemCapability.Notification.Notification
210
211**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
212
213**System API**: This is a system API and cannot be called by third-party applications.
214
215**Parameters**
216
217| Name    | Type                     | Mandatory| Description                    |
218| -------- | ------------------------- | ---- | ------------------------ |
219| slots    | Array\<[NotificationSlot](./js-apis-notification.md#notificationslot)\> | Yes  | Notification slots to add.|
220| callback | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |
221
222**Example**
223
224```ts
225import NotificationManager from '@ohos.notificationManager';
226import Base from '@ohos.base';
227
228// addSlots callback
229let addSlotsCallBack = (err: Base.BusinessError) => {
230  if (err) {
231    console.info("addSlots failed " + JSON.stringify(err));
232  } else {
233    console.info("addSlots success");
234  }
235}
236// NotificationSlot object
237let notificationSlot: NotificationManager.NotificationSlot = {
238  type: Notification.SlotType.SOCIAL_COMMUNICATION
239};
240// NotificationSlotArray object
241let notificationSlotArray: NotificationManager.NotificationSlot[] = new Array();
242notificationSlotArray[0] = notificationSlot;
243
244Notification.addSlots(notificationSlotArray, addSlotsCallBack);
245```
246
247## Notification.addSlots
248
249addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
250
251Adds an array of notification slots. This API uses a promise to return the result.
252
253**System capability**: SystemCapability.Notification.Notification
254
255**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
256
257**System API**: This is a system API and cannot be called by third-party applications.
258
259**Parameters**
260
261| Name | Type                     | Mandatory| Description                    |
262| ----- | ------------------------- | ---- | ------------------------ |
263| slots | Array\<[NotificationSlot](./js-apis-notification.md#notificationslot)\> | Yes  | Notification slots to add.|
264
265**Return value**
266
267| Type    | Description        |
268| ------- |------------|
269| Promise\<void\> | Promise that returns no value.|
270
271**Example**
272
273```ts
274import NotificationManager from '@ohos.notificationManager';
275import Base from '@ohos.base';
276
277// NotificationSlot object
278let notificationSlot: NotificationManager.NotificationSlot = {
279  type: Notification.SlotType.SOCIAL_COMMUNICATION
280};
281// NotificationSlotArray object
282let notificationSlotArray: NotificationManager.NotificationSlot[] = new Array();
283notificationSlotArray[0] = notificationSlot;
284
285Notification.addSlots(notificationSlotArray).then(() => {
286  console.info("addSlots success");
287}).catch((err: Base.BusinessError) => {
288  console.error(`addSlot failed, code is ${err}`);
289});
290```
291
292## Notification.subscribe
293
294subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\<void\>): void
295
296Subscribes to a notification with the subscription information specified. This API uses an asynchronous callback to return the result.
297
298**System capability**: SystemCapability.Notification.Notification
299
300**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
301
302**System API**: This is a system API and cannot be called by third-party applications.
303
304**Parameters**
305
306| Name      | Type                     | Mandatory| Description            |
307| ---------- | ------------------------- | ---- | ---------------- |
308| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber-sys.md#notificationsubscriber)    | Yes  | Notification subscriber.    |
309| info       | [NotificationSubscribeInfo](js-apis-inner-notification-notificationSubscribeInfo-sys.md#notificationsubscribeinfo) | Yes  | Notification subscription information.|
310| callback   | AsyncCallback\<void\>     | Yes  | Callback used to return the result.|
311
312**Example**
313
314```ts
315import Base from '@ohos.base';
316import NotificationSubscribe from '@ohos.notificationSubscribe';
317
318// subscribe callback
319let subscribeCallback = (err: Base.BusinessError) => {
320  if (err) {
321    console.info("subscribe failed " + JSON.stringify(err));
322  } else {
323    console.info("subscribe success");
324  }
325}
326let onConsumeCallback = (data: NotificationSubscribe.SubscribeCallbackData) => {
327  console.info("Consume callback: " + JSON.stringify(data));
328}
329let subscriber: NotificationSubscribe.NotificationSubscriber = {
330  onConsume: onConsumeCallback
331};
332let info: NotificationSubscribe.NotificationSubscribeInfo = {
333  bundleNames: ["bundleName1", "bundleName2"]
334};
335Notification.subscribe(subscriber, info, subscribeCallback);
336```
337
338## Notification.subscribe
339
340subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
341
342Subscribes to notifications of all applications under this user. This API uses an asynchronous callback to return the result.
343
344**System capability**: SystemCapability.Notification.Notification
345
346**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
347
348**System API**: This is a system API and cannot be called by third-party applications.
349
350**Parameters**
351
352| Name      | Type                  | Mandatory| Description            |
353| ---------- | ---------------------- | ---- | ---------------- |
354| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber-sys.md#notificationsubscriber) | Yes  | Notification subscriber.    |
355| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
356
357**Example**
358
359```ts
360import Base from '@ohos.base';
361import NotificationSubscribe from '@ohos.notificationSubscribe';
362
363let subscribeCallback = (err: Base.BusinessError) => {
364  if (err) {
365    console.info("subscribe failed " + JSON.stringify(err));
366  } else {
367    console.info("subscribe success");
368  }
369}
370function onConsumeCallback(data: NotificationSubscribe.SubscribeCallbackData) {
371  console.info("Consume callback: " + JSON.stringify(data));
372}
373let subscriber: NotificationSubscribe.NotificationSubscriber = {
374  onConsume: onConsumeCallback
375};
376Notification.subscribe(subscriber, subscribeCallback);
377```
378
379## Notification.subscribe
380
381subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise\<void\>
382
383Subscribes to a notification with the subscription information specified. This API uses a promise to return the result.
384
385**System capability**: SystemCapability.Notification.Notification
386
387**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
388
389**System API**: This is a system API and cannot be called by third-party applications.
390
391**Parameters**
392
393| Name      | Type                     | Mandatory| Description        |
394| ---------- | ------------------------- | ---- | ------------ |
395| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber-sys.md#notificationsubscriber)    | Yes  | Notification subscriber.|
396| info       | [NotificationSubscribeInfo](js-apis-inner-notification-notificationSubscribeInfo-sys.md#notificationsubscribeinfo) | No  | Notification subscription information. This parameter is left empty by default.  |
397
398**Return value**
399
400| Type    | Description        |
401| ------- |------------|
402| Promise\<void\> | Promise that returns no value.|
403
404**Example**
405
406```ts
407import Base from '@ohos.base';
408import NotificationSubscribe from '@ohos.notificationSubscribe';
409
410function onConsumeCallback(data: NotificationSubscribe.SubscribeCallbackData) {
411  console.info("Consume callback: " + JSON.stringify(data));
412}
413let subscriber: NotificationSubscribe.NotificationSubscriber = {
414  onConsume: onConsumeCallback
415};
416Notification.subscribe(subscriber).then(() => {
417  console.info("subscribe success");
418}).catch((err: Base.BusinessError) => {
419  console.error(`subscribe failed, code is ${err}`);
420});
421```
422
423## Notification.unsubscribe
424
425unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
426
427Unsubscribes from a notification. This API uses an asynchronous callback to return the result.
428
429**System capability**: SystemCapability.Notification.Notification
430
431**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
432
433**System API**: This is a system API and cannot be called by third-party applications.
434
435**Parameters**
436
437| Name      | Type                  | Mandatory| Description                |
438| ---------- | ---------------------- | ---- | -------------------- |
439| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber-sys.md#notificationsubscriber) | Yes  | Notification subscriber.        |
440| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
441
442**Example**
443
444```ts
445import Base from '@ohos.base';
446import NotificationSubscribe from '@ohos.notificationSubscribe';
447
448let unsubscribeCallback = (err: Base.BusinessError) => {
449  if (err) {
450    console.info("unsubscribe failed " + JSON.stringify(err));
451  } else {
452    console.info("unsubscribe success");
453  }
454}
455let onDisconnectCallback = () => {
456  console.info("subscribe disconnect");
457}
458let subscriber: NotificationSubscribe.NotificationSubscriber = {
459  onDisconnect: onDisconnectCallback
460};
461Notification.unsubscribe(subscriber, unsubscribeCallback);
462```
463
464## Notification.unsubscribe
465
466unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
467
468Unsubscribes from a notification. This API uses a promise to return the result.
469
470**System capability**: SystemCapability.Notification.Notification
471
472**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
473
474**System API**: This is a system API and cannot be called by third-party applications.
475
476**Parameters**
477
478| Name      | Type                  | Mandatory| Description        |
479| ---------- | ---------------------- | ---- | ------------ |
480| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber-sys.md#notificationsubscriber) | Yes  | Notification subscriber.|
481
482**Return value**
483
484| Type    | Description        |
485| ------- |------------|
486| Promise\<void\> | Promise that returns no value.|
487
488**Example**
489
490```ts
491import Base from '@ohos.base';
492import NotificationSubscribe from '@ohos.notificationSubscribe';
493
494function onDisconnectCallback() {
495  console.info("subscribe disconnect");
496}
497let subscriber: NotificationSubscribe.NotificationSubscriber = {
498  onDisconnect: onDisconnectCallback
499};
500Notification.unsubscribe(subscriber).then(() => {
501  console.info("unsubscribe success");
502}).catch((err: Base.BusinessError) => {
503  console.error(`unsubscribe failed, code is ${err}`);
504});
505```
506
507## Notification.enableNotification
508
509enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
510
511Sets whether to enable notification for a specified application. This API uses an asynchronous callback to return the result.
512
513**System capability**: SystemCapability.Notification.Notification
514
515**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
516
517**System API**: This is a system API and cannot be called by third-party applications.
518
519**Parameters**
520
521| Name    | Type                 | Mandatory| Description                |
522| -------- | --------------------- | ---- | -------------------- |
523| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.       |
524| enable   | boolean               | Yes  | Whether to enable notification.            |
525| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
526
527**Example**
528
529```ts
530import Base from '@ohos.base';
531
532let enableNotificationCallback = (err: Base.BusinessError) => {
533  if (err) {
534    console.info("enableNotification failed " + JSON.stringify(err));
535  } else {
536    console.info("enableNotification success");
537  }
538}
539let bundle: Notification.BundleOption = {
540  bundle: "bundleName1",
541};
542Notification.enableNotification(bundle, false, enableNotificationCallback);
543```
544
545## Notification.enableNotification
546
547enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\>
548
549Sets whether to enable notification for a specified application. This API uses a promise to return the result.
550
551**System capability**: SystemCapability.Notification.Notification
552
553**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
554
555**System API**: This is a system API and cannot be called by third-party applications.
556
557**Parameters**
558
559| Name  | Type        | Mandatory| Description      |
560| ------ | ------------ | ---- | ---------- |
561| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
562| enable | boolean      | Yes  | Whether to enable notification.  |
563
564**Return value**
565
566| Type    | Description        |
567| ------- |------------|
568| Promise\<void\> | Promise that returns no value.|
569
570**Example**
571
572```ts
573import Base from '@ohos.base';
574
575let bundle: Notification.BundleOption = {
576  bundle: "bundleName1",
577};
578Notification.enableNotification(bundle, false).then(() => {
579  console.info("enableNotification success");
580}).catch((err: Base.BusinessError) => {
581  console.error(`enableNotification failed, code is ${err}`);
582});
583
584```
585
586## Notification.isNotificationEnabled
587
588isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
589
590Checks whether notification is enabled for a specified application. This API uses an asynchronous callback to return the result.
591
592**System capability**: SystemCapability.Notification.Notification
593
594**System API**: This is a system API and cannot be called by third-party applications.
595
596**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
597
598**Parameters**
599
600| Name    | Type                 | Mandatory| Description                    |
601| -------- | --------------------- | ---- | ------------------------ |
602| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.           |
603| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
604
605**Example**
606
607```ts
608import Base from '@ohos.base';
609
610let isNotificationEnabledCallback = (err: Base.BusinessError, data: boolean) => {
611  if (err) {
612    console.info("isNotificationEnabled failed " + JSON.stringify(err));
613  } else {
614    console.info("isNotificationEnabled success");
615  }
616}
617let bundle: Notification.BundleOption = {
618  bundle: "bundleName1",
619};
620Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
621```
622
623## Notification.isNotificationEnabled
624
625isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
626
627Checks whether notification is enabled for a specified application. This API uses a promise to return the result.
628
629**System capability**: SystemCapability.Notification.Notification
630
631**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
632
633**System API**: This is a system API and cannot be called by third-party applications.
634
635**Parameters**
636
637| Name  | Type        | Mandatory| Description      |
638| ------ | ------------ | ---- | ---------- |
639| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
640
641**Return value**
642
643| Type              | Description                                               |
644| ------------------ | --------------------------------------------------- |
645| Promise\<boolean\> | Promise used to return the result.|
646
647**Example**
648
649```ts
650import Base from '@ohos.base';
651
652let bundle: Notification.BundleOption = {
653  bundle: "bundleName1",
654};
655Notification.isNotificationEnabled(bundle).then((data) => {
656  console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
657}).catch((err: Base.BusinessError) => {
658  console.error(`isNotificationEnabled failed, code is ${err}`);
659});
660```
661
662## Notification.isNotificationEnabled
663
664isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
665
666Checks whether notification is enabled for this application. This API uses an asynchronous callback to return the result.
667
668**System capability**: SystemCapability.Notification.Notification
669
670**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
671
672**System API**: This is a system API and cannot be called by third-party applications.
673
674**Parameters**
675
676| Name    | Type                 | Mandatory| Description                    |
677| -------- | --------------------- | ---- | ------------------------ |
678| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
679
680**Example**
681
682```ts
683import Base from '@ohos.base';
684
685let isNotificationEnabledCallback = (err: Base.BusinessError, data: boolean) => {
686  if (err) {
687    console.info("isNotificationEnabled failed " + JSON.stringify(err));
688  } else {
689    console.info("isNotificationEnabled success");
690  }
691}
692
693Notification.isNotificationEnabled(isNotificationEnabledCallback);
694```
695
696## Notification.isNotificationEnabled
697
698isNotificationEnabled(): Promise\<boolean\>
699
700Checks whether notification is enabled for this application. This API uses a promise to return the result.
701
702**System capability**: SystemCapability.Notification.Notification
703
704**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
705
706**System API**: This is a system API and cannot be called by third-party applications.
707
708**Parameters**
709
710| Name  | Type        | Mandatory| Description      |
711| ------ | ------------ | ---- | ---------- |
712| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
713
714**Return value**
715
716| Type                                                       | Description                                                        |
717| ----------------------------------------------------------- | ------------------------------------------------------------ |
718| Promise\<boolean\> | Promise used to return the result.|
719
720**Example**
721
722```ts
723import Base from '@ohos.base';
724
725Notification.isNotificationEnabled().then((data: boolean) => {
726  console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
727}).catch((err: Base.BusinessError) => {
728  console.error(`isNotificationEnabled failed, code is ${err}`);
729});
730```
731
732## Notification.displayBadge
733
734displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
735
736Sets whether to enable the notification badge for a specified application. This API uses an asynchronous callback to return the result.
737
738**System capability**: SystemCapability.Notification.Notification
739
740**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
741
742**System API**: This is a system API and cannot be called by third-party applications.
743
744**Parameters**
745
746| Name    | Type                 | Mandatory| Description                |
747| -------- | --------------------- | ---- | -------------------- |
748| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.          |
749| enable   | boolean               | Yes  | Whether to enable notification.            |
750| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
751
752**Example**
753
754```ts
755import Base from '@ohos.base';
756
757let displayBadgeCallback = (err: Base.BusinessError) => {
758  if (err) {
759    console.info("displayBadge failed " + JSON.stringify(err));
760  } else {
761    console.info("displayBadge success");
762  }
763}
764let bundle: Notification.BundleOption = {
765  bundle: "bundleName1",
766};
767Notification.displayBadge(bundle, false, displayBadgeCallback);
768```
769
770## Notification.displayBadge
771
772displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
773
774Sets whether to enable the notification badge for a specified application. This API uses a promise to return the result.
775
776**System capability**: SystemCapability.Notification.Notification
777
778**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
779
780**System API**: This is a system API and cannot be called by third-party applications.
781
782**Parameters**
783
784| Name  | Type        | Mandatory| Description      |
785| ------ | ------------ | ---- | ---------- |
786| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
787| enable | boolean      | Yes  | Whether to enable notification.  |
788
789**Return value**
790
791| Type    | Description        |
792| ------- |------------|
793| Promise\<void\> | Promise that returns no value.|
794
795**Example**
796
797```ts
798import Base from '@ohos.base';
799
800let bundle: Notification.BundleOption = {
801  bundle: "bundleName1",
802};
803Notification.displayBadge(bundle, false).then(() => {
804  console.info("displayBadge success");
805}).catch((err: Base.BusinessError) => {
806  console.error(`displayBadge failed, code is ${err}`);
807});
808```
809
810## Notification.isBadgeDisplayed
811
812isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
813
814Checks whether the notification badge is enabled for a specified application. This API uses an asynchronous callback to return the result.
815
816**System capability**: SystemCapability.Notification.Notification
817
818**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
819
820**System API**: This is a system API and cannot be called by third-party applications.
821
822**Parameters**
823
824| Name    | Type                 | Mandatory| Description                    |
825| -------- | --------------------- | ---- | ------------------------ |
826| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.              |
827| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
828
829**Example**
830
831```ts
832import Base from '@ohos.base';
833
834let isBadgeDisplayedCallback = (err: Base.BusinessError, data: boolean) => {
835  if (err) {
836    console.info("isBadgeDisplayed failed " + JSON.stringify(err));
837  } else {
838    console.info("isBadgeDisplayed success");
839  }
840}
841let bundle: Notification.BundleOption = {
842  bundle: "bundleName1",
843};
844Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
845```
846
847## Notification.isBadgeDisplayed
848
849isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
850
851Checks whether the notification badge is enabled for a specified application. This API uses a promise to return the result.
852
853**System capability**: SystemCapability.Notification.Notification
854
855**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
856
857**System API**: This is a system API and cannot be called by third-party applications.
858
859**Parameters**
860
861| Name  | Type        | Mandatory| Description      |
862| ------ | ------------ | ---- | ---------- |
863| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
864
865**Return value**
866
867| Type                                                       | Description                                                        |
868| ----------------------------------------------------------- | ------------------------------------------------------------ |
869| Promise\<boolean\> | Promise used to return the result.|
870
871**Example**
872
873```ts
874import Base from '@ohos.base';
875
876let bundle: Notification.BundleOption = {
877  bundle: "bundleName1",
878};
879Notification.isBadgeDisplayed(bundle).then((data) => {
880  console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
881}).catch((err: Base.BusinessError) => {
882  console.error(`isBadgeDisplayed failed, code is ${err}`);
883});
884```
885
886## Notification.setSlotByBundle
887
888setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
889
890Sets the notification slot for a specified application. This API uses an asynchronous callback to return the result.
891
892**System capability**: SystemCapability.Notification.Notification
893
894**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
895
896**System API**: This is a system API and cannot be called by third-party applications.
897
898**Parameters**
899
900| Name    | Type                 | Mandatory| Description                |
901| -------- | --------------------- | ---- | -------------------- |
902| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.          |
903| slot     | [NotificationSlot](./js-apis-notification.md#notificationslot)      | Yes  | Notification slot.            |
904| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
905
906**Example**
907
908```ts
909import Base from '@ohos.base';
910import NotificationManager from '@ohos.notificationManager';
911
912let setSlotByBundleCallback = (err: Base.BusinessError) => {
913  if (err) {
914    console.info("setSlotByBundle failed " + JSON.stringify(err));
915  } else {
916    console.info("setSlotByBundle success");
917  }
918}
919let bundle: Notification.BundleOption = {
920  bundle: "bundleName1",
921};
922let notificationSlot: NotificationManager.NotificationSlot = {
923  type: Notification.SlotType.SOCIAL_COMMUNICATION
924};
925Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
926```
927
928## Notification.setSlotByBundle
929
930setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
931
932Sets the notification slot for a specified application. This API uses a promise to return the result.
933
934**System capability**: SystemCapability.Notification.Notification
935
936**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
937
938**System API**: This is a system API and cannot be called by third-party applications.
939
940**Parameters**
941
942| Name  | Type        | Mandatory| Description      |
943| ------ | ------------ | ---- | ---------- |
944| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
945| slot   | [NotificationSlot](./js-apis-notification.md#notificationslot) | Yes  | Notification slot.|
946
947**Return value**
948
949| Type    | Description        |
950| ------- |------------|
951| Promise\<void\> | Promise that returns no value.|
952
953**Example**
954
955```ts
956import Base from '@ohos.base';
957import NotificationManager from '@ohos.notificationManager';
958
959let bundle: Notification.BundleOption = {
960  bundle: "bundleName1",
961};
962let notificationSlot: NotificationManager.NotificationSlot = {
963  type: Notification.SlotType.SOCIAL_COMMUNICATION
964};
965Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
966  console.info("setSlotByBundle success");
967}).catch((err: Base.BusinessError) => {
968  console.error(`setSlotByBundle failed, code is ${err}`);
969});
970```
971
972## Notification.getSlotsByBundle
973
974getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
975
976Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
977
978**System capability**: SystemCapability.Notification.Notification
979
980**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
981
982**System API**: This is a system API and cannot be called by third-party applications.
983
984**Parameters**
985
986| Name    | Type                                    | Mandatory| Description                |
987| -------- | ---------------------------------------- | ---- | -------------------- |
988| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)                             | Yes  | Bundle information of the application.          |
989| callback | AsyncCallback\<Array\<[NotificationSlot](./js-apis-notification.md#notificationslot)>> | Yes  | Callback used to return the result.|
990
991**Example**
992
993```ts
994import Base from '@ohos.base';
995import NotificationManager from '@ohos.notificationManager';
996
997let getSlotsByBundleCallback = (err: Base.BusinessError, data: NotificationManager.NotificationSlot[]) => {
998  if (err) {
999    console.info("getSlotsByBundle failed " + JSON.stringify(err));
1000  } else {
1001    console.info("getSlotsByBundle success");
1002  }
1003}
1004let bundle: Notification.BundleOption = {
1005  bundle: "bundleName1",
1006};
1007Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
1008```
1009
1010## Notification.getSlotsByBundle
1011
1012getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
1013
1014Obtains the notification slots of a specified application. This API uses a promise to return the result.
1015
1016**System capability**: SystemCapability.Notification.Notification
1017
1018**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1019
1020**System API**: This is a system API and cannot be called by third-party applications.
1021
1022**Parameters**
1023
1024| Name  | Type        | Mandatory| Description      |
1025| ------ | ------------ | ---- | ---------- |
1026| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
1027
1028**Return value**
1029
1030| Type                                                       | Description                                                        |
1031| ----------------------------------------------------------- | ------------------------------------------------------------ |
1032| Promise\<Array\<[NotificationSlot](./js-apis-notification.md#notificationslot)>> | Promise used to return the result.|
1033
1034**Example**
1035
1036```ts
1037import Base from '@ohos.base';
1038import NotificationManager from '@ohos.notificationManager';
1039
1040let bundle: Notification.BundleOption = {
1041  bundle: "bundleName1",
1042};
1043Notification.getSlotsByBundle(bundle).then((data: NotificationManager.NotificationSlot[]) => {
1044  console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
1045}).catch((err: Base.BusinessError) => {
1046  console.error(`getSlotsByBundle failed, code is ${err}`);
1047});
1048```
1049
1050## Notification.getSlotNumByBundle
1051
1052getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
1053
1054Obtains the number of notification slots of a specified application. This API uses an asynchronous callback to return the result.
1055
1056**System capability**: SystemCapability.Notification.Notification
1057
1058**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1059
1060**System API**: This is a system API and cannot be called by third-party applications.
1061
1062**Parameters**
1063
1064| Name    | Type                     | Mandatory| Description                  |
1065| -------- | ------------------------- | ---- | ---------------------- |
1066| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)              | Yes  | Bundle information of the application.            |
1067| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
1068
1069**Example**
1070
1071```ts
1072import Base from '@ohos.base';
1073import NotificationManager from '@ohos.notificationManager';
1074
1075let getSlotNumByBundleCallback = (err: Base.BusinessError, data: number) => {
1076  if (err) {
1077    console.info("getSlotNumByBundle failed " + JSON.stringify(err));
1078  } else {
1079    console.info("getSlotNumByBundle success");
1080  }
1081}
1082let bundle: Notification.BundleOption = {
1083  bundle: "bundleName1",
1084};
1085Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
1086```
1087
1088## Notification.getSlotNumByBundle
1089
1090getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
1091
1092Obtains the number of notification slots of a specified application. This API uses a promise to return the result.
1093
1094**System capability**: SystemCapability.Notification.Notification
1095
1096**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1097
1098**System API**: This is a system API and cannot be called by third-party applications.
1099
1100**Parameters**
1101
1102| Name  | Type        | Mandatory| Description      |
1103| ------ | ------------ | ---- | ---------- |
1104| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.|
1105
1106**Return value**
1107
1108| Type                                                       | Description                                                        |
1109| ----------------------------------------------------------- | ------------------------------------------------------------ |
1110| Promise\<number\> | Promise used to return the result.|
1111
1112**Example**
1113
1114```ts
1115import Base from '@ohos.base';
1116import NotificationManager from '@ohos.notificationManager';
1117
1118let bundle: Notification.BundleOption = {
1119  bundle: "bundleName1",
1120};
1121Notification.getSlotNumByBundle(bundle).then((data: number) => {
1122  console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
1123}).catch((err: Base.BusinessError) => {
1124  console.error(`getSlotNumByBundle failed, code is ${err}`);
1125});
1126```
1127
1128## Notification.remove
1129
1130remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void
1131
1132Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result.
1133
1134**System capability**: SystemCapability.Notification.Notification
1135
1136**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1137
1138**System API**: This is a system API and cannot be called by third-party applications.
1139
1140**Parameters**
1141
1142| Name           | Type                               | Mandatory| Description                |
1143| --------------- |   ----------------------------------| ---- | -------------------- |
1144| bundle          | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)       | Yes  | Bundle information of the application.          |
1145| notificationKey | [NotificationKey](./js-apis-notification.md#notificationkeydeprecated) | Yes  | Notification key.            |
1146| reason          | [RemoveReason](#removereason-deprecated)      | Yes  | Reason for deleting a notification.        |
1147| callback        | AsyncCallback\<void\>               | Yes  | Callback used to return the result.|
1148
1149**Example**
1150
1151```ts
1152import Base from '@ohos.base';
1153
1154let removeCallback = (err: Base.BusinessError) => {
1155  if (err) {
1156    console.info("remove failed " + JSON.stringify(err));
1157  } else {
1158    console.info("remove success");
1159  }
1160}
1161let bundle: Notification.BundleOption = {
1162  bundle: "bundleName1",
1163};
1164let notificationKey: Notification.NotificationKey = {
1165  id: 0,
1166  label: "label",
1167};
1168let reason: Notification.RemoveReason = Notification.RemoveReason.CLICK_REASON_REMOVE;
1169Notification.remove(bundle, notificationKey, reason, removeCallback);
1170```
1171
1172## Notification.remove
1173
1174remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason): Promise\<void\>
1175
1176Removes a notification for a specified bundle. This API uses a promise to return the result.
1177
1178**System capability**: SystemCapability.Notification.Notification
1179
1180**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1181
1182**System API**: This is a system API and cannot be called by third-party applications.
1183
1184**Parameters**
1185
1186| Name           | Type           | Mandatory| Description      |
1187| --------------- | --------------- | ---- | ---------- |
1188| bundle          | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)    | Yes  | Bundle information of the application.|
1189| notificationKey | [NotificationKey](./js-apis-notification.md#notificationkeydeprecated) | Yes  | Notification key.  |
1190| reason          | [RemoveReason](#removereason-deprecated) | Yes  | Reason for deleting a notification.        |
1191
1192**Return value**
1193
1194| Type    | Description        |
1195| ------- |------------|
1196| Promise\<void\> | Promise that returns no value.|
1197
1198**Example**
1199
1200```ts
1201import Base from '@ohos.base';
1202
1203let bundle: Notification.BundleOption = {
1204  bundle: "bundleName1",
1205};
1206let notificationKey: Notification.NotificationKey = {
1207  id: 0,
1208  label: "label",
1209};
1210let reason: Notification.RemoveReason = Notification.RemoveReason.CLICK_REASON_REMOVE;
1211Notification.remove(bundle, notificationKey, reason).then(() => {
1212  console.info("remove success");
1213}).catch((err: Base.BusinessError) => {
1214  console.error(`remove failed, code is ${err}`);
1215});
1216```
1217
1218## Notification.remove
1219
1220remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void
1221
1222Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result.
1223
1224**System capability**: SystemCapability.Notification.Notification
1225
1226**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1227
1228**System API**: This is a system API and cannot be called by third-party applications.
1229
1230**Parameters**
1231
1232| Name    | Type                 | Mandatory| Description                |
1233| -------- | --------------------- | ---- | -------------------- |
1234| hashCode | string                | Yes  | Unique notification ID. It is the value of **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](#subscribecallbackdata) of the [onConsume](js-apis-inner-notification-notificationSubscriber-sys.md#onconsume) callback.|
1235| reason   | [RemoveReason](#removereason-deprecated) | Yes  | Reason for deleting a notification.        |
1236| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1237
1238**Example**
1239
1240```ts
1241import Base from '@ohos.base';
1242
1243let hashCode: string = 'hashCode';
1244
1245let removeCallback = (err: Base.BusinessError) => {
1246  if (err) {
1247    console.info("remove failed " + JSON.stringify(err));
1248  } else {
1249    console.info("remove success");
1250  }
1251}
1252let reason: Notification.RemoveReason = Notification.RemoveReason.CANCEL_REASON_REMOVE;
1253Notification.remove(hashCode, reason, removeCallback);
1254```
1255
1256## Notification.remove
1257
1258remove(hashCode: string, reason: RemoveReason): Promise\<void\>
1259
1260Removes a notification for a specified bundle. This API uses a promise to return the result.
1261
1262**System capability**: SystemCapability.Notification.Notification
1263
1264**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1265
1266**System API**: This is a system API and cannot be called by third-party applications.
1267
1268**Parameters**
1269
1270| Name    | Type      | Mandatory| Description      |
1271| -------- | ---------- | ---- | ---------- |
1272| hashCode | string | Yes  | Unique notification ID.|
1273| reason   | [RemoveReason](#removereason-deprecated) | Yes  | Reason for deleting a notification.        |
1274
1275**Return value**
1276
1277| Type    | Description        |
1278| ------- |------------|
1279| Promise\<void\> | Promise that returns no value.|
1280
1281**Example**
1282
1283```ts
1284import Base from '@ohos.base';
1285
1286let hashCode: string = 'hashCode';
1287let reason: Notification.RemoveReason = Notification.RemoveReason.CLICK_REASON_REMOVE;
1288Notification.remove(hashCode, reason).then(() => {
1289  console.info("remove success");
1290}).catch((err: Base.BusinessError) => {
1291  console.error(`remove failed, code is ${err}`);
1292});
1293```
1294
1295## Notification.removeAll
1296
1297removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
1298
1299Removes all notifications for a specified application. This API uses an asynchronous callback to return the result.
1300
1301**System capability**: SystemCapability.Notification.Notification
1302
1303**System API**: This is a system API and cannot be called by third-party applications.
1304
1305**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1306
1307**Parameters**
1308
1309| Name    | Type                 | Mandatory| Description                        |
1310| -------- | --------------------- | ---- | ---------------------------- |
1311| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.                  |
1312| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1313
1314**Example**
1315
1316```ts
1317import Base from '@ohos.base';
1318
1319let removeAllCallback = (err: Base.BusinessError) => {
1320  if (err) {
1321    console.info("removeAll failed " + JSON.stringify(err));
1322  } else {
1323    console.info("removeAll success");
1324  }
1325}
1326let bundle: Notification.BundleOption = {
1327  bundle: "bundleName1",
1328};
1329Notification.removeAll(bundle, removeAllCallback);
1330```
1331
1332## Notification.removeAll
1333
1334removeAll(callback: AsyncCallback\<void\>): void
1335
1336Removes all notifications. This API uses an asynchronous callback to return the result.
1337
1338**System capability**: SystemCapability.Notification.Notification
1339
1340**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1341
1342**System API**: This is a system API and cannot be called by third-party applications.
1343
1344**Parameters**
1345
1346| Name    | Type                 | Mandatory| Description                |
1347| -------- | --------------------- | ---- | -------------------- |
1348| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1349
1350**Example**
1351
1352```ts
1353import Base from '@ohos.base';
1354
1355let removeAllCallback = (err: Base.BusinessError) => {
1356  if (err) {
1357    console.info("removeAll failed " + JSON.stringify(err));
1358  } else {
1359    console.info("removeAll success");
1360  }
1361}
1362
1363Notification.removeAll(removeAllCallback);
1364```
1365
1366## Notification.removeAll
1367
1368removeAll(bundle?: BundleOption): Promise\<void\>
1369
1370Removes all notifications for a specified application. This API uses a promise to return the result.
1371
1372**System capability**: SystemCapability.Notification.Notification
1373
1374**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1375
1376**System API**: This is a system API and cannot be called by third-party applications.
1377
1378**Parameters**
1379
1380| Name  | Type        | Mandatory| Description      |
1381| ------ | ------------ | ---- | ---------- |
1382| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | No  | Bundle information of the application. By default, this parameter is left empty, indicating that all notifications will be removed.|
1383
1384**Return value**
1385
1386| Type    | Description        |
1387| ------- |------------|
1388| Promise\<void\> | Promise that returns no value.|
1389
1390**Example**
1391
1392```ts
1393import Base from '@ohos.base';
1394
1395// If no application is specified, notifications of all applications are deleted.
1396Notification.removeAll().then(() => {
1397  console.info("removeAll success");
1398}).catch((err: Base.BusinessError) => {
1399  console.error(`removeAll failed, code is ${err}`);
1400});
1401```
1402
1403## Notification.removeAll<sup>8+</sup>
1404
1405removeAll(userId: number, callback: AsyncCallback\<void>): void
1406
1407Removes all notifications for a specified user. This API uses an asynchronous callback to return the result.
1408
1409**System capability**: SystemCapability.Notification.Notification
1410
1411**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1412
1413**System API**: This is a system API and cannot be called by third-party applications.
1414
1415**Parameters**
1416
1417| Name  | Type        | Mandatory| Description      |
1418| ------ | ------------ | ---- | ---------- |
1419| userId | number | Yes  | User ID.|
1420| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1421
1422**Example**
1423
1424```ts
1425import Base from '@ohos.base';
1426
1427function removeAllCallback(err: Base.BusinessError) {
1428  if (err) {
1429    console.info("removeAll failed " + JSON.stringify(err));
1430  } else {
1431    console.info("removeAll success");
1432  }
1433}
1434
1435let userId: number = 1;
1436Notification.removeAll(userId, removeAllCallback);
1437```
1438
1439## Notification.removeAll<sup>8+</sup>
1440
1441removeAll(userId: number): Promise\<void>
1442
1443Removes all notifications for a specified user. This API uses a promise to return the result.
1444
1445**System capability**: SystemCapability.Notification.Notification
1446
1447**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1448
1449**System API**: This is a system API and cannot be called by third-party applications.
1450
1451**Parameters**
1452
1453| Name  | Type        | Mandatory| Description      |
1454| ------ | ------------ | ---- | ---------- |
1455| userId | number | Yes  | User ID.|
1456
1457**Example**
1458
1459```ts
1460import Base from '@ohos.base';
1461
1462let userId: number = 1;
1463Notification.removeAll(userId).then(() => {
1464  console.info("removeAll success");
1465}).catch((err: Base.BusinessError) => {
1466  console.error(`removeAll failed, code is ${err}`);
1467});
1468```
1469
1470
1471## Notification.getAllActiveNotifications
1472
1473getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
1474
1475Obtains all active notifications. This API uses an asynchronous callback to return the result.
1476
1477**System capability**: SystemCapability.Notification.Notification
1478
1479**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1480
1481**System API**: This is a system API and cannot be called by third-party applications.
1482
1483**Parameters**
1484
1485| Name    | Type                                                        | Mandatory| Description                |
1486| -------- | ------------------------------------------------------------ | ---- | -------------------- |
1487| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | Yes  | Callback used to return the result.|
1488
1489**Example**
1490
1491```ts
1492import Base from '@ohos.base';
1493import NotificationManager from '@ohos.notificationManager';
1494
1495function getAllActiveNotificationsCallback(err: Base.BusinessError, data: NotificationManager.NotificationRequest[]) {
1496  if (err) {
1497    console.info("getAllActiveNotifications failed " + JSON.stringify(err));
1498  } else {
1499    console.info("getAllActiveNotifications success");
1500  }
1501}
1502
1503Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
1504```
1505
1506## Notification.getAllActiveNotifications
1507
1508getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>>
1509
1510Obtains all active notifications. This API uses a promise to return the result.
1511
1512**System capability**: SystemCapability.Notification.Notification
1513
1514**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1515
1516**System API**: This is a system API and cannot be called by third-party applications.
1517
1518**Return value**
1519
1520| Type                                                       | Description                                                        |
1521| ----------------------------------------------------------- | ------------------------------------------------------------ |
1522| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | Promise used to return the result.|
1523
1524**Example**
1525
1526```ts
1527import Base from '@ohos.base';
1528import NotificationManager from '@ohos.notificationManager';
1529
1530Notification.getAllActiveNotifications().then((data: NotificationManager.NotificationRequest[]) => {
1531  console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
1532}).catch((err: Base.BusinessError) => {
1533  console.error(`getAllActiveNotifications failed, code is ${err}`);
1534});
1535```
1536
1537## Notification.removeGroupByBundle<sup>8+</sup>
1538
1539removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
1540
1541Removes notifications under a notification group of a specified application. This API uses an asynchronous callback to return the result.
1542
1543**System capability**: SystemCapability.Notification.Notification
1544
1545**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1546
1547**System API**: This is a system API and cannot be called by third-party applications.
1548
1549**Parameters**
1550
1551| Name     | Type                 | Mandatory| Description                        |
1552| --------- | --------------------- | ---- | ---------------------------- |
1553| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.                  |
1554| groupName | string                | Yes  | Name of the notification group.              |
1555| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1556
1557**Example**
1558
1559```ts
1560import Base from '@ohos.base';
1561
1562let removeGroupByBundleCallback = (err: Base.BusinessError) => {
1563  if (err) {
1564    console.info("removeGroupByBundle failed " + JSON.stringify(err));
1565  } else {
1566    console.info("removeGroupByBundle success");
1567  }
1568}
1569
1570let bundleOption: Notification.BundleOption = {bundle: "Bundle"};
1571let groupName: string = "GroupName";
1572
1573Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
1574```
1575
1576## Notification.removeGroupByBundle<sup>8+</sup>
1577
1578removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
1579
1580Removes notifications under a notification group of a specified application. This API uses a promise to return the result.
1581
1582**System capability**: SystemCapability.Notification.Notification
1583
1584**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1585
1586**System API**: This is a system API and cannot be called by third-party applications.
1587
1588**Parameters**
1589
1590| Name     | Type        | Mandatory| Description          |
1591| --------- | ------------ | ---- | -------------- |
1592| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.    |
1593| groupName | string       | Yes  | Name of the notification group.|
1594
1595**Return value**
1596
1597| Type    | Description        |
1598| ------- |------------|
1599| Promise\<void\> | Promise that returns no value.|
1600
1601**Example**
1602
1603```ts
1604import Base from '@ohos.base';
1605
1606let bundleOption: Notification.BundleOption = {bundle: "Bundle"};
1607let groupName: string = "GroupName";
1608Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
1609  console.info("removeGroupByBundle success");
1610}).catch((err: Base.BusinessError) => {
1611  console.error(`removeGroupByBundle failed, code is ${err}`);
1612});
1613```
1614
1615## Notification.setDoNotDisturbDate<sup>8+</sup>
1616
1617setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
1618
1619Sets the DND time. This API uses an asynchronous callback to return the result.
1620
1621**System capability**: SystemCapability.Notification.Notification
1622
1623**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1624
1625**System API**: This is a system API and cannot be called by third-party applications.
1626
1627**Parameters**
1628
1629| Name    | Type                 | Mandatory| Description                  |
1630| -------- | --------------------- | ---- | ---------------------- |
1631| date     | [DoNotDisturbDate](#donotdisturbdate8-deprecated)      | Yes  | DND time to set.        |
1632| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1633
1634**Example**
1635
1636```ts
1637import Base from '@ohos.base';
1638
1639let setDoNotDisturbDateCallback = (err: Base.BusinessError) => {
1640  if (err) {
1641    console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
1642  } else {
1643    console.info("setDoNotDisturbDate success");
1644  }
1645}
1646
1647let doNotDisturbDate: Notification.DoNotDisturbDate = {
1648  type: Notification.DoNotDisturbType.TYPE_ONCE,
1649  begin: new Date(),
1650  end: new Date(2021, 11, 15, 18, 0)
1651};
1652
1653Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
1654```
1655
1656## Notification.setDoNotDisturbDate<sup>8+</sup>
1657
1658setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
1659
1660Sets the DND time. This API uses a promise to return the result.
1661
1662**System capability**: SystemCapability.Notification.Notification
1663
1664**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1665
1666**System API**: This is a system API and cannot be called by third-party applications.
1667
1668**Parameters**
1669
1670| Name| Type            | Mandatory| Description          |
1671| ---- | ---------------- | ---- | -------------- |
1672| date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes  | DND time to set.|
1673
1674**Return value**
1675
1676| Type    | Description        |
1677| ------- |------------|
1678| Promise\<void\> | Promise that returns no value.|
1679
1680**Example**
1681
1682```ts
1683import Base from '@ohos.base';
1684
1685let doNotDisturbDate: Notification.DoNotDisturbDate = {
1686    type: Notification.DoNotDisturbType.TYPE_ONCE,
1687    begin: new Date(),
1688    end: new Date(2021, 11, 15, 18, 0)
1689};
1690Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
1691	console.info("setDoNotDisturbDate success");
1692}).catch((err: Base.BusinessError) => {
1693  console.error(`setDoNotDisturbDate failed, code is ${err}`);
1694});
1695```
1696
1697
1698## Notification.setDoNotDisturbDate<sup>8+</sup>
1699
1700setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void
1701
1702Sets the DND time for a specified user. This API uses an asynchronous callback to return the result.
1703
1704**System capability**: SystemCapability.Notification.Notification
1705
1706**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1707
1708**System API**: This is a system API and cannot be called by third-party applications.
1709
1710**Parameters**
1711
1712| Name    | Type                 | Mandatory| Description                  |
1713| -------- | --------------------- | ---- | ---------------------- |
1714| date     | [DoNotDisturbDate](#donotdisturbdate8-deprecated)      | Yes  | DND time to set.        |
1715| userId   | number                | Yes  | ID of the user for whom you want to set the DND time.|
1716| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
1717
1718**Example**
1719
1720```ts
1721import Base from '@ohos.base';
1722
1723let setDoNotDisturbDateCallback = (err: Base.BusinessError) => {
1724  if (err) {
1725    console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
1726  } else {
1727    console.info("setDoNotDisturbDate success");
1728  }
1729}
1730
1731let doNotDisturbDate: Notification.DoNotDisturbDate = {
1732  type: Notification.DoNotDisturbType.TYPE_ONCE,
1733  begin: new Date(),
1734  end: new Date(2021, 11, 15, 18, 0)
1735};
1736
1737let userId: number = 1;
1738Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
1739```
1740
1741## Notification.setDoNotDisturbDate<sup>8+</sup>
1742
1743setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
1744
1745Sets the DND time for a specified user. This API uses a promise to return the result.
1746
1747**System capability**: SystemCapability.Notification.Notification
1748
1749**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1750
1751**System API**: This is a system API and cannot be called by third-party applications.
1752
1753**Parameters**
1754
1755| Name  | Type            | Mandatory| Description          |
1756| ------ | ---------------- | ---- | -------------- |
1757| date   | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes  | DND time to set.|
1758| userId | number           | Yes  | ID of the user for whom you want to set the DND time.|
1759
1760**Return value**
1761
1762| Type    | Description        |
1763| ------- |------------|
1764| Promise\<void\> | Promise that returns no value.|
1765
1766**Example**
1767
1768```ts
1769import Base from '@ohos.base';
1770
1771let doNotDisturbDate: Notification.DoNotDisturbDate = {
1772  type: Notification.DoNotDisturbType.TYPE_ONCE,
1773  begin: new Date(),
1774  end: new Date(2021, 11, 15, 18, 0)
1775};
1776
1777let userId: number = 1;
1778
1779Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
1780  console.info("setDoNotDisturbDate success");
1781}).catch((err: Base.BusinessError) => {
1782  console.error(`setDoNotDisturbDate failed, code is ${err}`);
1783});
1784```
1785
1786
1787## Notification.getDoNotDisturbDate<sup>8+</sup>
1788
1789getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
1790
1791Obtains the DND time. This API uses an asynchronous callback to return the result.
1792
1793**System capability**: SystemCapability.Notification.Notification
1794
1795**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1796
1797**System API**: This is a system API and cannot be called by third-party applications.
1798
1799**Parameters**
1800
1801| Name    | Type                             | Mandatory| Description                  |
1802| -------- | --------------------------------- | ---- | ---------------------- |
1803| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Yes  | Callback used to return the result.|
1804
1805**Example**
1806
1807```ts
1808import Base from '@ohos.base';
1809
1810let getDoNotDisturbDateCallback = (err: Base.BusinessError, data: Notification.DoNotDisturbDate) => {
1811  if (err) {
1812    console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
1813  } else {
1814    console.info("getDoNotDisturbDate success");
1815  }
1816}
1817
1818Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
1819```
1820
1821## Notification.getDoNotDisturbDate<sup>8+</sup>
1822
1823getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
1824
1825Obtains the DND time. This API uses a promise to return the result.
1826
1827**System capability**: SystemCapability.Notification.Notification
1828
1829**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1830
1831**System API**: This is a system API and cannot be called by third-party applications.
1832
1833**Return value**
1834
1835| Type                                             | Description                                     |
1836| ------------------------------------------------- | ----------------------------------------- |
1837| Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.|
1838
1839**Example**
1840
1841```ts
1842import Base from '@ohos.base';
1843
1844Notification.getDoNotDisturbDate().then((data: Notification.DoNotDisturbDate) => {
1845  console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
1846}).catch((err: Base.BusinessError) => {
1847  console.error(`getDoNotDisturbDate failed, code is ${err}`);
1848});
1849```
1850
1851
1852## Notification.getDoNotDisturbDate<sup>8+</sup>
1853
1854getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
1855
1856Obtains the DND time of a specified user. This API uses an asynchronous callback to return the result.
1857
1858**System capability**: SystemCapability.Notification.Notification
1859
1860**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1861
1862**System API**: This is a system API and cannot be called by third-party applications.
1863
1864**Parameters**
1865
1866| Name    | Type                             | Mandatory| Description                  |
1867| -------- | --------------------------------- | ---- | ---------------------- |
1868| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Yes  | Callback used to return the result.|
1869| userId   | number                            | Yes  | User ID.|
1870
1871**Example**
1872
1873```ts
1874import Base from '@ohos.base';
1875
1876let getDoNotDisturbDateCallback = (err: Base.BusinessError, data: Notification.DoNotDisturbDate) => {
1877  if (err) {
1878    console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
1879  } else {
1880    console.info("getDoNotDisturbDate success");
1881  }
1882}
1883
1884let userId: number = 1;
1885
1886Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
1887```
1888
1889## Notification.getDoNotDisturbDate<sup>8+</sup>
1890
1891getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
1892
1893Obtains the DND time of a specified user. This API uses a promise to return the result.
1894
1895**System capability**: SystemCapability.Notification.Notification
1896
1897**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1898
1899**System API**: This is a system API and cannot be called by third-party applications.
1900
1901**Parameters**
1902
1903| Name    | Type                             | Mandatory| Description                  |
1904| -------- | --------------------------------- | ---- | ---------------------- |
1905| userId   | number                            | Yes  | User ID.|
1906
1907**Return value**
1908
1909| Type                                             | Description                                     |
1910| ------------------------------------------------- | ----------------------------------------- |
1911| Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.|
1912
1913**Example**
1914
1915```ts
1916import Base from '@ohos.base';
1917
1918let userId: number = 1;
1919
1920Notification.getDoNotDisturbDate(userId).then((data: Notification.DoNotDisturbDate) => {
1921  console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
1922}).catch((err: Base.BusinessError) => {
1923  console.error(`getDoNotDisturbDate failed, code is ${err}`);
1924});
1925```
1926
1927
1928## Notification.supportDoNotDisturbMode<sup>8+</sup>
1929
1930supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
1931
1932Checks whether DND mode is supported. This API uses an asynchronous callback to return the result.
1933
1934**System capability**: SystemCapability.Notification.Notification
1935
1936**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1937
1938**System API**: This is a system API and cannot be called by third-party applications.
1939
1940**Parameters**
1941
1942| Name    | Type                    | Mandatory| Description                            |
1943| -------- | ------------------------ | ---- | -------------------------------- |
1944| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
1945
1946**Example**
1947
1948```ts
1949import Base from '@ohos.base';
1950
1951let supportDoNotDisturbModeCallback = (err: Base.BusinessError, data: boolean) => {
1952  if (err) {
1953    console.info("supportDoNotDisturbMode failed " + JSON.stringify(err));
1954  } else {
1955    console.info("supportDoNotDisturbMode success");
1956  }
1957}
1958
1959Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
1960```
1961
1962## Notification.supportDoNotDisturbMode<sup>8+</sup>
1963
1964supportDoNotDisturbMode(): Promise\<boolean\>
1965
1966Checks whether DND mode is supported. This API uses a promise to return the result.
1967
1968**System capability**: SystemCapability.Notification.Notification
1969
1970**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
1971
1972**System API**: This is a system API and cannot be called by third-party applications.
1973
1974**Return value**
1975
1976| Type                                                       | Description                                                        |
1977| ----------------------------------------------------------- | ------------------------------------------------------------ |
1978| Promise\<boolean\> | Promise used to return the result.|
1979
1980**Example**
1981
1982```ts
1983import Base from '@ohos.base';
1984
1985Notification.supportDoNotDisturbMode().then((data: boolean) => {
1986  console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
1987}).catch((err: Base.BusinessError) => {
1988  console.error(`supportDoNotDisturbMode failed, code is ${err}`);
1989});
1990```
1991
1992## Notification.enableDistributed<sup>8+</sup>
1993
1994enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void
1995
1996Sets whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.
1997
1998**System capability**: SystemCapability.Notification.Notification
1999
2000**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2001
2002**System API**: This is a system API and cannot be called by third-party applications.
2003
2004**Parameters**
2005
2006| Name  | Type                    | Mandatory| Description                      |
2007| -------- | ------------------------ | ---- | -------------------------- |
2008| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|
2009| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
2010
2011**Example**
2012
2013```ts
2014import Base from '@ohos.base';
2015
2016let enabledNotificationCallback = (err: Base.BusinessError) => {
2017  if (err) {
2018    console.info("enableDistributed failed " + JSON.stringify(err));
2019  } else {
2020    console.info("enableDistributed success");
2021  }
2022};
2023
2024let enable: boolean = true;
2025
2026Notification.enableDistributed(enable, enabledNotificationCallback);
2027```
2028
2029## Notification.enableDistributed<sup>8+</sup>
2030
2031enableDistributed(enable: boolean): Promise\<void>
2032
2033Sets whether this device supports distributed notifications. This API uses a promise to return the result.
2034
2035**System capability**: SystemCapability.Notification.Notification
2036
2037**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2038
2039**System API**: This is a system API and cannot be called by third-party applications.
2040
2041**Parameters**
2042
2043| Name  | Type                    | Mandatory| Description                      |
2044| -------- | ------------------------ | ---- | -------------------------- |
2045| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|
2046
2047**Example**
2048
2049```ts
2050import Base from '@ohos.base';
2051
2052let enable: boolean = true;
2053Notification.enableDistributed(enable).then(() => {
2054  console.info("enableDistributed success");
2055}).catch((err: Base.BusinessError) => {
2056  console.error(`enableDistributed failed, code is ${err}`);
2057});
2058```
2059
2060## Notification.enableDistributedByBundle<sup>8+</sup>
2061
2062enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
2063
2064Sets whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.
2065
2066**System capability**: SystemCapability.Notification.Notification
2067
2068**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2069
2070**System API**: This is a system API and cannot be called by third-party applications.
2071
2072**Parameters**
2073
2074| Name  | Type                    | Mandatory| Description                      |
2075| -------- | ------------------------ | ---- | -------------------------- |
2076| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.                  |
2077| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                      |
2078| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
2079
2080**Example**
2081
2082```ts
2083import Base from '@ohos.base';
2084
2085let enableDistributedByBundleCallback = (err: Base.BusinessError) => {
2086  if (err) {
2087    console.info("enableDistributedByBundle failed " + JSON.stringify(err));
2088  } else {
2089    console.info("enableDistributedByBundle success");
2090  }
2091};
2092
2093let bundle: Notification.BundleOption = {
2094  bundle: "bundleName1",
2095};
2096
2097let enable: boolean = true;
2098
2099Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
2100```
2101
2102## Notification.enableDistributedByBundle<sup>8+</sup>
2103
2104enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
2105
2106Sets whether a specified application supports distributed notifications. This API uses a promise to return the result.
2107
2108**System capability**: SystemCapability.Notification.Notification
2109
2110**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2111
2112**System API**: This is a system API and cannot be called by third-party applications.
2113
2114**Parameters**
2115
2116| Name  | Type                    | Mandatory| Description                      |
2117| -------- | ------------------------ | ---- | -------------------------- |
2118| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Application bundle.               |
2119| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                 |
2120
2121**Example**
2122
2123```ts
2124import Base from '@ohos.base';
2125
2126let enable: boolean = true;
2127
2128let bundle: Notification.BundleOption = {
2129  bundle: "bundleName1",
2130};
2131
2132Notification.enableDistributedByBundle(bundle, enable).then(() => {
2133  console.info("enableDistributedByBundle success");
2134}).catch((err: Base.BusinessError) => {
2135  console.error(`enableDistributedByBundle failed, code is ${err}`);
2136});
2137
2138```
2139
2140## Notification.isDistributedEnabledByBundle<sup>8+</sup>
2141
2142isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
2143
2144Obtains whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result.
2145
2146**System capability**: SystemCapability.Notification.Notification
2147
2148**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2149
2150**System API**: This is a system API and cannot be called by third-party applications.
2151
2152**Parameters**
2153
2154| Name  | Type                    | Mandatory| Description                      |
2155| -------- | ------------------------ | ---- | -------------------------- |
2156| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Application bundle.                    |
2157| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
2158
2159**Example**
2160
2161```ts
2162import Base from '@ohos.base';
2163
2164let isDistributedEnabledByBundleCallback = (err: Base.BusinessError, data: boolean) => {
2165  if (err) {
2166    console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
2167  } else {
2168    console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
2169  }
2170};
2171
2172let bundle: Notification.BundleOption = {
2173  bundle: "bundleName1",
2174};
2175
2176Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
2177```
2178
2179## Notification.isDistributedEnabledByBundle<sup>8+</sup>
2180
2181isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
2182
2183Checks whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.
2184
2185**System capability**: SystemCapability.Notification.Notification
2186
2187**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2188
2189**System API**: This is a system API and cannot be called by third-party applications.
2190
2191**Parameters**
2192
2193| Name  | Type                    | Mandatory| Description                      |
2194| -------- | ------------------------ | ---- | -------------------------- |
2195| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Application bundle.               |
2196
2197**Return value**
2198
2199| Type              | Description                                             |
2200| ------------------ | ------------------------------------------------- |
2201| Promise\<boolean\> | Promise used to return the result.|
2202
2203**Example**
2204
2205```ts
2206import Base from '@ohos.base';
2207
2208let bundle: Notification.BundleOption = {
2209  bundle: "bundleName1",
2210};
2211
2212Notification.isDistributedEnabledByBundle(bundle).then((data: boolean) => {
2213  console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
2214}).catch((err: Base.BusinessError) => {
2215  console.error(`isDistributedEnabledByBundle failed, code is ${err}`);
2216});
2217```
2218
2219
2220## Notification.getDeviceRemindType<sup>8+</sup>
2221
2222getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
2223
2224Obtains the notification reminder type. This API uses an asynchronous callback to return the result.
2225
2226**System capability**: SystemCapability.Notification.Notification
2227
2228**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2229
2230**System API**: This is a system API and cannot be called by third-party applications.
2231
2232**Parameters**
2233
2234| Name  | Type                              | Mandatory| Description                      |
2235| -------- | --------------------------------- | ---- | -------------------------- |
2236| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8-deprecated)\> | Yes  | Callback used to return the result.|
2237
2238**Example**
2239
2240```ts
2241import Base from '@ohos.base';
2242
2243let getDeviceRemindTypeCallback = (err: Base.BusinessError, data: Notification.DeviceRemindType) => {
2244  if (err) {
2245    console.info("getDeviceRemindType failed " + JSON.stringify(err));
2246  } else {
2247    console.info("getDeviceRemindType success");
2248  }
2249};
2250
2251Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
2252```
2253
2254## Notification.getDeviceRemindType<sup>8+</sup>
2255
2256getDeviceRemindType(): Promise\<DeviceRemindType\>
2257
2258Obtains the notification reminder type. This API uses a promise to return the result.
2259
2260**System capability**: SystemCapability.Notification.Notification
2261
2262**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER
2263
2264**System API**: This is a system API and cannot be called by third-party applications.
2265
2266**Return value**
2267
2268| Type              | Description           |
2269| ------------------ | --------------- |
2270| Promise\<[DeviceRemindType](#deviceremindtype8-deprecated)\> | Promise used to return the result.|
2271
2272**Example**
2273
2274```ts
2275import Base from '@ohos.base';
2276
2277Notification.getDeviceRemindType().then((data: Notification.DeviceRemindType) => {
2278  console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
2279}).catch((err: Base.BusinessError) => {
2280  console.error(`getDeviceRemindType failed, code is ${err}`);
2281});
2282```
2283
2284## DoNotDisturbDate<sup>8+</sup> <sup>deprecated</sup>
2285
2286**System capability**: SystemCapability.Notification.Notification
2287
2288> **NOTE**<br>
2289> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DoNotDisturbDate](js-apis-notificationManager-sys.md#donotdisturbdate) instead.
2290
2291**System API**: This is a system API and cannot be called by third-party applications.
2292
2293| Name | Type                                  | Readable| Writable| Description                  |
2294| ----- | -------------------------------------- | ---- | ---- | ---------------------- |
2295| type  | [DoNotDisturbType](./js-apis-notificationManager-sys.md#donotdisturbtype) | Yes  | Yes  | DND time type.|
2296| begin | Date                                   | Yes  | Yes  | DND start time.|
2297| end   | Date                                   | Yes  | Yes  | DND end time.|
2298
2299## DoNotDisturbType<sup>8+</sup> <sup>deprecated</sup>
2300
2301**System capability**: SystemCapability.Notification.Notification
2302
2303> **NOTE**<br>
2304> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DoNotDisturbType](js-apis-notificationManager-sys.md#donotdisturbtype) instead.
2305
2306**System API**: This is a system API and cannot be called by third-party applications.
2307
2308| Name        | Value              | Description                                      |
2309| ------------ | ---------------- | ------------------------------------------ |
2310| TYPE_NONE    | 0 | Non-DND.                          |
2311| TYPE_ONCE    | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
2312| TYPE_DAILY   | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
2313| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute).    |
2314
2315## DeviceRemindType<sup>8+</sup> <sup>deprecated</sup>
2316
2317**System capability**: SystemCapability.Notification.Notification
2318
2319**System API**: This is a system API and cannot be called by third-party applications.
2320
2321> **NOTE**<br>
2322> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DeviceRemindType](js-apis-notificationManager-sys.md#deviceremindtype) instead.
2323
2324| Name                | Value | Description                              |
2325| -------------------- | --- | --------------------------------- |
2326| IDLE_DONOT_REMIND    | 0   | The device is not in use. No notification is required.           |
2327| IDLE_REMIND          | 1   | The device is not in use.                |
2328| ACTIVE_DONOT_REMIND  | 2   | The device is in use. No notification is required.           |
2329| ACTIVE_REMIND        | 3   | The device is in use.                |
2330
2331
2332## SourceType<sup>8+</sup> <sup>deprecated</sup>
2333
2334**System capability**: SystemCapability.Notification.Notification
2335
2336**System API**: This is a system API and cannot be called by third-party applications.
2337
2338> **NOTE**<br>
2339> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.SourceType](js-apis-notificationManager-sys.md#sourcetype) instead.
2340
2341| Name                | Value | Description                 |
2342| -------------------- | --- | -------------------- |
2343| TYPE_NORMAL          | 0   | Normal notification.           |
2344| TYPE_CONTINUOUS      | 1   | Continuous notification.           |
2345| TYPE_TIMER           | 2   | Timed notification.           |
2346
2347## RemoveReason <sup>deprecated</sup>
2348
2349**System capability**: SystemCapability.Notification.Notification
2350
2351**System API**: This is a system API and cannot be called by third-party applications.
2352
2353> **NOTE**<br>
2354> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [notificationManager.RemoveReason](js-apis-notificationSubscribe-sys.md#removereason) instead.
2355
2356| Name                | Value | Description                 |
2357| -------------------- | --- | -------------------- |
2358| CLICK_REASON_REMOVE  | 1   | The notification is removed after a click on it.   |
2359| CANCEL_REASON_REMOVE | 2   | The notification is removed by the user.        |
2360