• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.notificationManager (NotificationManager模块)
2<!--Kit: Notification Kit-->
3<!--Subsystem: Notification-->
4<!--Owner: @michael_woo888-->
5<!--Designer: @dongqingran; @wulong158-->
6<!--Tester: @wanghong1997-->
7<!--Adviser: @huipeizi-->
8
9本模块提供通知管理的能力,包括发布、更新、取消通知,创建、获取、移除通知渠道,获取发布通知应用的使能状态,获取通知的相关信息等。
10
11> **说明:**
12>
13> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
14
15## 导入模块
16
17```ts
18import { notificationManager } from '@kit.NotificationKit';
19```
20
21## notificationManager.publish
22
23publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
24
25发布通知。使用callback异步回调。
26
27如果新发布通知与已发布通知的ID和标签都相同,则新通知将取代原有通知。
28
29**系统能力**:SystemCapability.Notification.Notification
30
31**参数:**
32
33| 参数名     | 类型                                        | 必填 | 说明                                        |
34| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
35| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest-1) | 是   | 设置发布通知的内容和相关配置信息。 |
36| callback | AsyncCallback\<void\>                       | 是   | 回调函数。当发布通知成功,err为undefined,否则为错误对象。                        |
37
38**错误码:**
39
40以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[HTTP错误码](../apis-network-kit/errorcode-net-http.md)。
41
42| 错误码ID | 错误信息                                              |
43| -------- | ---------------------------------------------------- |
44| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.    |
45| 1600001  | Internal error.                                      |
46| 1600002  | Marshalling or unmarshalling error.                  |
47| 1600003  | Failed to connect to the service.                    |
48| 1600004  | Notification disabled.                               |
49| 1600005  | Notification slot disabled.                          |
50| 1600007  | The notification does not exist.                     |
51| 1600009  | The notification sending frequency reaches the upper limit.            |
52| 1600012  | No memory space.                                     |
53| 1600014  | No permission.                                       |
54| 1600015  | The current notification status does not support duplicate configurations. |
55| 1600016  | The notification version for this update is too low. |
56| 1600020  | The application is not allowed to send notifications due to permission settings. |
57| 2300007  | Network unreachable.                                 |
58
59**示例:**
60
61```ts
62import { BusinessError } from '@kit.BasicServicesKit';
63
64// publish回调
65let publishCallback = (err: BusinessError): void => {
66  if (err) {
67    console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
68  } else {
69    console.info(`Succeeded in publishing notification.`);
70  }
71}
72// 通知Request对象
73let notificationRequest: notificationManager.NotificationRequest = {
74  id: 1,
75  content: {
76    notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
77    normal: {
78      title: "test_title",
79      text: "test_text",
80      additionalText: "test_additionalText"
81    }
82  }
83};
84notificationManager.publish(notificationRequest, publishCallback);
85```
86
87## notificationManager.publish
88
89publish(request: NotificationRequest): Promise\<void\>
90
91发布通知。使用Promise异步回调。
92
93如果新发布通知与已发布通知的ID和标签都相同,则新通知将取代原有通知。
94
95**系统能力**:SystemCapability.Notification.Notification
96
97**参数:**
98
99| 参数名     | 类型                                        | 必填 | 说明                                        |
100| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
101| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest-1) | 是   | 设置发布通知的内容和相关配置信息。 |
102
103**返回值:**
104
105| 类型     | 说明 |
106| ------- |--|
107| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
108
109**错误码:**
110
111以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[HTTP错误码](../apis-network-kit/errorcode-net-http.md)。
112
113| 错误码ID | 错误信息                                              |
114| -------- | ---------------------------------------------------- |
115| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.    |
116| 1600001  | Internal error.                                      |
117| 1600002  | Marshalling or unmarshalling error.                  |
118| 1600003  | Failed to connect to the service.                    |
119| 1600004  | Notification disabled.                               |
120| 1600005  | Notification slot disabled.                          |
121| 1600007  | The notification does not exist.                     |
122| 1600009  | The notification sending frequency reaches the upper limit.            |
123| 1600012  | No memory space.                                     |
124| 1600014  | No permission.                                       |
125| 1600015  | The current notification status does not support duplicate configurations. |
126| 1600016  | The notification version for this update is too low. |
127| 1600020  | The application is not allowed to send notifications due to permission settings. |
128| 2300007  | Network unreachable.                                 |
129
130**示例:**
131
132```ts
133import { BusinessError } from '@kit.BasicServicesKit';
134
135// 通知Request对象
136let notificationRequest: notificationManager.NotificationRequest = {
137  id: 1,
138  content: {
139    notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
140    normal: {
141      title: "test_title",
142      text: "test_text",
143      additionalText: "test_additionalText"
144    }
145  }
146};
147notificationManager.publish(notificationRequest).then(() => {
148  console.info(`Succeeded in publishing notification.`);
149}).catch((err: BusinessError) => {
150  console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
151});
152
153```
154
155## notificationManager.cancel
156
157cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
158
159根据通知ID和标签取消已发布的通知。使用callback异步回调。
160
161**系统能力**:SystemCapability.Notification.Notification
162
163**参数:**
164
165| 参数名     | 类型                  | 必填 | 说明                 |
166| -------- | --------------------- | ---- | -------------------- |
167| id       | number                | 是   | 通知ID。               |
168| label    | string                | 是   | 通知标签。             |
169| callback | AsyncCallback\<void\> | 是   | 回调函数。根据通知ID和标签取消已发布的通知成功,err为undefined,否则为错误对象。 |
170
171**错误码:**
172
173以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
174
175| 错误码ID | 错误信息                            |
176| -------- | ----------------------------------- |
177| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
178| 1600001  | Internal error.                     |
179| 1600002  | Marshalling or unmarshalling error. |
180| 1600003  | Failed to connect to the service.          |
181| 1600007  | The notification does not exist.      |
182
183**示例:**
184
185```ts
186import { BusinessError } from '@kit.BasicServicesKit';
187
188// cancel回调
189let cancelCallback = (err: BusinessError): void => {
190  if (err) {
191    console.error(`Failed to cancel notification. Code is ${err.code}, message is ${err.message}`);
192  } else {
193    console.info(`Succeeded in canceling notification.`);
194  }
195}
196notificationManager.cancel(0, "label", cancelCallback);
197```
198
199## notificationManager.cancel
200
201cancel(id: number, label?: string): Promise\<void\>
202
203根据通知ID和标签取消已发布的通知,若标签为空,则取消与指定通知ID匹配的已发布通知。使用Promise异步回调。
204
205**系统能力**:SystemCapability.Notification.Notification
206
207**参数:**
208
209| 参数名  | 类型   | 必填 | 说明     |
210| ----- | ------ | ---- | -------- |
211| id    | number | 是   | 通知ID。   |
212| label | string | 否   | 通知标签,默认为空。 |
213
214**返回值:**
215
216| 类型     | 说明        |
217| ------- |-----------|
218| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
219
220**错误码:**
221
222以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
223
224| 错误码ID | 错误信息                            |
225| -------- | ----------------------------------- |
226| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
227| 1600001  | Internal error.                     |
228| 1600002  | Marshalling or unmarshalling error. |
229| 1600003  | Failed to connect to the service.          |
230| 1600007  | The notification does not exist.      |
231
232**示例:**
233
234```ts
235import { BusinessError } from '@kit.BasicServicesKit';
236
237notificationManager.cancel(0).then(() => {
238  console.info(`Succeeded in canceling notification.`);
239}).catch((err: BusinessError) => {
240  console.error(`Failed to cancel notification. Code is ${err.code}, message is ${err.message}`);
241});
242```
243
244## notificationManager.cancel
245
246cancel(id: number, callback: AsyncCallback\<void\>): void
247
248根据指定的通知ID取消已发布的通知。使用callback异步回调。
249
250**系统能力**:SystemCapability.Notification.Notification
251
252**参数:**
253
254| 参数名     | 类型                  | 必填 | 说明                 |
255| -------- | --------------------- | ---- | -------------------- |
256| id       | number                | 是   | 通知ID。               |
257| callback | AsyncCallback\<void\> | 是   | 回调函数。当取消已发布的通知成功,err为undefined,否则为错误对象。 |
258
259**错误码:**
260
261以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
262
263| 错误码ID | 错误信息                            |
264| -------- | ----------------------------------- |
265| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
266| 1600001  | Internal error.                     |
267| 1600002  | Marshalling or unmarshalling error. |
268| 1600003  | Failed to connect to the service.          |
269| 1600007  | The notification does not exist.      |
270
271**示例:**
272
273```ts
274import { BusinessError } from '@kit.BasicServicesKit';
275
276// cancel回调
277let cancelCallback = (err: BusinessError): void => {
278  if (err) {
279    console.error(`Failed to cancel notification. Code is ${err.code}, message is ${err.message}`);
280  } else {
281    console.info(`Succeeded in canceling notification.`);
282  }
283}
284notificationManager.cancel(0, cancelCallback);
285```
286
287## notificationManager.cancelAll
288
289cancelAll(callback: AsyncCallback\<void\>): void
290
291取消当前应用所有已发布的通知。使用callback异步回调。
292
293**系统能力**:SystemCapability.Notification.Notification
294
295**参数:**
296
297| 参数名     | 类型                  | 必填 | 说明                 |
298| -------- | --------------------- | ---- | -------------------- |
299| callback | AsyncCallback\<void\> | 是   | 回调函数。当取消当前应用所有已发布的通知成功,err为undefined,否则为错误对象。 |
300
301**错误码:**
302
303以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
304
305| 错误码ID | 错误信息                            |
306| -------- | ----------------------------------- |
307| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
308| 1600001  | Internal error.                     |
309| 1600002  | Marshalling or unmarshalling error. |
310| 1600003  | Failed to connect to the service.          |
311
312**示例:**
313
314```ts
315import { BusinessError } from '@kit.BasicServicesKit';
316
317// cancel回调
318let cancelAllCallback = (err: BusinessError): void => {
319  if (err) {
320    console.error(`Failed to cancel all notification. Code is ${err.code}, message is ${err.message}`);
321  } else {
322    console.info(`Succeeded in canceling all notification.`);
323  }
324}
325notificationManager.cancelAll(cancelAllCallback);
326```
327
328## notificationManager.cancelAll
329
330cancelAll(): Promise\<void\>
331
332取消当前应用所有已发布的通知。使用Promise异步回调。
333
334**系统能力**:SystemCapability.Notification.Notification
335
336**返回值:**
337
338| 类型     | 说明        |
339| ------- |-----------|
340| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
341
342**错误码:**
343
344以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
345
346| 错误码ID | 错误信息                            |
347| -------- | ----------------------------------- |
348| 1600001  | Internal error.                     |
349| 1600002  | Marshalling or unmarshalling error. |
350| 1600003  | Failed to connect to the service.          |
351
352**示例:**
353
354```ts
355import { BusinessError } from '@kit.BasicServicesKit';
356
357notificationManager.cancelAll().then(() => {
358  console.info(`Succeeded in canceling all notification.`);
359}).catch((err: BusinessError) => {
360  console.error(`Failed to cancel all notification. Code is ${err.code}, message is ${err.message}`);
361});
362```
363
364## notificationManager.addSlot
365
366addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
367
368创建指定类型的通知渠道。使用callback异步回调。
369
370**系统能力**:SystemCapability.Notification.Notification
371
372**参数:**
373
374| 参数名     | 类型                  | 必填 | 说明                   |
375| -------- | --------------------- | ---- | ---------------------- |
376| type     | [SlotType](#slottype)              | 是   | 要创建的通知渠道的类型。 |
377| callback | AsyncCallback\<void\> | 是   | 回调函数。当创建指定类型的通知渠道成功,err为undefined,否则为错误对象。   |
378
379**错误码:**
380
381以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
382
383| 错误码ID | 错误信息                            |
384| -------- | ----------------------------------- |
385| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
386| 1600001  | Internal error.                     |
387| 1600002  | Marshalling or unmarshalling error. |
388| 1600003  | Failed to connect to the service.          |
389| 1600012  | No memory space.                    |
390
391**示例:**
392
393```ts
394import { BusinessError } from '@kit.BasicServicesKit';
395
396// addSlot回调
397let addSlotCallBack = (err: BusinessError): void => {
398  if (err) {
399    console.error(`Failed to add slot. Code is ${err.code}, message is ${err.message}`);
400  } else {
401    console.info(`Succeeded in adding slot.`);
402  }
403}
404notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
405```
406
407## notificationManager.addSlot
408
409addSlot(type: SlotType): Promise\<void\>
410
411创建指定类型的通知渠道。使用Promise异步回调。
412
413**系统能力**:SystemCapability.Notification.Notification
414
415**参数:**
416
417| 参数名 | 类型     | 必填 | 说明                   |
418| ---- | -------- | ---- | ---------------------- |
419| type | [SlotType](#slottype) | 是   | 要创建的通知渠道的类型。 |
420
421**返回值:**
422
423| 类型     | 说明        |
424| ------- |-----------|
425| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
426
427**错误码:**
428
429以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
430
431| 错误码ID | 错误信息                            |
432| -------- | ----------------------------------- |
433| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
434| 1600001  | Internal error.                     |
435| 1600002  | Marshalling or unmarshalling error. |
436| 1600003  | Failed to connect to the service.          |
437| 1600012  | No memory space.                    |
438
439**示例:**
440
441```ts
442import { BusinessError } from '@kit.BasicServicesKit';
443
444notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {
445  console.info(`Succeeded in adding slot.`);
446}).catch((err: BusinessError) => {
447  console.error(`Failed to add slot. Code is ${err.code}, message is ${err.message}`);
448});
449```
450
451## notificationManager.getSlot
452
453getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
454
455获取指定类型的通知渠道。使用callback异步回调。
456
457**系统能力**:SystemCapability.Notification.Notification
458
459**参数:**
460
461| 参数名     | 类型                              | 必填 | 说明                                                        |
462| -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
463| slotType | [SlotType](#slottype)                          | 是   | 通知渠道类型,例如社交通信、服务提醒、内容咨询等类型。 |
464| callback | AsyncCallback\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | 是   | 回调函数。当获取通知渠道成功,err为undefined,data为获取到的NotificationSlot,否则为错误对象。                                        |
465
466**错误码:**
467
468以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
469
470| 错误码ID | 错误信息                            |
471| -------- | ----------------------------------- |
472| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
473| 1600001  | Internal error.                     |
474| 1600002  | Marshalling or unmarshalling error. |
475| 1600003  | Failed to connect to the service.          |
476
477**示例:**
478
479```ts
480import { BusinessError } from '@kit.BasicServicesKit';
481
482// getSlot回调
483let getSlotCallback = (err: BusinessError, data: notificationManager.NotificationSlot): void => {
484  if (err) {
485    console.error(`Failed to get slot. Code is ${err.code}, message is ${err.message}`);
486  } else {
487    console.info(`Succeeded in getting slot, data is ${JSON.stringify(data)}`);
488  }
489}
490let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
491notificationManager.getSlot(slotType, getSlotCallback);
492```
493
494## notificationManager.getSlot
495
496getSlot(slotType: SlotType): Promise\<NotificationSlot\>
497
498获取指定类型的通知渠道。使用Promise异步回调。
499
500**系统能力**:SystemCapability.Notification.Notification
501
502**参数:**
503
504| 参数名     | 类型     | 必填 | 说明                                                        |
505| -------- | -------- | ---- | ----------------------------------------------------------- |
506| slotType | [SlotType](#slottype) | 是   | 通知渠道类型,例如社交通信、服务提醒、内容咨询等类型。 |
507
508**返回值:**
509
510| 类型                                                        | 说明                                                         |
511| ----------------------------------------------------------- | ------------------------------------------------------------ |
512| Promise\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Promise对象,返回通知渠道对象。 |
513
514**错误码:**
515
516以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
517
518| 错误码ID | 错误信息                            |
519| -------- | ----------------------------------- |
520| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
521| 1600001  | Internal error.                     |
522| 1600002  | Marshalling or unmarshalling error. |
523| 1600003  | Failed to connect to the service.          |
524
525**示例:**
526
527```ts
528import { BusinessError } from '@kit.BasicServicesKit';
529
530let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
531notificationManager.getSlot(slotType).then((data: notificationManager.NotificationSlot) => {
532  console.info(`Succeeded in getting slot, data is ${JSON.stringify(data)}`);
533}).catch((err: BusinessError) => {
534  console.error(`Failed to get slot. Code is ${err.code}, message is ${err.message}`);
535});
536```
537
538## notificationManager.getSlots
539
540getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
541
542获取当前应用的所有通知渠道。使用callback异步回调。
543
544**系统能力**:SystemCapability.Notification.Notification
545
546**参数:**
547
548| 参数名     | 类型                              | 必填 | 说明                 |
549| -------- | --------------------------------- | ---- | -------------------- |
550| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | 是   | 回调函数。当获取通知渠道成功,err为undefined,data为获取到的NotificationSlot数组,否则为错误对象。 |
551
552**错误码:**
553
554以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
555
556
557| 错误码ID | 错误信息                            |
558| -------- | ----------------------------------- |
559| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
560| 1600001  | Internal error.                     |
561| 1600002  | Marshalling or unmarshalling error. |
562| 1600003  | Failed to connect to the service.          |
563
564**示例:**
565
566```ts
567import { BusinessError } from '@kit.BasicServicesKit';
568
569// getSlots回调
570let getSlotsCallback = (err: BusinessError, data: Array<notificationManager.NotificationSlot>): void => {
571  if (err) {
572    console.error(`Failed to get slots. Code is ${err.code}, message is ${err.message}`);
573  } else {
574    console.info(`Succeeded in getting slots, data is ${JSON.stringify(data)}`);
575  }
576}
577notificationManager.getSlots(getSlotsCallback);
578```
579
580## notificationManager.getSlots
581
582getSlots(): Promise\<Array\<NotificationSlot>>
583
584获取当前应用的所有通知渠道。使用Promise异步回调。
585
586**系统能力**:SystemCapability.Notification.Notification
587
588**返回值:**
589
590| 类型                                                        | 说明                                                         |
591| ----------------------------------------------------------- | ------------------------------------------------------------ |
592| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | Promise对象,返回通知渠道对象。 |
593
594**错误码:**
595
596以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
597
598| 错误码ID | 错误信息                            |
599| -------- | ----------------------------------- |
600| 1600001  | Internal error.                     |
601| 1600002  | Marshalling or unmarshalling error. |
602| 1600003  | Failed to connect to the service.          |
603
604**示例:**
605
606```ts
607import { BusinessError } from '@kit.BasicServicesKit';
608
609notificationManager.getSlots().then((data: Array<notificationManager.NotificationSlot>) => {
610  console.info(`Succeeded in getting slots, data is ${JSON.stringify(data)}`);
611}).catch((err: BusinessError) => {
612  console.error(`Failed to get slots. Code is ${err.code}, message is ${err.message}`);
613});
614```
615
616## notificationManager.removeSlot
617
618removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
619
620删除当前应用指定类型的通知渠道。使用callback异步回调。
621
622**系统能力**:SystemCapability.Notification.Notification
623
624**参数:**
625
626| 参数名     | 类型                  | 必填 | 说明                                                        |
627| -------- | --------------------- | ---- | ----------------------------------------------------------- |
628| slotType | [SlotType](#slottype)              | 是   | 通知渠道类型,例如社交通信、服务提醒、内容咨询等类型。 |
629| callback | AsyncCallback\<void\> | 是   | 回调函数。当删除指定类型的通知渠道成功,err为undefined,否则为错误对象。                                        |
630
631**错误码:**
632
633以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
634
635| 错误码ID | 错误信息                            |
636| -------- | ----------------------------------- |
637| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
638| 1600001  | Internal error.                     |
639| 1600002  | Marshalling or unmarshalling error. |
640| 1600003  | Failed to connect to the service.          |
641
642**示例:**
643
644```ts
645import { BusinessError } from '@kit.BasicServicesKit';
646
647// removeSlot回调
648let removeSlotCallback = (err: BusinessError): void => {
649  if (err) {
650    console.error(`Failed to remove slot. Code is ${err.code}, message is ${err.message}`);
651  } else {
652    console.info(`Succeeded in removing slot.`);
653  }
654}
655let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
656notificationManager.removeSlot(slotType, removeSlotCallback);
657```
658
659## notificationManager.removeSlot
660
661removeSlot(slotType: SlotType): Promise\<void\>
662
663删除当前应用指定类型的通知渠道。使用Promise异步回调。
664
665**系统能力**:SystemCapability.Notification.Notification
666
667**参数:**
668
669| 参数名     | 类型     | 必填 | 说明                                                        |
670| -------- | -------- | ---- | ----------------------------------------------------------- |
671| slotType | [SlotType](#slottype) | 是   | 通知渠道类型,例如社交通信、服务提醒、内容咨询等类型。 |
672
673**返回值:**
674
675| 类型      | 说明        |
676|---------|-----------|
677| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
678
679**错误码:**
680
681以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
682
683| 错误码ID | 错误信息                            |
684| -------- | ----------------------------------- |
685| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
686| 1600001  | Internal error.                     |
687| 1600002  | Marshalling or unmarshalling error. |
688| 1600003  | Failed to connect to the service.          |
689
690**示例:**
691
692```ts
693import { BusinessError } from '@kit.BasicServicesKit';
694
695let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
696notificationManager.removeSlot(slotType).then(() => {
697  console.info(`Succeeded in removing slot.`);
698}).catch((err: BusinessError) => {
699  console.error(`Failed to remove slot. Code is ${err.code}, message is ${err.message}`);
700});
701```
702
703## notificationManager.removeAllSlots
704
705removeAllSlots(callback: AsyncCallback\<void\>): void
706
707删除当前应用所有通知渠道。使用callback异步回调。
708
709**系统能力**:SystemCapability.Notification.Notification
710
711**参数:**
712
713| 参数名     | 类型                  | 必填 | 说明                 |
714| -------- | --------------------- | ---- | -------------------- |
715| callback | AsyncCallback\<void\> | 是   | 回调函数。当删除当前应用所有通知渠道成功,err为undefined,否则为错误对象。 |
716
717**错误码:**
718
719以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
720
721| 错误码ID | 错误信息                            |
722| -------- | ----------------------------------- |
723| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
724| 1600001  | Internal error.                     |
725| 1600002  | Marshalling or unmarshalling error. |
726| 1600003  | Failed to connect to the service.          |
727
728**示例:**
729
730```ts
731import { BusinessError } from '@kit.BasicServicesKit';
732
733let removeAllSlotsCallback = (err: BusinessError): void => {
734  if (err) {
735    console.error(`Failed to remove all slots. Code is ${err.code}, message is ${err.message}`);
736  } else {
737    console.info(`Succeeded in removing all slots.`);
738  }
739}
740notificationManager.removeAllSlots(removeAllSlotsCallback);
741```
742
743## notificationManager.removeAllSlots
744
745removeAllSlots(): Promise\<void\>
746
747删除当前应用所有通知渠道。使用Promise异步回调。
748
749**系统能力**:SystemCapability.Notification.Notification
750
751**返回值:**
752
753| 类型      | 说明        |
754|---------|-----------|
755| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
756
757**错误码:**
758
759以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
760
761| 错误码ID | 错误信息                            |
762| -------- | ----------------------------------- |
763| 1600001  | Internal error.                     |
764| 1600002  | Marshalling or unmarshalling error. |
765| 1600003  | Failed to connect to the service.          |
766
767**示例:**
768
769```ts
770import { BusinessError } from '@kit.BasicServicesKit';
771
772notificationManager.removeAllSlots().then(() => {
773  console.info(`Succeeded in removing all slots.`);
774}).catch((err: BusinessError) => {
775  console.error(`Failed to remove all slots. Code is ${err.code}, message is ${err.message}`);
776});
777```
778
779## notificationManager.isNotificationEnabled<sup>11+</sup>
780
781isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
782
783查询当前应用通知使能状态。使用callback异步回调。
784
785**系统能力**:SystemCapability.Notification.Notification
786
787**参数:**
788
789| 参数名     | 类型                  | 必填 | 说明                     |
790| -------- | --------------------- | ---- | ------------------------ |
791| callback | AsyncCallback\<boolean\> | 是   | 回调函数。返回true,表示允许发布通知;返回false,表示禁止发布通知;调用失败返回错误对象。 |
792
793**错误码:**
794
795以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)、[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
796
797| 错误码ID | 错误信息                                  |
798| -------- | ---------------------------------------- |
799| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
800| 1600001  | Internal error.                          |
801| 1600002  | Marshalling or unmarshalling error.      |
802| 1600003  | Failed to connect to the service.               |
803| 1600008  | The user does not exist.                   |
804| 17700001 | The specified bundle name was not found. |
805
806**示例:**
807
808```ts
809import { BusinessError } from '@kit.BasicServicesKit';
810
811let isNotificationEnabledCallback = (err: BusinessError, data: boolean): void => {
812  if (err) {
813    console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
814  } else {
815    console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
816  }
817}
818
819notificationManager.isNotificationEnabled(isNotificationEnabledCallback);
820```
821
822## notificationManager.isNotificationEnabled<sup>11+</sup>
823
824isNotificationEnabled(): Promise\<boolean\>
825
826查询当前应用通知使能状态。使用Promise异步回调。
827
828**系统能力**:SystemCapability.Notification.Notification
829
830**返回值:**
831
832| 类型                                                        | 说明                                                         |
833| ----------------------------------------------------------- | ------------------------------------------------------------ |
834| Promise\<boolean\> | Promise对象。返回true,表示允许发布通知;返回false,表示禁止发布通知。 |
835
836**错误码:**
837
838以下错误码的详细介绍请参见[通知错误码](./errorcode-notification.md)、[包管理子系统通用错误码](../../reference/apis-ability-kit/errorcode-bundle.md)。
839
840| 错误码ID | 错误信息                                 |
841| -------- | ---------------------------------------- |
842| 1600001  | Internal error.                          |
843| 1600002  | Marshalling or unmarshalling error.      |
844| 1600003  | Failed to connect to the service.               |
845| 1600008  | The user does not exist.                   |
846| 17700001 | The specified bundle name was not found. |
847
848**示例:**
849
850```ts
851import { BusinessError } from '@kit.BasicServicesKit';
852
853notificationManager.isNotificationEnabled().then((data: boolean) => {
854  console.info(`isNotificationEnabled success, data: ${JSON.stringify(data)}`);
855}).catch((err: BusinessError) => {
856  console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
857});
858```
859
860## notificationManager.isNotificationEnabledSync<sup>12+</sup>
861
862isNotificationEnabledSync(): boolean
863
864同步查询当前应用通知使能状态。
865
866**系统能力**:SystemCapability.Notification.Notification
867
868**返回值:**
869
870| 类型                                                        | 说明                                                     |
871| ----------------------------------------------------------- |--------------------------------------------------------- |
872| boolean | 返回查询通知使能状态的结果。返回true,表示允许发布通知;返回false,表示禁止发布通知。 |
873
874**错误码:**
875
876以下错误码的详细介绍请参见[通知错误码](./errorcode-notification.md)。
877
878| 错误码ID | 错误信息                                 |
879| -------- | ---------------------------------------- |
880| 1600001  | Internal error.                          |
881| 1600002  | Marshalling or unmarshalling error.      |
882| 1600003  | Failed to connect to the service.               |
883
884**示例:**
885
886```ts
887let enabled = notificationManager.isNotificationEnabledSync();
888console.info(`isNotificationEnabledSync success, data is : ${JSON.stringify(enabled)}`);
889```
890
891## notificationManager.setBadgeNumber<sup>10+</sup>
892
893setBadgeNumber(badgeNumber: number): Promise\<void\>
894
895设定角标个数,在应用的桌面图标上呈现。使用Promise异步回调。
896
897**系统能力**:SystemCapability.Notification.Notification
898
899**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
900
901**参数:**
902
903| 参数名      | 类型   | 必填 | 说明       |
904| ----------- | ------ | ---- | ---------- |
905| badgeNumber | number | 是   | 角标个数。当角标设定个数取值小于或等于0时,清除角标。取值大于99时,通知角标将显示99+。 |
906
907**返回值:**
908
909| 类型      | 说明        |
910|---------|-----------|
911| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
912
913**错误码:**
914
915以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
916
917| 错误码ID | 错误信息                            |
918| -------- | ----------------------------------- |
919| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
920| 801 | Capability not supported. |
921| 1600001  | Internal error.                     |
922| 1600002  | Marshalling or unmarshalling error. |
923| 1600003  | Failed to connect to the service.          |
924| 1600012  | No memory space.                          |
925
926**示例:**
927
928```ts
929import { BusinessError } from '@kit.BasicServicesKit';
930
931let badgeNumber: number = 10;
932notificationManager.setBadgeNumber(badgeNumber).then(() => {
933  console.info(`Succeeded in setting badge number.`);
934}).catch((err: BusinessError) => {
935  console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
936});
937```
938
939## notificationManager.setBadgeNumber<sup>10+</sup>
940
941setBadgeNumber(badgeNumber: number, callback: AsyncCallback\<void\>): void
942
943设定角标个数,在应用的桌面图标上呈现。使用callback异步回调。
944
945**系统能力**:SystemCapability.Notification.Notification
946
947**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
948
949**参数:**
950
951| 参数名      | 类型                  | 必填 | 说明               |
952| ----------- | --------------------- | ---- | ------------------ |
953| badgeNumber | number                | 是   | 角标个数。当角标设定个数取值小于或等于0时,清除角标。取值大于99时,通知角标将显示99+。         |
954| callback    | AsyncCallback\<void\> | 是   | 回调函数。当设定角标个数成功,err为undefined,否则为错误对象。 |
955
956**错误码:**
957
958以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
959
960| 错误码ID | 错误信息                            |
961| -------- | ----------------------------------- |
962| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
963| 801 | Capability not supported. |
964| 1600001  | Internal error.                     |
965| 1600002  | Marshalling or unmarshalling error. |
966| 1600003  | Failed to connect to the service.          |
967| 1600012  | No memory space.                          |
968
969**示例:**
970
971```ts
972import { BusinessError } from '@kit.BasicServicesKit';
973
974let setBadgeNumberCallback = (err: BusinessError): void => {
975  if (err) {
976    console.error(`Failed to set badge number. Code is ${err.code}, message is ${err.message}`);
977  } else {
978    console.info(`Succeeded in setting badge number.`);
979  }
980}
981let badgeNumber: number = 10;
982notificationManager.setBadgeNumber(badgeNumber, setBadgeNumberCallback);
983```
984
985## notificationManager.getActiveNotificationCount
986
987getActiveNotificationCount(callback: AsyncCallback\<number\>): void
988
989获取当前应用未删除的通知数。使用callback异步回调。
990
991**系统能力**:SystemCapability.Notification.Notification
992
993**参数:**
994
995| 参数名     | 类型                   | 必填 | 说明                   |
996| -------- | ---------------------- | ---- | ---------------------- |
997| callback | AsyncCallback\<number\> | 是   | 回调函数。当获取当前应用未删除的通知数成功,err为undefined,data为当前应用未删除的通知数,否则为错误对象。 |
998
999**错误码:**
1000
1001以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1002
1003| 错误码ID | 错误信息                            |
1004| -------- | ----------------------------------- |
1005| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1006| 1600001  | Internal error.                     |
1007| 1600002  | Marshalling or unmarshalling error. |
1008| 1600003  | Failed to connect to the service.          |
1009
1010**示例:**
1011
1012```ts
1013import { BusinessError } from '@kit.BasicServicesKit';
1014
1015let getActiveNotificationCountCallback = (err: BusinessError, data: number): void => {
1016  if (err) {
1017    console.error(`Failed to get active notification count. Code is ${err.code}, message is ${err.message}`);
1018  } else {
1019    console.info(`Succeeded in getting active notification count, data is ${JSON.stringify(data)}`);
1020  }
1021}
1022
1023notificationManager.getActiveNotificationCount(getActiveNotificationCountCallback);
1024```
1025
1026## notificationManager.getActiveNotificationCount
1027
1028getActiveNotificationCount(): Promise\<number\>
1029
1030获取当前应用未删除的通知数。使用Promise异步回调。
1031
1032**系统能力**:SystemCapability.Notification.Notification
1033
1034**返回值:**
1035
1036| 类型              | 说明                                        |
1037| ----------------- | ------------------------------------------- |
1038| Promise\<number\> | Promise对象,返回当前应用未删除通知数。 |
1039
1040**错误码:**
1041
1042以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1043
1044| 错误码ID | 错误信息                            |
1045| -------- | ----------------------------------- |
1046| 1600001  | Internal error.                     |
1047| 1600002  | Marshalling or unmarshalling error. |
1048| 1600003  | Failed to connect to the service.          |
1049
1050**示例:**
1051
1052```ts
1053import { BusinessError } from '@kit.BasicServicesKit';
1054
1055notificationManager.getActiveNotificationCount().then((data: number) => {
1056  console.info(`Succeeded in getting active notification count, data is ${JSON.stringify(data)}`);
1057}).catch((err: BusinessError) => {
1058  console.error(`Failed to get active notification count. Code is ${err.code}, message is ${err.message}`);
1059});
1060```
1061
1062## notificationManager.getActiveNotifications
1063
1064getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
1065
1066获取当前应用未删除的通知列表。使用callback异步回调。
1067
1068**系统能力**:SystemCapability.Notification.Notification
1069
1070**参数:**
1071
1072| 参数名     | 类型                                                         | 必填 | 说明                           |
1073| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
1074| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest-1)>> | 是   | 回调函数。当获取未删除的通知列表成功,err为undefined,data为获取到的通知列表,否则为错误对象。 |
1075
1076**错误码:**
1077
1078以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1079
1080| 错误码ID | 错误信息                            |
1081| -------- | ----------------------------------- |
1082| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1083| 1600001  | Internal error.                     |
1084| 1600002  | Marshalling or unmarshalling error. |
1085| 1600003  | Failed to connect to the service.          |
1086
1087**示例:**
1088
1089```ts
1090import { BusinessError } from '@kit.BasicServicesKit';
1091
1092let getActiveNotificationsCallback = (err: BusinessError, data: Array<notificationManager.NotificationRequest>): void => {
1093  if (err) {
1094    console.error(`Failed to get active notifications. Code is ${err.code}, message is ${err.message}`);
1095  } else {
1096    console.info(`Succeeded in getting active notifications, data is ${JSON.stringify(data)}`);
1097  }
1098}
1099notificationManager.getActiveNotifications(getActiveNotificationsCallback);
1100```
1101
1102## notificationManager.getActiveNotifications
1103
1104getActiveNotifications(): Promise\<Array\<NotificationRequest\>\>
1105
1106获取当前应用未删除的通知列表。使用Promise异步回调。
1107
1108**系统能力**:SystemCapability.Notification.Notification
1109
1110**返回值:**
1111
1112| 类型                                                         | 说明                                    |
1113| ------------------------------------------------------------ | --------------------------------------- |
1114| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest-1)\>\> | Promise对象,返回当前应用的通知列表。 |
1115
1116**错误码:**
1117
1118以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1119
1120| 错误码ID | 错误信息                            |
1121| -------- | ----------------------------------- |
1122| 1600001  | Internal error.                     |
1123| 1600002  | Marshalling or unmarshalling error. |
1124| 1600003  | Failed to connect to the service.          |
1125
1126**示例:**
1127
1128```ts
1129import { BusinessError } from '@kit.BasicServicesKit';
1130
1131notificationManager.getActiveNotifications().then((data: Array<notificationManager.NotificationRequest>) => {
1132  console.info(`Succeeded in getting active notifications, data is ${JSON.stringify(data)}`);
1133}).catch((err: BusinessError) => {
1134  console.error(`Failed to get active notifications. Code is ${err.code}, message is ${err.message}`);
1135});
1136```
1137
1138## notificationManager.cancelGroup
1139
1140cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
1141
1142取消当前应用指定组下的通知。使用callback异步回调。
1143
1144**系统能力**:SystemCapability.Notification.Notification
1145
1146**参数:**
1147
1148| 参数名      | 类型                  | 必填 | 说明                         |
1149| --------- | --------------------- | ---- | ---------------------------- |
1150| groupName | string                | 是   | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest-1)对象指定。 |
1151| callback  | AsyncCallback\<void\> | 是   | 回调函数。当取消当前应用指定组下的通知成功,err为undefined,否则为错误对象。 |
1152
1153**错误码:**
1154
1155以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1156
1157| 错误码ID | 错误信息                            |
1158| -------- | ----------------------------------- |
1159| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1160| 1600001  | Internal error.                     |
1161| 1600002  | Marshalling or unmarshalling error. |
1162| 1600003  | Failed to connect to the service.          |
1163
1164**示例:**
1165
1166```ts
1167import { BusinessError } from '@kit.BasicServicesKit';
1168
1169let cancelGroupCallback = (err: BusinessError): void => {
1170  if (err) {
1171    console.error(`Failed to cancel group. Code is ${err.code}, message is ${err.message}`);
1172  } else {
1173    console.info(`Succeeded in canceling group.`);
1174  }
1175}
1176let groupName: string = "GroupName";
1177notificationManager.cancelGroup(groupName, cancelGroupCallback);
1178```
1179
1180## notificationManager.cancelGroup
1181
1182cancelGroup(groupName: string): Promise\<void\>
1183
1184取消当前应用指定组下的通知。使用Promise异步回调。
1185
1186**系统能力**:SystemCapability.Notification.Notification
1187
1188**参数:**
1189
1190| 参数名      | 类型   | 必填 | 说明           |
1191| --------- | ------ | ---- | -------------- |
1192| groupName | string | 是   | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest-1)对象指定。 |
1193
1194**返回值:**
1195
1196| 类型      | 说明        |
1197|---------|-----------|
1198| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1199
1200**错误码:**
1201
1202以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1203
1204| 错误码ID | 错误信息                            |
1205| -------- | ----------------------------------- |
1206| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1207| 1600001  | Internal error.                     |
1208| 1600002  | Marshalling or unmarshalling error. |
1209| 1600003  | Failed to connect to the service.          |
1210
1211**示例:**
1212
1213```ts
1214import { BusinessError } from '@kit.BasicServicesKit';
1215
1216let groupName: string = "GroupName";
1217notificationManager.cancelGroup(groupName).then(() => {
1218  console.info(`Succeeded in canceling group.`);
1219}).catch((err: BusinessError) => {
1220  console.error(`Failed to cancel group. Code is ${err.code}, message is ${err.message}`);
1221});
1222```
1223
1224## notificationManager.isSupportTemplate
1225
1226isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void
1227
1228在使用[通知模板](js-apis-inner-notification-notificationTemplate.md)发布通知前,可以通过该接口查询是否支持对应的通知模板。使用callback异步回调。
1229
1230**系统能力**:SystemCapability.Notification.Notification
1231
1232**参数:**
1233
1234| 参数名       | 类型                     | 必填 | 说明                       |
1235| ------------ | ------------------------ | ---- | -------------------------- |
1236| templateName | string                   | 是   | 模板名称。当前仅支持'downloadTemplate'。                   |
1237| callback     | AsyncCallback\<boolean\> | 是   | 回调函数。返回true表示支持该模板;返回false表示不支持该模板;调用失败返回错误对象。 |
1238
1239**错误码:**
1240
1241以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1242
1243| 错误码ID | 错误信息                            |
1244| -------- | ----------------------------------- |
1245| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1246| 1600001  | Internal error.                     |
1247| 1600002  | Marshalling or unmarshalling error. |
1248| 1600003  | Failed to connect to the service.          |
1249
1250**示例:**
1251
1252```ts
1253import { BusinessError } from '@kit.BasicServicesKit';
1254
1255let templateName: string = 'downloadTemplate';
1256let isSupportTemplateCallback = (err: BusinessError, data: boolean): void => {
1257  if (err) {
1258    console.error(`isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
1259  } else {
1260    console.info(`isSupportTemplate success, data: ${JSON.stringify(data)}`);
1261  }
1262}
1263notificationManager.isSupportTemplate(templateName, isSupportTemplateCallback);
1264```
1265
1266## notificationManager.isSupportTemplate
1267
1268isSupportTemplate(templateName: string): Promise\<boolean\>
1269
1270在使用[通知模板](js-apis-inner-notification-notificationTemplate.md)发布通知前,可以通过该接口查询是否支持对应的通知模板。使用Promise异步回调。
1271
1272**系统能力**:SystemCapability.Notification.Notification
1273
1274**参数:**
1275
1276| 参数名       | 类型   | 必填 | 说明     |
1277| ------------ | ------ | ---- | -------- |
1278| templateName | string | 是   | 模板名称。当前仅支持'downloadTemplate'。 |
1279
1280**返回值:**
1281
1282| 类型               | 说明            |
1283| ------------------ | --------------- |
1284| Promise\<boolean\> | Promise对象。返回true表示支持该模板;返回false表示不支持该模板。 |
1285
1286**错误码:**
1287
1288以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1289
1290| 错误码ID | 错误信息                            |
1291| -------- | ----------------------------------- |
1292| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1293| 1600001  | Internal error.                     |
1294| 1600002  | Marshalling or unmarshalling error. |
1295| 1600003  | Failed to connect to the service.          |
1296
1297**示例:**
1298
1299```ts
1300import { BusinessError } from '@kit.BasicServicesKit';
1301
1302let templateName: string = 'downloadTemplate';
1303notificationManager.isSupportTemplate(templateName).then((data: boolean) => {
1304  console.info(`isSupportTemplate success, data: ${JSON.stringify(data)}`);
1305}).catch((err: BusinessError) => {
1306  console.error(`isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
1307});
1308```
1309
1310## notificationManager.requestEnableNotification<sup>10+</sup>
1311
1312requestEnableNotification(context: UIAbilityContext, callback: AsyncCallback\<void\>): void
1313
1314应用需要获取用户授权才能发送通知。在通知发布前调用该接口,可以拉起通知授权弹窗,让用户选择是否允许发送通知。使用callback异步回调。
1315
1316> **说明:**
1317>
1318> - 仅当应用界面加载完成后(即调用[loadContent](../apis-ability-kit/js-apis-app-ability-uiExtensionContentSession.md#loadcontent)成功),方可使用该接口。
1319> - 在使用该接口拉起通知授权弹窗后,如果用户拒绝授权,将无法使用该接口再次拉起弹窗。开发者可以调用[openNotificationSettings](#notificationmanageropennotificationsettings13)二次申请授权,拉起通知管理弹窗。
1320
1321**模型约束**:此接口仅可在Stage模型下使用。
1322
1323**系统能力**:SystemCapability.Notification.Notification
1324
1325**参数:**
1326
1327| 参数名   | 类型                     | 必填 | 说明                 |
1328| -------- | ------------------------ | ---- |--------------------|
1329| context | [UIAbilityContext](../../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) | 是   | 通知弹窗绑定Ability的上下文。 |
1330| callback | AsyncCallback\<void\> | 是   | 回调函数。当应用通过弹窗获取用户授权成功,err为undefined,否则为错误对象。     |
1331
1332**错误码:**
1333
1334以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1335
1336| 错误码ID | 错误信息                            |
1337| -------- | ----------------------------------- |
1338| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1339| 1600001  | Internal error.                     |
1340| 1600002  | Marshalling or unmarshalling error. |
1341| 1600003  | Failed to connect to the service.          |
1342| 1600004  | Notification disabled.          |
1343| 1600013  | A notification dialog box is already displayed.           |
1344
1345**示例:**
1346
1347```ts
1348import { BusinessError } from '@kit.BasicServicesKit';
1349import { UIAbility } from '@kit.AbilityKit';
1350import { window } from '@kit.ArkUI';
1351import { hilog } from '@kit.PerformanceAnalysisKit';
1352
1353class MyAbility extends UIAbility {
1354  onWindowStageCreate(windowStage: window.WindowStage) {
1355    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
1356    windowStage.loadContent('pages/Index', (err, data) => {
1357      if (err.code) {
1358        hilog.error(0x0000, 'testTag', `Failed to load the content. Cause: ${JSON.stringify(err) ?? ''}`);
1359        return;
1360      }
1361      hilog.info(0x0000, 'testTag', `Succeeded in loading the content. Data: ${JSON.stringify(data) ?? ''}`);
1362      let requestEnableNotificationCallback = (err: BusinessError): void => {
1363        if (err) {
1364          hilog.error(0x0000, 'testTag', `[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
1365        } else {
1366          hilog.info(0x0000, 'testTag', `[ANS] requestEnableNotification success`);
1367        }
1368      };
1369      notificationManager.requestEnableNotification(this.context, requestEnableNotificationCallback);
1370    });
1371  }
1372}
1373```
1374
1375## notificationManager.requestEnableNotification<sup>10+</sup>
1376
1377requestEnableNotification(context: UIAbilityContext): Promise\<void\>
1378
1379应用需要获取用户授权才能发送通知。在通知发布前调用该接口,可以拉起通知授权弹窗,让用户选择是否允许发送通知。使用Promise异步回调。
1380
1381> **说明:**
1382>
1383> - 仅当应用界面加载完成后(即调用[loadContent](../apis-ability-kit/js-apis-app-ability-uiExtensionContentSession.md#loadcontent)成功),方可使用该接口。
1384> - 在使用该接口拉起通知授权弹窗后,如果用户拒绝授权,将无法使用该接口再次拉起弹窗。开发者可以调用[openNotificationSettings](#notificationmanageropennotificationsettings13)二次申请授权,拉起通知管理弹窗。
1385
1386**模型约束**:此接口仅可在Stage模型下使用。
1387
1388**系统能力**:SystemCapability.Notification.Notification
1389
1390**参数:**
1391
1392| 参数名   | 类型                     | 必填 | 说明                 |
1393| -------- | ------------------------ | ---- |--------------------|
1394| context | [UIAbilityContext](../../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) | 是   | 通知弹窗绑定的Ability上下文。 |
1395
1396**返回值:**
1397
1398| 类型      | 说明        |
1399|---------|-----------|
1400| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1401
1402**错误码:**
1403
1404以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1405
1406| 错误码ID | 错误信息                            |
1407| -------- | ----------------------------------- |
1408| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1409| 1600001  | Internal error.                     |
1410| 1600002  | Marshalling or unmarshalling error. |
1411| 1600003  | Failed to connect to the service.          |
1412| 1600004  | Notification disabled.          |
1413| 1600013  | A notification dialog box is already displayed.           |
1414
1415**示例:**
1416
1417```ts
1418import { BusinessError } from '@kit.BasicServicesKit';
1419import { UIAbility } from '@kit.AbilityKit';
1420import { window } from '@kit.ArkUI';
1421import { hilog } from '@kit.PerformanceAnalysisKit';
1422
1423class MyAbility extends UIAbility {
1424  onWindowStageCreate(windowStage: window.WindowStage) {
1425    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
1426    windowStage.loadContent('pages/Index', (err, data) => {
1427      if (err.code) {
1428        hilog.error(0x0000, 'testTag', `Failed to load the content. Cause: ${JSON.stringify(err) ?? ''}`);
1429        return;
1430      }
1431      hilog.info(0x0000, 'testTag', `Succeeded in loading the content. Data: ${JSON.stringify(data) ?? ''}`);
1432      notificationManager.requestEnableNotification(this.context).then(() => {
1433        hilog.info(0x0000, 'testTag', `[ANS] requestEnableNotification success`);
1434      }).catch((err: BusinessError) => {
1435        hilog.error(0x0000, 'testTag', `[ANS] requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
1436      });
1437    });
1438  }
1439}
1440```
1441
1442## notificationManager.requestEnableNotification<sup>(deprecated)</sup>
1443
1444requestEnableNotification(callback: AsyncCallback\<void\>): void
1445
1446当前应用请求通知使能。使用callback异步回调。
1447
1448> **说明:**
1449>
1450> 从API version 12开始不再维护,建议使用有context入参的[requestEnableNotification](#notificationmanagerrequestenablenotification10)代替。
1451
1452**系统能力**:SystemCapability.Notification.Notification
1453
1454**参数:**
1455
1456| 参数名   | 类型                     | 必填 | 说明                       |
1457| -------- | ------------------------ | ---- | -------------------------- |
1458| callback | AsyncCallback\<void\> | 是   | 回调函数。当应用请求通知使能成功,err为undefined,否则为错误对象。 |
1459
1460**错误码:**
1461
1462以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1463
1464| 错误码ID | 错误信息                            |
1465| -------- | ----------------------------------- |
1466| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1467| 1600001  | Internal error.                     |
1468| 1600002  | Marshalling or unmarshalling error. |
1469| 1600003  | Failed to connect to the service.          |
1470| 1600004  | Notification disabled.          |
1471| 1600013  | A notification dialog box is already displayed.           |
1472
1473**示例:**
1474
1475```ts
1476import { BusinessError } from '@kit.BasicServicesKit';
1477
1478let requestEnableNotificationCallback = (err: BusinessError): void => {
1479  if (err) {
1480    console.error(`requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
1481  } else {
1482    console.info("requestEnableNotification success");
1483  }
1484};
1485notificationManager.requestEnableNotification(requestEnableNotificationCallback);
1486```
1487
1488## notificationManager.requestEnableNotification<sup>(deprecated)</sup>
1489
1490requestEnableNotification(): Promise\<void\>
1491
1492当前应用请求通知使能。使用Promise异步回调。
1493
1494> **说明:**
1495>
1496> 从API version 12开始不再维护,建议使用有context入参的[requestEnableNotification](#notificationmanagerrequestenablenotification10-1)代替。
1497
1498**系统能力**:SystemCapability.Notification.Notification
1499
1500**返回值:**
1501
1502| 类型      | 说明        |
1503|---------|-----------|
1504| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1505
1506**错误码:**
1507
1508以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1509
1510| 错误码ID | 错误信息                            |
1511| -------- | ----------------------------------- |
1512| 1600001  | Internal error.                     |
1513| 1600002  | Marshalling or unmarshalling error. |
1514| 1600003  | Failed to connect to the service.          |
1515| 1600004  | Notification disabled.          |
1516| 1600013  | A notification dialog box is already displayed.           |
1517
1518**示例:**
1519
1520```ts
1521import { BusinessError } from '@kit.BasicServicesKit';
1522
1523notificationManager.requestEnableNotification().then(() => {
1524  console.info("requestEnableNotification success");
1525}).catch((err: BusinessError) => {
1526  console.error(`requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
1527});
1528```
1529
1530## notificationManager.isDistributedEnabled
1531
1532isDistributedEnabled(callback: AsyncCallback\<boolean>): void
1533
1534查询设备是否支持跨设备协同通知。使用callback异步回调。
1535
1536**系统能力**:SystemCapability.Notification.Notification
1537
1538**参数:**
1539
1540| 参数名   | 类型                     | 必填 | 说明                       |
1541| -------- | ------------------------ | ---- | -------------------------- |
1542| callback | AsyncCallback\<boolean\> | 是   | 回调函数。返回true表示支持跨设备协同通知;返回false表示不支持跨设备协同通知;调用失败返回错误对象。 |
1543
1544**错误码:**
1545
1546以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1547
1548| 错误码ID | 错误信息                            |
1549| -------- | ----------------------------------- |
1550| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1551| 1600001  | Internal error.                     |
1552| 1600002  | Marshalling or unmarshalling error. |
1553| 1600003  | Failed to connect to the service.          |
1554| 1600010  | Distributed operation failed.       |
1555
1556**示例:**
1557
1558```ts
1559import { BusinessError } from '@kit.BasicServicesKit';
1560
1561let isDistributedEnabledCallback = (err: BusinessError, data: boolean): void => {
1562  if (err) {
1563    console.error(`isDistributedEnabled failed, code is ${err.code}, message is ${err.message}`);
1564  } else {
1565    console.info(`isDistributedEnabled success ${JSON.stringify(data)}`);
1566  }
1567};
1568notificationManager.isDistributedEnabled(isDistributedEnabledCallback);
1569```
1570
1571## notificationManager.isDistributedEnabled
1572
1573isDistributedEnabled(): Promise\<boolean>
1574
1575查询设备是否支持跨设备协同通知。使用Promise异步回调。
1576
1577**系统能力**:SystemCapability.Notification.Notification
1578
1579**返回值:**
1580
1581| 类型               | 说明                                          |
1582| ------------------ | --------------------------------------------- |
1583| Promise\<boolean\> | Promise对象。返回true表示支持跨设备协同通知;返回false表示不支持跨设备协同通知。 |
1584
1585**错误码:**
1586
1587以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1588
1589| 错误码ID | 错误信息                            |
1590| -------- | ----------------------------------- |
1591| 1600001  | Internal error.                     |
1592| 1600002  | Marshalling or unmarshalling error. |
1593| 1600003  | Failed to connect to the service.          |
1594| 1600010  | Distributed operation failed.       |
1595
1596**示例:**
1597
1598```ts
1599import { BusinessError } from '@kit.BasicServicesKit';
1600
1601notificationManager.isDistributedEnabled().then((data: boolean) => {
1602  console.info(`isDistributedEnabled success, data: ${JSON.stringify(data)}`);
1603}).catch((err: BusinessError) => {
1604  console.error(`isDistributedEnabled failed, code is ${err.code}, message is ${err.message}`);
1605});
1606```
1607
1608## notificationManager.openNotificationSettings<sup>13+</sup>
1609
1610openNotificationSettings(context: UIAbilityContext): Promise\<void\>
1611
1612拉起应用的通知设置界面,该页面以半模态形式呈现,可用于设置通知开关、通知提醒方式等。使用Promise异步回调。
1613
1614**模型约束**:此接口仅可在Stage模型下使用。
1615
1616**设备行为差异**:该接口在Wearable中返回801错误码,在其他设备类型中可正常调用。
1617
1618**系统能力**:SystemCapability.Notification.NotificationSettings
1619
1620**参数:**
1621
1622| 参数名   | 类型                     | 必填 | 说明                 |
1623| -------- | ------------------------ | ---- |--------------------|
1624| context | [UIAbilityContext](../../reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) | 是   | 通知设置页面绑定Ability的上下文。 |
1625
1626**返回值:**
1627
1628| 类型      | 说明        |
1629|---------|-----------|
1630| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
1631
1632**错误码:**
1633
1634以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1635
1636| 错误码ID | 错误信息                            |
1637| -------- | ----------------------------------- |
1638| 801 | Capability not supported. |
1639| 1600001  | Internal error.                     |
1640| 1600003  | Failed to connect to the service.          |
1641| 1600018  | the notification settings window is already displayed.           |
1642
1643**示例:**
1644
1645```ts
1646import { BusinessError } from '@kit.BasicServicesKit';
1647import { UIAbility } from '@kit.AbilityKit';
1648import { window } from '@kit.ArkUI';
1649import { hilog } from '@kit.PerformanceAnalysisKit';
1650
1651class MyAbility extends UIAbility {
1652  onWindowStageCreate(windowStage: window.WindowStage) {
1653    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
1654    windowStage.loadContent('pages/Index', (err, data) => {
1655      if (err.code) {
1656        hilog.error(0x0000, 'testTag', `Failed to load the content. Cause: ${JSON.stringify(err) ?? ''}`);
1657        return;
1658      }
1659      hilog.info(0x0000, 'testTag', `Succeeded in loading the content. Data: ${JSON.stringify(data) ?? ''}`);
1660      notificationManager.openNotificationSettings(this.context).then(() => {
1661        hilog.info(0x0000, 'testTag', `[ANS] openNotificationSettings success`);
1662      }).catch((err: BusinessError) => {
1663        hilog.error(0x0000, 'testTag', `[ANS] openNotificationSettings failed, code is ${err.code}, message is ${err.message}`);
1664      });
1665    });
1666  }
1667}
1668```
1669
1670## notificationManager.getNotificationSetting<sup>20+</sup>
1671
1672getNotificationSetting(): Promise\<NotificationSetting\>
1673
1674获取应用程序的通知设置。使用Promise异步回调。
1675
1676**系统能力**:SystemCapability.Notification.Notification
1677
1678**返回值:**
1679
1680| 类型               | 说明            |
1681| ------------------ | --------------- |
1682| Promise\<[NotificationSetting](#notificationsetting20)\> | Promise对象,返回此应用程序的通知设置。 |
1683
1684**错误码:**
1685
1686以下错误码的详细介绍请参见[通知错误码](./errorcode-notification.md)。
1687
1688| 错误码ID | 错误信息                            |
1689| -------- | ----------------------------------- |
1690| 1600001  | Internal error.                     |
1691| 1600002  | Marshalling or unmarshalling error. |
1692| 1600003  | Failed to connect to the service.          |
1693
1694**示例:**
1695
1696```ts
1697import { BusinessError } from '@kit.BasicServicesKit';
1698
1699notificationManager.getNotificationSetting().then((data: notificationManager.NotificationSetting) => {
1700    console.info(`getNotificationSetting success, data: ${JSON.stringify(data)}`);
1701}).catch((err: BusinessError) => {
1702    console.error(`getNotificationSetting failed, code is ${err.code}, message is ${err.message}`);
1703});
1704```
1705
1706## ContentType
1707
1708通知内容类型。
1709
1710**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1711
1712**系统能力**:SystemCapability.Notification.Notification
1713
1714| 名称                              | 值          | 说明               |
1715| --------------------------------- | ----------- |------------------|
1716| NOTIFICATION_CONTENT_BASIC_TEXT   | 0          | 普通文本类型通知。          |
1717| NOTIFICATION_CONTENT_LONG_TEXT    | 1          | 长文本类型通知。         |
1718| NOTIFICATION_CONTENT_PICTURE      | 2          | 图片类型通知。          |
1719| NOTIFICATION_CONTENT_CONVERSATION | 3          | 社交类型通知。预留能力,暂未支持。|
1720| NOTIFICATION_CONTENT_MULTILINE    | 4          | 多行文本类型通知。        |
1721| NOTIFICATION_CONTENT_SYSTEM_LIVE_VIEW<sup>11+</sup>    | 5 | 系统实况窗类型通知。不支持三方应用直接创建该类型通知。系统代理创建系统实况窗类型通知后,三方应用可以通过发布相同ID的通知来更新指定内容。|
1722| NOTIFICATION_CONTENT_LIVE_VIEW<sup>11+</sup>    | 6 | 普通实况窗类型通知。仅系统应用可用。  |
1723
1724## SlotLevel
1725
1726通知级别。
1727
1728**系统能力**:SystemCapability.Notification.Notification
1729
1730| 名称                              | 值          | 说明               |
1731| --------------------------------- | ----------- | ------------------ |
1732| LEVEL_NONE                        | 0           | 表示关闭通知功能。     |
1733| LEVEL_MIN                         | 1           | 表示通知功能已启用,状态栏中不显示通知图标,无横幅,无提示音。 |
1734| LEVEL_LOW                         | 2           | 表示通知功能已启用,状态栏中显示通知图标,无横幅,无提示音。 |
1735| LEVEL_DEFAULT                     | 3           | 表示通知功能已启用,状态栏中显示通知图标,无横幅,有提示音。 |
1736| LEVEL_HIGH                        | 4           | 表示通知功能已启用,状态栏中显示通知图标,有横幅,有提示音。 |
1737
1738
1739## SlotType
1740
1741通知渠道类型。
1742
1743**原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。
1744
1745**系统能力**:SystemCapability.Notification.Notification
1746
1747| 名称                 | 值       | 说明       |
1748| -------------------- | -------- | ---------- |
1749| UNKNOWN_TYPE         | 0 | 未知类型。该类型对应[SlotLevel](#slotlevel)为LEVEL_MIN。 |
1750| SOCIAL_COMMUNICATION | 1 | 社交通信。该类型对应[SlotLevel](#slotlevel)为LEVEL_HIGH。 |
1751| SERVICE_INFORMATION  | 2 | 服务提醒。该类型对应[SlotLevel](#slotlevel)为LEVEL_HIGH。|
1752| CONTENT_INFORMATION  | 3 | 内容资讯。该类型对应[SlotLevel](#slotlevel)为LEVEL_MIN。 |
1753| LIVE_VIEW<sup>11+</sup>            | 4 | 实况窗。不支持三方应用直接创建该渠道类型通知,可以由系统代理创建后,三方应用发布同ID的通知来更新指定内容。该类型对应[SlotLevel](#slotlevel)为LEVEL_DEFAULT。 |
1754| CUSTOMER_SERVICE<sup>11+</sup>     | 5 | 客服消息。该类型用于用户与商家之间的客服消息,需由用户主动发起。该类型对应[SlotLevel](#slotlevel)为LEVEL_DEFAULT。  |
1755| OTHER_TYPES          | 0xFFFF | 其他。该类型对应[SlotLevel](#slotlevel)为LEVEL_MIN。 |
1756
1757## NotificationSetting<sup>20+</sup>
1758
1759通知设置状态,包括是否开启振动、是否开启响铃。
1760
1761**系统能力**:SystemCapability.Notification.Notification
1762
1763| 名称             | 类型     | 只读 | 可选 | 说明                                         |
1764| ---------------- | ------- | ---- | ---- | ------------------------------------------- |
1765| vibrationEnabled | boolean | 否   |  否  | 表示是否开启振动。<br/> - true:开启。<br/> - false:关闭。 |
1766| soundEnabled     | boolean | 否   |  否  | 表示是否开启响铃。<br/> - true:开启。<br/> - false:关闭。 |
1767
1768## BundleOption
1769
1770type BundleOption = _BundleOption
1771
1772指定应用的包信息。
1773
1774**系统能力**: SystemCapability.Notification.Notification
1775
1776| 类型 | 说明 |
1777| --- | --- |
1778| [_BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 指定应用的包信息。 |
1779
1780## NotificationActionButton
1781
1782type NotificationActionButton = _NotificationActionButton
1783
1784通知中显示的操作按钮。
1785
1786**系统能力**: SystemCapability.Notification.Notification
1787
1788| 类型 | 说明 |
1789| --- | --- |
1790| [_NotificationActionButton](js-apis-inner-notification-notificationActionButton.md) | 通知中显示的操作按钮。 |
1791
1792## NotificationBasicContent
1793
1794type NotificationBasicContent = _NotificationBasicContent
1795
1796普通文本通知。
1797
1798**系统能力**: SystemCapability.Notification.Notification
1799
1800| 类型 | 说明 |
1801| --- | --- |
1802| [_NotificationBasicContent](js-apis-inner-notification-notificationContent.md#notificationbasiccontent) | 描述普通文本通知。 |
1803
1804## NotificationContent
1805
1806type NotificationContent = _NotificationContent
1807
1808通知内容。
1809
1810**系统能力**: SystemCapability.Notification.Notification
1811
1812| 类型 | 说明 |
1813| --- | --- |
1814| [_NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent-1) | 描述通知内容。 |
1815
1816## NotificationLongTextContent
1817
1818type NotificationLongTextContent = _NotificationLongTextContent
1819
1820长文本通知。
1821
1822**系统能力**: SystemCapability.Notification.Notification
1823
1824| 类型 | 说明 |
1825| --- | --- |
1826| [_NotificationLongTextContent](js-apis-inner-notification-notificationContent.md#notificationlongtextcontent) | 描述长文本通知。 |
1827
1828## NotificationMultiLineContent
1829
1830type NotificationMultiLineContent = _NotificationMultiLineContent
1831
1832多行文本通知。
1833
1834**系统能力**: SystemCapability.Notification.Notification
1835
1836| 类型 | 说明 |
1837| --- | --- |
1838| [_NotificationMultiLineContent](js-apis-inner-notification-notificationContent.md#notificationmultilinecontent) | 描述多行文本通知。 |
1839
1840## NotificationPictureContent
1841
1842type NotificationPictureContent = _NotificationPictureContent
1843
1844附有图片的通知。
1845
1846**系统能力**: SystemCapability.Notification.Notification
1847
1848| 类型 | 说明 |
1849| --- | --- |
1850| [_NotificationPictureContent](js-apis-inner-notification-notificationContent.md#notificationpicturecontent) | 附有图片的通知。 |
1851
1852## NotificationSystemLiveViewContent<sup>11+</sup>
1853
1854type NotificationSystemLiveViewContent = _NotificationSystemLiveViewContent
1855
1856系统实况窗通知内容。
1857
1858**系统能力**: SystemCapability.Notification.Notification
1859
1860| 类型 | 说明 |
1861| --- | --- |
1862| [_NotificationSystemLiveViewContent](js-apis-inner-notification-notificationContent.md#notificationsystemliveviewcontent) | 系统实况窗通知内容。 |
1863
1864## NotificationRequest
1865
1866type NotificationRequest = _NotificationRequest
1867
1868通知请求。
1869
1870**系统能力**: SystemCapability.Notification.Notification
1871
1872| 类型 | 说明 |
1873| --- | --- |
1874| [_NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest-1) | 通知请求。 |
1875
1876## DistributedOptions
1877
1878type DistributedOptions = _DistributedOptions
1879
1880分布式选项。
1881
1882**系统能力**: SystemCapability.Notification.Notification
1883
1884| 类型 | 说明 |
1885| --- | --- |
1886| [_DistributedOptions](js-apis-inner-notification-notificationRequest.md#distributedoptions8) | 分布式选项。 |
1887
1888## NotificationSlot
1889
1890type NotificationSlot = _NotificationSlot
1891
1892通知渠道。
1893
1894**系统能力**: SystemCapability.Notification.Notification
1895
1896| 类型 | 说明 |
1897| --- | --- |
1898| [_NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 通知渠道。 |
1899
1900## NotificationTemplate
1901
1902type NotificationTemplate = _NotificationTemplate
1903
1904通知模板。
1905
1906**系统能力**: SystemCapability.Notification.Notification
1907
1908| 类型 | 说明 |
1909| --- | --- |
1910| [_NotificationTemplate](js-apis-inner-notification-notificationTemplate.md) | 通知模板。 |
1911
1912## NotificationUserInput
1913
1914type NotificationUserInput = _NotificationUserInput
1915
1916保存用户输入的通知消息。
1917
1918**系统能力**: SystemCapability.Notification.Notification
1919
1920| 类型 | 说明 |
1921| --- | --- |
1922| [_NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | 保存用户输入的通知消息。 |
1923
1924## NotificationCapsule<sup>11+</sup>
1925
1926type NotificationCapsule = _NotificationCapsule
1927
1928通知胶囊。
1929
1930**系统能力**: SystemCapability.Notification.Notification
1931
1932| 类型 | 说明 |
1933| --- | --- |
1934| [_NotificationCapsule](js-apis-inner-notification-notificationContent.md#notificationcapsule11) | 通知胶囊。 |
1935
1936## NotificationButton<sup>11+</sup>
1937
1938type NotificationButton = _NotificationButton
1939
1940通知按钮。
1941
1942**系统能力**: SystemCapability.Notification.Notification
1943
1944| 类型 | 说明 |
1945| --- | --- |
1946| [_NotificationButton](js-apis-inner-notification-notificationContent.md#notificationbutton11) | 通知按钮。 |
1947
1948## NotificationTime<sup>11+</sup>
1949
1950type NotificationTime = _NotificationTime
1951
1952通知计时信息。
1953
1954**系统能力**: SystemCapability.Notification.Notification
1955
1956| 类型 | 说明 |
1957| --- | --- |
1958| [_NotificationTime](js-apis-inner-notification-notificationContent.md#notificationtime11) | 描述通知计时信息。 |
1959
1960## NotificationProgress<sup>11+</sup>
1961
1962type NotificationProgress = _NotificationProgress
1963
1964通知进度。
1965
1966**系统能力**: SystemCapability.Notification.Notification
1967
1968| 类型 | 说明 |
1969| --- | --- |
1970| [_NotificationProgress](js-apis-inner-notification-notificationContent.md#notificationprogress11) | 描述通知进度。 |
1971