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