• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.notificationManager (NotificationManager模块)(系统接口)
2
3本模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知渠道,获取通知的使能状态、角标使能状态,获取通知的相关信息等。
4
5> **说明:**
6>
7> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8>
9> 当前界面仅包含本模块的系统接口,其他公开接口参见[NotificationManager](./js-apis-notificationManager.md)。
10
11## 导入模块
12
13```ts
14import { notificationManager } from '@kit.NotificationKit';
15```
16
17## notificationManager.publish
18
19publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
20
21发布通知给指定的用户。使用callback异步回调。
22
23**系统能力**:SystemCapability.Notification.Notification
24
25**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.SEND_NOTIFICATION_CROSS_USER
26
27**系统接口**:此接口为系统接口。
28
29**参数:**
30
31| 参数名     | 类型                                        | 必填 | 说明                                        |
32| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
33| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
34| userId   | number                                      | 是   | 用户ID。                           |
35| callback | AsyncCallback\<void\>                       | 是   | 被指定的回调方法。                           |
36
37**错误码:**
38
39以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
40
41| 错误码ID | 错误信息                                              |
42| -------- | ---------------------------------------------------- |
43| 201      | Permission denied.     |
44| 202      | Not system application to call the interface.                                      |
45| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
46| 1600001  | Internal error.                                      |
47| 1600002  | Marshalling or unmarshalling error.                  |
48| 1600003  | Failed to connect to the service.                    |
49| 1600004  | Notification disabled.                               |
50| 1600005  | Notification slot disabled.                    |
51| 1600007  | The notification does not exist.                       |
52| 1600008  | The user does not exist.                               |
53| 1600009  | The notification sending frequency reaches the upper limit.            |
54| 1600012  | No memory space.                                     |
55| 1600014  | No permission.                                   |
56| 1600015  | The current notification status does not support duplicate configurations. |
57| 1600016  | The notification version for this update is too low. |
58| 1600020  | The application is not allowed to publish notifications due to permission control settings. |
59| 2300007  | Network unreachable.                              |
60
61**示例:**
62
63```ts
64import { BusinessError } from '@kit.BasicServicesKit';
65
66// publish回调
67let publishCallback = (err: BusinessError): void => {
68    if (err) {
69        console.error(`publish failed, code is ${err.code}, message is ${err.message}`);
70    } else {
71        console.info("publish success");
72    }
73}
74// 用户ID,使用时需替换为真实的userId。
75let userId: number = 1;
76// 通知Request对象
77let notificationRequest: notificationManager.NotificationRequest = {
78    id: 1,
79    content: {
80        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
81        normal: {
82            title: "test_title",
83            text: "test_text",
84            additionalText: "test_additionalText"
85        }
86    }
87};
88notificationManager.publish(notificationRequest, userId, publishCallback);
89```
90
91## notificationManager.publish
92
93publish(request: NotificationRequest, userId: number): Promise\<void\>
94
95发布通知给指定的用户。使用Promise异步回调。
96
97**系统能力**:SystemCapability.Notification.Notification
98
99**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.SEND_NOTIFICATION_CROSS_USER
100
101**系统接口**:此接口为系统接口。
102
103**参数:**
104
105| 参数名     |  类型                                        | 必填 | 说明                                        |
106| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
107| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
108| userId   | number                                      | 是   | 用户ID。                           |
109
110**返回值:**
111
112| 类型     | 说明        |
113| ------- |-----------|
114| Promise\<void\> | 无返回结果的Promise对象。 |
115
116**错误码:**
117
118以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
119
120| 错误码ID | 错误信息                                              |
121| -------- | ---------------------------------------------------- |
122| 201      | Permission denied.     |
123| 202      | Not system application to call the interface.                                      |
124| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
125| 1600001  | Internal error.                                      |
126| 1600002  | Marshalling or unmarshalling error.                  |
127| 1600003  | Failed to connect to the service.                           |
128| 1600004  | Notification disabled.                         |
129| 1600005  | Notification slot disabled.                    |
130| 1600007  | The notification does not exist.                       |
131| 1600008  | The user does not exist.                               |
132| 1600009  | The notification sending frequency reaches the upper limit.            |
133| 1600012  | No memory space.                                     |
134| 1600014  | No permission.                                   |
135| 1600015  | The current notification status does not support duplicate configurations. |
136| 1600016  | The notification version for this update is too low. |
137| 1600020  | The application is not allowed to publish notifications due to permission control settings. |
138| 2300007  | Network unreachable.                              |
139
140**示例:**
141
142```ts
143import { BusinessError } from '@kit.BasicServicesKit';
144
145let notificationRequest: notificationManager.NotificationRequest = {
146    id: 1,
147    content: {
148        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
149        normal: {
150            title: "test_title",
151            text: "test_text",
152            additionalText: "test_additionalText"
153        }
154    }
155};
156
157// 用户ID,使用时需替换为真实的userId。
158let userId: number = 1;
159
160notificationManager.publish(notificationRequest, userId).then(() => {
161	console.info("publish success");
162}).catch((err: BusinessError) => {
163    console.error(`publish failed, code is ${err.code}, message is ${err.message}`);
164});
165```
166
167## notificationManager.addSlot
168
169addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
170
171创建通知渠道。使用callback异步回调。
172
173**系统能力**:SystemCapability.Notification.Notification
174
175**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
176
177**系统接口**:此接口为系统接口。
178
179**参数:**
180
181| 参数名     | 类型                  | 必填 | 说明                 |
182| -------- | --------------------- | ---- | -------------------- |
183| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)       | 是   | 要创建的通知渠道对象。 |
184| callback | AsyncCallback\<void\> | 是   | 表示被指定通道的回调方法。 |
185
186**错误码:**
187
188以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
189
190| 错误码ID | 错误信息                            |
191| -------- | ----------------------------------- |
192| 201      | Permission denied.     |
193| 202      | Not system application to call the interface.                                      |
194| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
195| 1600001  | Internal error.                     |
196| 1600002  | Marshalling or unmarshalling error. |
197| 1600003  | Failed to connect to the service.          |
198| 1600012  | No memory space.                          |
199
200**示例:**
201
202```ts
203import { BusinessError } from '@kit.BasicServicesKit';
204
205// addslot回调
206let addSlotCallBack = (err: BusinessError): void => {
207    if (err) {
208        console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
209    } else {
210        console.info("addSlot success");
211    }
212}
213// 通知slot对象
214let notificationSlot: notificationManager.NotificationSlot = {
215    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
216};
217notificationManager.addSlot(notificationSlot, addSlotCallBack);
218```
219
220## notificationManager.addSlot
221
222addSlot(slot: NotificationSlot): Promise\<void\>
223
224创建通知渠道。使用Promise异步回调。
225
226**系统能力**:SystemCapability.Notification.Notification
227
228**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
229
230**系统接口**:此接口为系统接口。
231
232**参数:**
233
234| 参数名 | 类型             | 必填 | 说明                 |
235| ---- | ---------------- | ---- | -------------------- |
236| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md) | 是   | 要创建的通知渠道对象。 |
237
238**返回值:**
239
240| 类型     | 说明        |
241| ------- |-----------|
242| Promise\<void\> | 无返回结果的Promise对象。 |
243
244**错误码:**
245
246以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
247
248| 错误码ID | 错误信息                            |
249| -------- | ----------------------------------- |
250| 201      | Permission denied.     |
251| 202      | Not system application to call the interface.                                      |
252| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
253| 1600001  | Internal error.                     |
254| 1600002  | Marshalling or unmarshalling error. |
255| 1600003  | Failed to connect to the service.          |
256| 1600012  | No memory space.                          |
257
258**示例:**
259
260```ts
261import { BusinessError } from '@kit.BasicServicesKit';
262
263// 通知slot对象
264let notificationSlot: notificationManager.NotificationSlot = {
265    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
266};
267notificationManager.addSlot(notificationSlot).then(() => {
268	console.info("addSlot success");
269}).catch((err: BusinessError) => {
270    console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
271});
272```
273
274## notificationManager.addSlots
275
276addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
277
278创建多个通知渠道。使用callback异步回调。
279
280**系统能力**:SystemCapability.Notification.Notification
281
282**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
283
284**系统接口**:此接口为系统接口。
285
286**参数:**
287
288| 参数名     | 类型                      | 必填 | 说明                     |
289| -------- | ------------------------- | ---- | ------------------------ |
290| slots    | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)\> | 是   | 要创建的通知渠道对象数组。 |
291| callback | AsyncCallback\<void\>     | 是   | 表示被指定通道的回调方法。     |
292
293**错误码:**
294
295以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
296
297| 错误码ID | 错误信息                            |
298| -------- | ----------------------------------- |
299| 201      | Permission denied.     |
300| 202      | Not system application to call the interface.                                      |
301| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
302| 1600001  | Internal error.                     |
303| 1600002  | Marshalling or unmarshalling error. |
304| 1600003  | Failed to connect to the service.          |
305| 1600012  | No memory space.                          |
306
307**示例:**
308
309```ts
310import { BusinessError } from '@kit.BasicServicesKit';
311
312// addSlots回调
313let addSlotsCallBack = (err: BusinessError): void => {
314    if (err) {
315        console.error(`addSlots failed, code is ${err.code}, message is ${err.message}`);
316    } else {
317        console.info("addSlots success");
318    }
319}
320// 通知slot对象
321let notificationSlot: notificationManager.NotificationSlot = {
322    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
323};
324// 通知slot array 对象
325let notificationSlotArray: notificationManager.NotificationSlot[] = new Array();
326notificationSlotArray[0] = notificationSlot;
327
328notificationManager.addSlots(notificationSlotArray, addSlotsCallBack);
329```
330
331## notificationManager.addSlots
332
333addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
334
335创建多个通知渠道。使用Promise异步回调。
336
337**系统能力**:SystemCapability.Notification.Notification
338
339**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
340
341**系统接口**:此接口为系统接口。
342
343**参数:**
344
345| 参数名  | 类型                      | 必填 | 说明                     |
346| ----- | ------------------------- | ---- | ------------------------ |
347| slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)\> | 是   | 要创建的通知渠道对象数组。 |
348
349**返回值:**
350
351| 类型      | 说明        |
352|---------|-----------|
353| Promise\<void\> | 无返回结果的Promise对象。 |
354
355**错误码:**
356
357以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
358
359| 错误码ID | 错误信息                            |
360| -------- | ----------------------------------- |
361| 201      | Permission denied.     |
362| 202      | Not system application to call the interface.                                      |
363| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
364| 1600001  | Internal error.                     |
365| 1600002  | Marshalling or unmarshalling error. |
366| 1600003  | Failed to connect to the service.          |
367| 1600012  | No memory space.                          |
368
369**示例:**
370
371```ts
372import { BusinessError } from '@kit.BasicServicesKit';
373
374// 通知slot对象
375let notificationSlot: notificationManager.NotificationSlot = {
376    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
377};
378// 通知slot array 对象
379let notificationSlotArray: notificationManager.NotificationSlot[] = new Array();
380notificationSlotArray[0] = notificationSlot;
381
382notificationManager.addSlots(notificationSlotArray).then(() => {
383	console.info("addSlots success");
384}).catch((err: BusinessError) => {
385    console.error(`addSlots failed, code is ${err.code}, message is ${err.message}`);
386});
387```
388
389
390## notificationManager.setNotificationEnable
391
392setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
393
394设定指定应用的通知使能状态。使用callback异步回调。
395
396**系统能力**:SystemCapability.Notification.Notification
397
398**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
399
400**系统接口**:此接口为系统接口。
401
402**参数:**
403
404| 参数名     | 类型                  | 必填 | 说明                 |
405| -------- | --------------------- | ---- | -------------------- |
406| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)   | 是   | 指定应用的包信息。        |
407| enable   | boolean               | 是   | 使能状态(true:使能,false:禁止)。             |
408| callback | AsyncCallback\<void\> | 是   | 设定通知使能回调函数。 |
409
410**错误码:**
411
412以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
413
414| 错误码ID | 错误信息                                 |
415| -------- | ---------------------------------------- |
416| 201      | Permission denied.     |
417| 202      | Not system application to call the interface.                                      |
418| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
419| 1600001  | Internal error.                          |
420| 1600002  | Marshalling or unmarshalling error.      |
421| 1600003  | Failed to connect to the service.               |
422| 17700001 | The specified bundle name was not found. |
423
424**示例:**
425
426```ts
427import { BusinessError } from '@kit.BasicServicesKit';
428
429let setNotificationEnableCallback = (err: BusinessError): void => {
430    if (err) {
431        console.error(`setNotificationEnable failed, code is ${err.code}, message is ${err.message}`);
432    } else {
433        console.info("setNotificationEnable success");
434    }
435}
436let bundle: notificationManager.BundleOption = {
437    bundle: "bundleName1",
438};
439notificationManager.setNotificationEnable(bundle, false, setNotificationEnableCallback);
440```
441
442## notificationManager.setNotificationEnable
443
444setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
445
446设定指定应用的通知使能状态。使用Promise异步回调。
447
448**系统能力**:SystemCapability.Notification.Notification
449
450**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
451
452**系统接口**:此接口为系统接口。
453
454**参数:**
455
456| 参数名   | 类型         | 必填 | 说明       |
457| ------ | ------------ | ---- | ---------- |
458| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
459| enable | boolean      | 是   | 使能状态(true:使能,false:禁止)。   |
460
461**返回值:**
462
463| 类型      | 说明        |
464|---------|-----------|
465| Promise\<void\> | 无返回结果的Promise对象。 |
466
467**错误码:**
468
469以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
470
471| 错误码ID | 错误信息                                 |
472| -------- | ---------------------------------------- |
473| 201      | Permission denied.     |
474| 202      | Not system application to call the interface.                                      |
475| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
476| 1600001  | Internal error.                          |
477| 1600002  | Marshalling or unmarshalling error.      |
478| 1600003  | Failed to connect to the service.               |
479| 17700001 | The specified bundle name was not found. |
480
481**示例:**
482
483```ts
484import { BusinessError } from '@kit.BasicServicesKit';
485
486let bundle: notificationManager.BundleOption = {
487    bundle: "bundleName1",
488};
489notificationManager.setNotificationEnable(bundle, false).then(() => {
490	console.info("setNotificationEnable success");
491}).catch((err: BusinessError) => {
492    console.error(`setNotificationEnable failed, code is ${err.code}, message is ${err.message}`);
493});
494```
495
496## notificationManager.getAllNotificationEnabledBundles<sup>12+</sup>
497
498getAllNotificationEnabledBundles(): Promise<Array<BundleOption\>>
499
500获取允许通知的应用程序列表。使用Promise异步回调。
501
502**系统能力**:SystemCapability.Notification.Notification
503
504**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
505
506**系统接口**:此接口为系统接口。
507
508**返回值:**
509
510| 类型      | 说明        |
511|---------|-----------|
512| Promise<Array<[BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption)\>> | 返回允许通知的应用程序列表。 |
513
514**错误码:**
515
516以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
517
518| 错误码ID | 错误信息                            |
519| -------- | ----------------------------------- |
520| 201      | Permission denied.     |
521| 202      | Not system application to call the interface.                                      |
522| 1600001  | Internal error.                     |
523| 1600002  | Marshalling or unmarshalling error. |
524| 1600003  | Failed to connect to the service.          |
525
526**示例:**
527
528```ts
529import { BusinessError } from '@kit.BasicServicesKit';
530
531notificationManager.getAllNotificationEnabledBundles().then((data: Array<notificationManager.BundleOption>) => {
532    console.info("Enable bundle data is" + JSON.stringify(data));
533    data.forEach(element => {
534        console.info("Enable uid is " + JSON.stringify(element.uid));
535        console.info("Enable bundle is " + JSON.stringify(element.bundle));
536    });
537}).catch((err: BusinessError) => {
538    console.error(`getAllNotificationEnabledBundles failed, code is ${err.code}, message is ${err.message}`);
539})
540```
541
542## notificationManager.isNotificationEnabled
543
544isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
545
546获取指定应用的通知使能状态。使用callback异步回调。
547
548**系统能力**:SystemCapability.Notification.Notification
549
550**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
551
552**系统接口**:此接口为系统接口。
553
554**参数:**
555
556| 参数名     | 类型                  | 必填 | 说明                     |
557| -------- | --------------------- | ---- | ------------------------ |
558| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。            |
559| callback | AsyncCallback\<boolean\> | 是   | 获取通知使能状态回调函数(true:使能,false:禁止)。 |
560
561**错误码:**
562
563以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
564
565| 错误码ID | 错误信息                                 |
566| -------- | ---------------------------------------- |
567| 201      | Permission denied.     |
568| 202      | Not system application to call the interface.                                      |
569| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
570| 1600001  | Internal error.                          |
571| 1600002  | Marshalling or unmarshalling error.      |
572| 1600003  | Failed to connect to the service.               |
573| 17700001 | The specified bundle name was not found. |
574
575**示例:**
576
577```ts
578import { BusinessError } from '@kit.BasicServicesKit';
579
580let isNotificationEnabledCallback = (err: BusinessError, data: boolean): void => {
581    if (err) {
582        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
583    } else {
584        console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
585    }
586}
587
588let bundle: notificationManager.BundleOption = {
589    bundle: "bundleName1",
590};
591
592notificationManager.isNotificationEnabled(bundle, isNotificationEnabledCallback);
593```
594
595## notificationManager.isNotificationEnabled
596
597isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
598
599获取指定应用的通知使能状态。使用Promise异步回调。
600
601**系统能力**:SystemCapability.Notification.Notification
602
603**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
604
605**系统接口**:此接口为系统接口。
606
607**参数:**
608
609| 参数名   | 类型         | 必填 | 说明       |
610| ------ | ------------ | ---- | ---------- |
611| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
612
613**返回值:**
614
615| 类型               | 说明                                                |
616| ------------------ | --------------------------------------------------- |
617| Promise\<boolean\> | 以Promise形式返回获取指定应用的通知使能状态的结果(true:使能,false:禁止)。 |
618
619**错误码:**
620
621以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
622
623| 错误码ID | 错误信息                                 |
624| -------- | ---------------------------------------- |
625| 201      | Permission denied.     |
626| 202      | Not system application to call the interface.                                      |
627| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
628| 1600001  | Internal error.                          |
629| 1600002  | Marshalling or unmarshalling error.      |
630| 1600003  | Failed to connect to the service.               |
631| 17700001 | The specified bundle name was not found. |
632
633**示例:**
634
635```ts
636import { BusinessError } from '@kit.BasicServicesKit';
637
638let bundle: notificationManager.BundleOption = {
639    bundle: "bundleName1",
640};
641notificationManager.isNotificationEnabled(bundle).then((data: boolean) => {
642	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
643}).catch((err: BusinessError) => {
644    console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
645});
646```
647
648## notificationManager.isNotificationEnabled
649
650isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void
651
652获取指定用户ID下的通知使能状态。使用callback异步回调。
653
654**系统能力**:SystemCapability.Notification.Notification
655
656**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
657
658**系统接口**:此接口为系统接口。
659
660**参数:**
661
662| 参数名     | 类型                  | 必填 | 说明                     |
663| -------- | --------------------- | ---- | ------------------------ |
664| userId   | number                | 是   | 指定的用户ID。 |
665| callback | AsyncCallback\<boolean\> | 是   | 获取通知使能状态回调函数(true:使能,false:禁止)。 |
666
667**错误码:**
668
669以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
670
671| 错误码ID | 错误信息                            |
672| -------- | ----------------------------------- |
673| 201      | Permission denied.     |
674| 202      | Not system application to call the interface.                                      |
675| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
676| 1600001  | Internal error.                     |
677| 1600002  | Marshalling or unmarshalling error. |
678| 1600003  | Failed to connect to the service.          |
679| 1600008  | The user does not exist.              |
680
681**示例:**
682
683```ts
684import { BusinessError } from '@kit.BasicServicesKit';
685
686let isNotificationEnabledCallback = (err: BusinessError, data: boolean): void => {
687    if (err) {
688        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
689    } else {
690        console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
691    }
692}
693
694// 用户ID,使用时需替换为真实的userId。
695let userId: number = 1;
696
697notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
698```
699
700## notificationManager.isNotificationEnabled
701
702isNotificationEnabled(userId: number): Promise\<boolean\>
703
704获取指定用户下的通知使能状态。使用Promise异步回调。
705
706**系统能力**:SystemCapability.Notification.Notification
707
708**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
709
710**系统接口**:此接口为系统接口。
711
712**参数:**
713
714| 参数名   | 类型         | 必填 | 说明       |
715| ------ | ------------ | ---- | ---------- |
716| userId | number       | 是   | 指定的用户ID。 |
717
718**返回值:**
719
720| 类型                                                        | 说明                                                         |
721| ----------------------------------------------------------- | ------------------------------------------------------------ |
722| Promise\<boolean\> | 以Promise形式返回获取通知使能状态的结果(true:使能,false:禁止)。 |
723
724**错误码:**
725
726以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
727
728| 错误码ID | 错误信息                                 |
729| -------- | ---------------------------------------- |
730| 201      | Permission denied.     |
731| 202      | Not system application to call the interface.                                      |
732| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
733| 1600001  | Internal error.                          |
734| 1600002  | Marshalling or unmarshalling error.      |
735| 1600003  | Failed to connect to the service.               |
736| 1600008  | The user does not exist.                  |
737
738**示例:**
739
740```ts
741import { BusinessError } from '@kit.BasicServicesKit';
742
743// 用户ID,使用时需替换为真实的userId。
744let userId: number = 1;
745
746notificationManager.isNotificationEnabled(userId).then((data: boolean) => {
747	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
748}).catch((err: BusinessError) => {
749    console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
750});
751```
752
753## notificationManager.displayBadge
754
755displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
756
757设定指定应用的角标使能状态。使用callback异步回调。
758
759该接口不支持tv和wearable设备。
760
761**系统能力**:SystemCapability.Notification.Notification
762
763**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
764
765**系统接口**:此接口为系统接口。
766
767**参数:**
768
769| 参数名     | 类型                  | 必填 | 说明                 |
770| -------- | --------------------- | ---- | -------------------- |
771| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。           |
772| enable   | boolean               | 是   | 使能状态(true:使能,false:禁止)。             |
773| callback | AsyncCallback\<void\> | 是   | 设定角标使能回调函数。 |
774
775**错误码:**
776
777以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
778
779| 错误码ID | 错误信息                                 |
780| -------- | ---------------------------------------- |
781| 201      | Permission denied.     |
782| 202      | Not system application to call the interface.                                      |
783| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
784| 801 | Capability not supported. |
785| 1600001  | Internal error.                          |
786| 1600002  | Marshalling or unmarshalling error.      |
787| 1600003  | Failed to connect to the service.               |
788| 17700001 | The specified bundle name was not found. |
789
790**示例:**
791
792```ts
793import { BusinessError } from '@kit.BasicServicesKit';
794
795let displayBadgeCallback = (err: BusinessError): void => {
796    if (err) {
797        console.error(`displayBadge failed, code is ${err.code}, message is ${err.message}`);
798    } else {
799        console.info("displayBadge success");
800    }
801}
802let bundle: notificationManager.BundleOption = {
803    bundle: "bundleName1",
804};
805notificationManager.displayBadge(bundle, false, displayBadgeCallback);
806```
807
808## notificationManager.displayBadge
809
810displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
811
812设定指定应用的角标使能状态。使用Promise异步回调。
813
814该接口不支持tv和wearable设备。
815
816**系统能力**:SystemCapability.Notification.Notification
817
818**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
819
820**系统接口**:此接口为系统接口。
821
822**参数:**
823
824| 参数名   | 类型         | 必填 | 说明       |
825| ------ | ------------ | ---- | ---------- |
826| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
827| enable | boolean      | 是   | 使能状态(true:使能,false:禁止)。   |
828
829**返回值:**
830
831| 类型      | 说明        |
832|---------|-----------|
833| Promise\<void\> | 无返回结果的Promise对象。 |
834
835**错误码:**
836
837以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
838
839| 错误码ID | 错误信息                                 |
840| -------- | ---------------------------------------- |
841| 201      | Permission denied.     |
842| 202      | Not system application to call the interface.                                      |
843| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
844| 801 | Capability not supported. |
845| 1600001  | Internal error.                          |
846| 1600002  | Marshalling or unmarshalling error.      |
847| 1600003  | Failed to connect to the service.               |
848| 17700001 | The specified bundle name was not found. |
849
850**示例:**
851
852```ts
853import { BusinessError } from '@kit.BasicServicesKit';
854
855let bundle: notificationManager.BundleOption = {
856    bundle: "bundleName1",
857};
858notificationManager.displayBadge(bundle, false).then(() => {
859	console.info("displayBadge success");
860}).catch((err: BusinessError) => {
861    console.error(`displayBadge failed, code is ${err.code}, message is ${err.message}`);
862});
863```
864
865## notificationManager.isBadgeDisplayed
866
867isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
868
869获取指定应用的角标使能状态。使用callback异步回调。
870
871该接口不支持wearable设备。
872
873**系统能力**:SystemCapability.Notification.Notification
874
875**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
876
877**系统接口**:此接口为系统接口。
878
879**参数:**
880
881| 参数名     | 类型                  | 必填 | 说明                     |
882| -------- | --------------------- | ---- | ------------------------ |
883| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。               |
884| callback | AsyncCallback\<boolean\> | 是   | 获取角标使能状态回调函数(true:使能,false:禁止)。 |
885
886**错误码:**
887
888以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
889
890| 错误码ID | 错误信息                                 |
891| -------- | ---------------------------------------- |
892| 201      | Permission denied.     |
893| 202      | Not system application to call the interface.                                      |
894| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
895| 801 | Capability not supported. |
896| 1600001  | Internal error.                          |
897| 1600002  | Marshalling or unmarshalling error.      |
898| 1600003  | Failed to connect to the service.               |
899| 17700001 | The specified bundle name was not found. |
900
901**示例:**
902
903```ts
904import { BusinessError } from '@kit.BasicServicesKit';
905
906let isBadgeDisplayedCallback = (err: BusinessError, data: boolean): void => {
907    if (err) {
908        console.error(`isBadgeDisplayed failed, code is ${err.code}, message is ${err.message}`);
909    } else {
910        console.info(`isBadgeDisplayed success, data is ${JSON.stringify(data)}`);
911    }
912}
913let bundle: notificationManager.BundleOption = {
914    bundle: "bundleName1",
915};
916notificationManager.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
917```
918
919## notificationManager.isBadgeDisplayed
920
921isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
922
923获取指定应用的角标使能状态。使用Promise异步回调。
924
925该接口不支持wearable设备。
926
927**系统能力**:SystemCapability.Notification.Notification
928
929**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
930
931**系统接口**:此接口为系统接口。
932
933**参数:**
934
935| 参数名   | 类型         | 必填 | 说明       |
936| ------ | ------------ | ---- | ---------- |
937| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
938
939**返回值:**
940
941| 类型                                                        | 说明                                                         |
942| ----------------------------------------------------------- | ------------------------------------------------------------ |
943| Promise\<boolean\> | 以Promise形式返回获取指定应用的角标使能状态(true:使能,false:禁止)。 |
944
945**错误码:**
946
947以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
948
949| 错误码ID | 错误信息                                 |
950| -------- | ---------------------------------------- |
951| 201      | Permission denied.     |
952| 202      | Not system application to call the interface.                                      |
953| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
954| 801 | Capability not supported. |
955| 1600001  | Internal error.                          |
956| 1600002  | Marshalling or unmarshalling error.      |
957| 1600003  | Failed to connect to the service.               |
958| 17700001 | The specified bundle name was not found. |
959
960**示例:**
961
962```ts
963import { BusinessError } from '@kit.BasicServicesKit';
964
965let bundle: notificationManager.BundleOption = {
966  bundle: "bundleName1",
967};
968
969notificationManager.isBadgeDisplayed(bundle).then((data: boolean) => {
970	console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
971}).catch((err: BusinessError) => {
972    console.error(`isBadgeDisplayed failed, code is ${err.code}, message is ${err.message}`);
973});
974```
975
976## notificationManager.setSlotFlagsByBundle<sup>11+</sup>
977
978setSlotFlagsByBundle(bundle: BundleOption, slotFlags: number): Promise\<void\>
979
980设定指定应用的通知渠道。使用Promise异步回调。
981
982该接口不支持wearable设备。
983
984**系统能力**:SystemCapability.Notification.Notification
985
986**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
987
988**系统接口**:此接口为系统接口。
989
990**参数:**
991
992| 参数名   | 类型         | 必填 | 说明       |
993| ------ | ------------ | ---- | ---------- |
994| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
995| slotFlags   | number | 是   | 通知渠道标识位。<br>- bit0:铃声提示。0表示关闭,1表示开启。 <br>- bit1:锁屏。0表示关闭,1表示开启。 <br>- bit2:横幅。0表示关闭,1表示开启。 <br>- bit3:亮屏。0表示关闭,1表示开启。 <br>- bit4:振动。0表示关闭,1表示开启。 <br>- bit5:状态栏通知图标。0表示关闭,1表示开启。 |
996
997**返回值:**
998
999| 类型      | 说明        |
1000|---------|-----------|
1001| Promise\<void\> | 无返回结果的Promise对象。 |
1002
1003**错误码:**
1004
1005以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1006
1007| 错误码ID | 错误信息                                 |
1008| -------- | ---------------------------------------- |
1009| 201      | Permission denied.     |
1010| 202      | Not system application to call the interface.                                      |
1011| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1012| 801 | Capability not supported. |
1013| 1600001  | Internal error.                          |
1014| 1600002  | Marshalling or unmarshalling error.      |
1015| 1600003  | Failed to connect to the service.               |
1016| 17700001 | The specified bundle name was not found. |
1017
1018**示例:**
1019
1020```ts
1021import { BusinessError } from '@kit.BasicServicesKit';
1022
1023let bundle: notificationManager.BundleOption = {
1024    bundle: "bundleName1",
1025};
1026
1027let slotFlags: number = 1;
1028
1029notificationManager.setSlotFlagsByBundle(bundle, slotFlags).then(() => {
1030	console.info("setSlotFlagsByBundle success");
1031}).catch((err: BusinessError) => {
1032    console.error(`setSlotFlagsByBundle failed, code is ${err.code}, message is ${err.message}`);
1033});
1034```
1035
1036## notificationManager.setSlotByBundle
1037
1038setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
1039
1040设置指定应用的通知渠道。使用callback异步回调。
1041
1042设置前需要先通过[addSlot](#notificationmanageraddslot)创建通知渠道。
1043
1044该接口不支持wearable设备。
1045
1046**系统能力**:SystemCapability.Notification.Notification
1047
1048**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1049
1050**系统接口**:此接口为系统接口。
1051
1052**参数:**
1053
1054| 参数名     | 类型                  | 必填 | 说明                 |
1055| -------- | --------------------- | ---- | -------------------- |
1056| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 指定应用的包信息。           |
1057| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)      | 是   | 通知渠道。             |
1058| callback | AsyncCallback\<void\> | 是   | 设定通知渠道回调函数。 |
1059
1060**错误码:**
1061
1062以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1063
1064| 错误码ID | 错误信息                                 |
1065| -------- | ---------------------------------------- |
1066| 201      | Permission denied.     |
1067| 202      | Not system application to call the interface.                                      |
1068| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1069| 801 | Capability not supported. |
1070| 1600001  | Internal error.                          |
1071| 1600002  | Marshalling or unmarshalling error.      |
1072| 1600003  | Failed to connect to the service.               |
1073| 17700001 | The specified bundle name was not found. |
1074
1075**示例:**
1076
1077```ts
1078import { BusinessError } from '@kit.BasicServicesKit';
1079
1080let setSlotByBundleCallback = (err: BusinessError): void => {
1081    if (err) {
1082        console.error(`setSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
1083    } else {
1084        console.info("setSlotByBundle success");
1085    }
1086}
1087let bundle: notificationManager.BundleOption = {
1088    bundle: "bundleName1",
1089};
1090let notificationSlot: notificationManager.NotificationSlot = {
1091    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
1092};
1093notificationManager.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
1094```
1095
1096## notificationManager.setSlotByBundle
1097
1098setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
1099
1100设置指定应用的通知渠道。使用Promise异步回调。
1101
1102设置前需要先通过[addSlot](#notificationmanageraddslot)创建通知渠道。
1103
1104该接口不支持wearable设备。
1105
1106**系统能力**:SystemCapability.Notification.Notification
1107
1108**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1109
1110**系统接口**:此接口为系统接口。
1111
1112**参数:**
1113
1114| 参数名   | 类型         | 必填 | 说明       |
1115| ------ | ------------ | ---- | ---------- |
1116| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1117| slot   | [NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md) | 是   | 通知渠道。 |
1118
1119**返回值:**
1120
1121| 类型      | 说明        |
1122|---------|-----------|
1123| Promise\<void\> | 无返回结果的Promise对象。 |
1124
1125**错误码:**
1126
1127以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1128
1129| 错误码ID | 错误信息                                 |
1130| -------- | ---------------------------------------- |
1131| 201      | Permission denied.     |
1132| 202      | Not system application to call the interface.                                      |
1133| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1134| 801 | Capability not supported. |
1135| 1600001  | Internal error.                          |
1136| 1600002  | Marshalling or unmarshalling error.      |
1137| 1600003  | Failed to connect to the service.               |
1138| 17700001 | The specified bundle name was not found. |
1139
1140**示例:**
1141
1142```ts
1143import { BusinessError } from '@kit.BasicServicesKit';
1144
1145let bundle: notificationManager.BundleOption = {
1146    bundle: "bundleName1",
1147};
1148
1149let notificationSlot: notificationManager.NotificationSlot = {
1150    notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION
1151};
1152
1153notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => {
1154	console.info("setSlotByBundle success");
1155}).catch((err: BusinessError) => {
1156    console.error(`setSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
1157});
1158```
1159
1160## notificationManager.getSlotFlagsByBundle<sup>11+</sup>
1161
1162getSlotFlagsByBundle(bundle: BundleOption): Promise\<number\>
1163
1164获取指定应用的通知渠道标识位。使用Promise异步回调。
1165
1166该接口不支持wearable设备。
1167
1168**系统能力**:SystemCapability.Notification.Notification
1169
1170**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1171
1172**系统接口**:此接口为系统接口。
1173
1174**参数:**
1175
1176| 参数名   | 类型         | 必填 | 说明       |
1177| ------ | ------------ | ---- | ---------- |
1178| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1179
1180**返回值:**
1181
1182| 类型                                                        | 说明                                                         |
1183| ----------------------------------------------------------- | ------------------------------------------------------------ |
1184|  Promise\<number\>| 以Promise形式返回获取指定应用的通知渠道标识位。<br>- bit0:铃声提示。0表示关闭,1表示开启。 <br>- bit1:锁屏。0表示关闭,1表示开启。 <br>- bit2:横幅。0表示关闭,1表示开启。 <br>- bit3:亮屏。0表示关闭,1表示开启。 <br>- bit4:振动。0表示关闭,1表示开启。 <br>- bit5:状态栏通知图标。0表示关闭,1表示开启。 |
1185
1186**错误码:**
1187
1188以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1189
1190| 错误码ID | 错误信息                                 |
1191| -------- | ---------------------------------------- |
1192| 201      | Permission denied.     |
1193| 202      | Not system application to call the interface.                                      |
1194| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1195| 801 | Capability not supported. |
1196| 1600001  | Internal error.                          |
1197| 1600002  | Marshalling or unmarshalling error.      |
1198| 1600003  | Failed to connect to the service.               |
1199| 17700001 | The specified bundle name was not found. |
1200
1201**示例:**
1202
1203```ts
1204import { BusinessError } from '@kit.BasicServicesKit';
1205
1206let bundle: notificationManager.BundleOption = {
1207    bundle: "bundleName1",
1208};
1209notificationManager.getSlotFlagsByBundle(bundle).then((data : number) => {
1210	console.info("getSlotFlagsByBundle success, data: " + JSON.stringify(data));
1211}).catch((err: BusinessError) => {
1212    console.error(`getSlotFlagsByBundle failed, code is ${err.code}, message is ${err.message}`);
1213});
1214```
1215
1216## notificationManager.getSlotsByBundle
1217
1218getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
1219
1220获取指定应用的所有通知渠道。使用callback异步回调。
1221
1222该接口不支持wearable设备。
1223
1224**系统能力**:SystemCapability.Notification.Notification
1225
1226**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1227
1228**系统接口**:此接口为系统接口。
1229
1230**参数:**
1231
1232| 参数名     | 类型                                     | 必填 | 说明                 |
1233| -------- | ---------------------------------------- | ---- | -------------------- |
1234| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)                             | 是   | 指定应用的包信息。           |
1235| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)>> | 是   | 获取通知渠道回调函数。 |
1236
1237**错误码:**
1238
1239以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1240
1241| 错误码ID | 错误信息                                 |
1242| -------- | ---------------------------------------- |
1243| 201      | Permission denied.     |
1244| 202      | Not system application to call the interface.                                      |
1245| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1246| 801 | Capability not supported. |
1247| 1600001  | Internal error.                          |
1248| 1600002  | Marshalling or unmarshalling error.      |
1249| 1600003  | Failed to connect to the service.               |
1250| 17700001 | The specified bundle name was not found. |
1251
1252**示例:**
1253
1254```ts
1255import { BusinessError } from '@kit.BasicServicesKit';
1256
1257let getSlotsByBundleCallback = (err: BusinessError, data: Array<notificationManager.NotificationSlot>): void => {
1258    if (err) {
1259        console.error(`getSlotsByBundle failed, code is ${err.code}, message is ${err.message}`);
1260    } else {
1261        console.info(`getSlotsByBundle success, data is ${JSON.stringify(data)}`);
1262    }
1263}
1264let bundle: notificationManager.BundleOption = {
1265    bundle: "bundleName1",
1266};
1267notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback);
1268```
1269
1270## notificationManager.getSlotsByBundle
1271
1272getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
1273
1274获取指定应用的所有通知渠道。使用Promise异步回调。
1275
1276该接口不支持wearable设备。
1277
1278**系统能力**:SystemCapability.Notification.Notification
1279
1280**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1281
1282**系统接口**:此接口为系统接口。
1283
1284**参数:**
1285
1286| 参数名   | 类型         | 必填 | 说明       |
1287| ------ | ------------ | ---- | ---------- |
1288| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1289
1290**返回值:**
1291
1292| 类型                                                        | 说明                                                         |
1293| ----------------------------------------------------------- | ------------------------------------------------------------ |
1294| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)>> | 以Promise形式返回获取指定应用的通知渠道。 |
1295
1296**错误码:**
1297
1298以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1299
1300| 错误码ID | 错误信息                                 |
1301| -------- | ---------------------------------------- |
1302| 201      | Permission denied.     |
1303| 202      | Not system application to call the interface.                                      |
1304| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1305| 801 | Capability not supported. |
1306| 1600001  | Internal error.                          |
1307| 1600002  | Marshalling or unmarshalling error.      |
1308| 1600003  | Failed to connect to the service.               |
1309| 17700001 | The specified bundle name was not found. |
1310
1311**示例:**
1312
1313```ts
1314import { BusinessError } from '@kit.BasicServicesKit';
1315
1316let bundle: notificationManager.BundleOption = {
1317    bundle: "bundleName1",
1318};
1319
1320notificationManager.getSlotsByBundle(bundle).then((data: Array<notificationManager.NotificationSlot>) => {
1321	console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
1322}).catch((err: BusinessError) => {
1323    console.error(`getSlotsByBundle failed, code is ${err.code}, message is ${err.message}`);
1324});
1325```
1326
1327## notificationManager.getSlotNumByBundle
1328
1329getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
1330
1331获取指定应用的通知渠道数量。使用callback异步回调。
1332
1333该接口不支持wearable设备。
1334
1335**系统能力**:SystemCapability.Notification.Notification
1336
1337**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1338
1339**系统接口**:此接口为系统接口。
1340
1341**参数:**
1342
1343| 参数名     | 类型                      | 必填 | 说明                   |
1344| -------- | ------------------------- | ---- | ---------------------- |
1345| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)              | 是   | 指定应用的包信息。             |
1346| callback | AsyncCallback\<number\> | 是   | 获取通知渠道数量回调函数。 |
1347
1348**错误码:**
1349
1350以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1351
1352| 错误码ID | 错误信息                                 |
1353| -------- | ---------------------------------------- |
1354| 201      | Permission denied.     |
1355| 202      | Not system application to call the interface.                                      |
1356| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1357| 801 | Capability not supported. |
1358| 1600001  | Internal error.                          |
1359| 1600002  | Marshalling or unmarshalling error.      |
1360| 1600003  | Failed to connect to the service.               |
1361| 17700001 | The specified bundle name was not found. |
1362
1363**示例:**
1364
1365```ts
1366import { BusinessError } from '@kit.BasicServicesKit';
1367
1368let getSlotNumByBundleCallback = (err: BusinessError, data: number): void => {
1369    if (err) {
1370        console.error(`getSlotNumByBundle failed, code is ${err.code}, message is ${err.message}`);
1371    } else {
1372        console.info(`getSlotNumByBundle success data is ${JSON.stringify(data)}`);
1373    }
1374}
1375
1376let bundle: notificationManager.BundleOption = {
1377  bundle: "bundleName1",
1378};
1379
1380notificationManager.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
1381```
1382
1383## notificationManager.getSlotNumByBundle
1384
1385getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
1386
1387获取指定应用的通知渠道数量。使用Promise异步回调。
1388
1389该接口不支持wearable设备。
1390
1391**系统能力**:SystemCapability.Notification.Notification
1392
1393**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1394
1395**系统接口**:此接口为系统接口。
1396
1397**参数:**
1398
1399| 参数名   | 类型         | 必填 | 说明       |
1400| ------ | ------------ | ---- | ---------- |
1401| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
1402
1403**返回值:**
1404
1405| 类型                                                        | 说明                                                         |
1406| ----------------------------------------------------------- | ------------------------------------------------------------ |
1407| Promise\<number\> | 以Promise形式返回获取指定应用的通知渠道数量。 |
1408
1409**错误码:**
1410
1411以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1412
1413| 错误码ID | 错误信息                                 |
1414| -------- | ---------------------------------------- |
1415| 201      | Permission denied.     |
1416| 202      | Not system application to call the interface.                                      |
1417| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1418| 801 | Capability not supported. |
1419| 1600001  | Internal error.                          |
1420| 1600002  | Marshalling or unmarshalling error.      |
1421| 1600003  | Failed to connect to the service.               |
1422| 17700001 | The specified bundle name was not found. |
1423
1424**示例:**
1425
1426```ts
1427import { BusinessError } from '@kit.BasicServicesKit';
1428
1429let bundle: notificationManager.BundleOption = {
1430  bundle: "bundleName1",
1431};
1432
1433notificationManager.getSlotNumByBundle(bundle).then((data: number) => {
1434	console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
1435}).catch((err: BusinessError) => {
1436    console.error(`getSlotNumByBundle failed, code is ${err.code}, message is ${err.message}`);
1437});
1438```
1439
1440
1441## notificationManager.getAllActiveNotifications
1442
1443getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
1444
1445获取当前未删除的所有通知。使用callback异步回调。
1446
1447**系统能力**:SystemCapability.Notification.Notification
1448
1449**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1450
1451**系统接口**:此接口为系统接口。
1452
1453**参数:**
1454
1455| 参数名     | 类型                                                         | 必填 | 说明                 |
1456| -------- | ------------------------------------------------------------ | ---- | -------------------- |
1457| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)>> | 是   | 获取活动通知回调函数。 |
1458
1459**错误码:**
1460
1461以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1462
1463| 错误码ID | 错误信息                            |
1464| -------- | ----------------------------------- |
1465| 201      | Permission denied.     |
1466| 202      | Not system application to call the interface.                                      |
1467| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1468| 1600001  | Internal error.                     |
1469| 1600002  | Marshalling or unmarshalling error. |
1470| 1600003  | Failed to connect to the service.          |
1471
1472**示例:**
1473
1474```ts
1475import { BusinessError } from '@kit.BasicServicesKit';
1476
1477let getAllActiveNotificationsCallback = (err: BusinessError, data: Array<notificationManager.NotificationRequest>): void => {
1478    if (err) {
1479        console.error(`getAllActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
1480    } else {
1481        console.info(`getAllActiveNotifications success, data is ${JSON.stringify(data)}`);
1482    }
1483}
1484
1485notificationManager.getAllActiveNotifications(getAllActiveNotificationsCallback);
1486```
1487
1488## notificationManager.getAllActiveNotifications
1489
1490getAllActiveNotifications(): Promise\<Array\<NotificationRequest\>\>
1491
1492获取当前未删除的所有通知。使用Promise异步回调。
1493
1494**系统能力**:SystemCapability.Notification.Notification
1495
1496**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1497
1498**系统接口**:此接口为系统接口。
1499
1500**返回值:**
1501
1502| 类型                                                        | 说明                                                         |
1503| ----------------------------------------------------------- | ------------------------------------------------------------ |
1504| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)\>\> | 以Promise形式返回获取活动通知。 |
1505
1506**错误码:**
1507
1508以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1509
1510| 错误码ID | 错误信息                            |
1511| -------- | ----------------------------------- |
1512| 201      | Permission denied.     |
1513| 202      | Not system application to call the interface.                                      |
1514| 1600001  | Internal error.                     |
1515| 1600002  | Marshalling or unmarshalling error. |
1516| 1600003  | Failed to connect to the service.          |
1517
1518**示例:**
1519
1520```ts
1521import { BusinessError } from '@kit.BasicServicesKit';
1522
1523notificationManager.getAllActiveNotifications().then((data: Array<notificationManager.NotificationRequest>) => {
1524	console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
1525}).catch((err: BusinessError) => {
1526    console.error(`getAllActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
1527});
1528```
1529
1530## notificationManager.getActiveNotificationByFilter<sup>11+</sup>
1531
1532getActiveNotificationByFilter(filter: NotificationFilter, callback: AsyncCallback\<NotificationRequest\>): void
1533
1534获取满足条件的普通实况通知信息。使用callback异步回调。
1535
1536**系统能力**:SystemCapability.Notification.Notification
1537
1538**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1539
1540**系统接口**:此接口为系统接口。
1541
1542
1543**参数:**
1544
1545| 参数名     | 类型                                                         | 必填 | 说明                           |
1546| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
1547| filter   | [NotificationFilter](js-apis-inner-notification-notificationRequest-sys.md#notificationfilter11) | 是   | 查询普通实况窗的过滤条件。 |
1548| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)>> | 是   | 获取满足条件的普通实况通知信息的回调函数。 |
1549
1550**错误码:**
1551
1552以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1553
1554| 错误码ID | 错误信息                                  |
1555| -------- | ---------------------------------------- |
1556| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1557| 1600007  | The notification does not exist.           |
1558| 17700001 | The specified bundle name was not found. |
1559
1560**示例:**
1561
1562```ts
1563import { BusinessError } from '@kit.BasicServicesKit';
1564import { notificationSubscribe } from '@kit.NotificationKit';
1565
1566let bundleOption: notificationManager.BundleOption = {
1567  bundle: "bundleName1",
1568};
1569let notificationKey: notificationSubscribe.NotificationKey = {
1570    id: 11,
1571    label: ""
1572};
1573let filter: notificationManager.NotificationFilter = {
1574    bundle: bundleOption,
1575    notificationKey: notificationKey,
1576    extraInfoKeys: ['event']
1577}
1578let getActiveNotificationByFilterCallback = (err: BusinessError, data: notificationManager.NotificationRequest): void => {
1579    if (err) {
1580        console.error(`getActiveNotificationByFilter failed, code is ${err.code}, message is ${err.message}`);
1581    } else {
1582        console.info("getActiveNotificationByFilter success");
1583    }
1584}
1585notificationManager.getActiveNotificationByFilter(filter, getActiveNotificationByFilterCallback);
1586```
1587
1588## notificationManager.getActiveNotificationByFilter<sup>11+</sup>
1589
1590getActiveNotificationByFilter(filter: NotificationFilter): Promise\<NotificationRequest\>
1591
1592获取满足条件的普通实况通知信息。使用Promise异步回调。
1593
1594**系统能力**:SystemCapability.Notification.Notification
1595
1596**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1597
1598**系统接口**:此接口为系统接口。
1599
1600
1601**参数:**
1602
1603| 参数名     | 类型                                                         | 必填 | 说明                           |
1604| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
1605| filter   | [NotificationFilter](js-apis-inner-notification-notificationRequest-sys.md#notificationfilter11) | 是   | 查询普通实况窗的过滤条件。 |
1606
1607**返回值:**
1608
1609| 类型                                                         | 说明                                    |
1610| ------------------------------------------------------------ | --------------------------------------- |
1611| Promise\<[NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest)\> | 以Promise形式返回获取的满足条件的普通实况通知信息。 |
1612
1613**错误码:**
1614
1615以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1616
1617| 错误码ID | 错误信息                                  |
1618| -------- | ---------------------------------------- |
1619| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1620| 1600007  | The notification does not exist.         |
1621| 17700001 | The specified bundle name was not found. |
1622
1623**示例:**
1624
1625```ts
1626import { BusinessError } from '@kit.BasicServicesKit';
1627import { notificationSubscribe } from '@kit.NotificationKit';
1628
1629let bundleOption: notificationManager.BundleOption = {
1630  bundle: "bundleName1",
1631};
1632let notificationKey: notificationSubscribe.NotificationKey = {
1633    id: 11,
1634    label: ""
1635};
1636let filter: notificationManager.NotificationFilter = {
1637    bundle: bundleOption,
1638    notificationKey: notificationKey,
1639    extraInfoKeys: ['event']
1640}
1641notificationManager.getActiveNotificationByFilter(filter).then((data: notificationManager.NotificationRequest) => {
1642	console.info("getActiveNotificationByFilter success, data: " + JSON.stringify(data));
1643}).catch((err: BusinessError) => {
1644    console.error(`getActiveNotificationByFilter failed, code is ${err.code}, message is ${err.message}`);
1645});
1646```
1647
1648## notificationManager.removeGroupByBundle
1649
1650removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
1651
1652删除指定应用的指定组下的通知。使用callback异步回调。
1653
1654**系统能力**:SystemCapability.Notification.Notification
1655
1656**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1657
1658**系统接口**:此接口为系统接口。
1659
1660**参数:**
1661
1662| 参数名      | 类型                  | 必填 | 说明                         |
1663| --------- | --------------------- | ---- | ---------------------------- |
1664| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | 是   | 应用的包信息。                   |
1665| groupName | string                | 是   | 通知组名称。               |
1666| callback  | AsyncCallback\<void\> | 是   | 删除指定应用指定组下通知的回调函数。 |
1667
1668**错误码:**
1669
1670以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1671
1672| 错误码ID | 错误信息                                 |
1673| -------- | ---------------------------------------- |
1674| 201      | Permission denied.     |
1675| 202      | Not system application to call the interface.                                      |
1676| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1677| 1600001  | Internal error.                          |
1678| 1600002  | Marshalling or unmarshalling error.      |
1679| 1600003  | Failed to connect to the service.               |
1680| 17700001 | The specified bundle name was not found. |
1681
1682**示例:**
1683
1684```ts
1685import { BusinessError } from '@kit.BasicServicesKit';
1686
1687let removeGroupByBundleCallback = (err: BusinessError): void => {
1688    if (err) {
1689        console.error(`removeGroupByBundle failed, code is ${err.code}, message is ${err.message}`);
1690    } else {
1691        console.info("removeGroupByBundle success");
1692    }
1693}
1694
1695let bundleOption: notificationManager.BundleOption = { bundle: "Bundle" };
1696let groupName: string = "GroupName";
1697
1698notificationManager.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
1699```
1700
1701## notificationManager.removeGroupByBundle
1702
1703removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
1704
1705删除指定应用的指定组下的通知。使用Promise异步回调。
1706
1707**系统能力**:SystemCapability.Notification.Notification
1708
1709**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1710
1711**系统接口**:此接口为系统接口。
1712
1713**参数:**
1714
1715| 参数名      | 类型         | 必填 | 说明           |
1716| --------- | ------------ | ---- | -------------- |
1717| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。     |
1718| groupName | string       | 是   | 通知组名称。 |
1719
1720**返回值:**
1721
1722| 类型      | 说明        |
1723|---------|-----------|
1724| Promise\<void\> | 无返回结果的Promise对象。 |
1725
1726**错误码:**
1727
1728以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1729
1730| 错误码ID | 错误信息                                 |
1731| -------- | ---------------------------------------- |
1732| 201      | Permission denied.     |
1733| 202      | Not system application to call the interface.                                      |
1734| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1735| 1600001  | Internal error.                          |
1736| 1600002  | Marshalling or unmarshalling error.      |
1737| 1600003  | Failed to connect to the service.               |
1738| 17700001 | The specified bundle name was not found. |
1739
1740**示例:**
1741
1742```ts
1743import { BusinessError } from '@kit.BasicServicesKit';
1744
1745let bundleOption: notificationManager.BundleOption = { bundle: "Bundle" };
1746let groupName: string = "GroupName";
1747
1748notificationManager.removeGroupByBundle(bundleOption, groupName).then(() => {
1749	console.info("removeGroupByBundle success");
1750}).catch((err: BusinessError) => {
1751    console.error(`removeGroupByBundle failed, code is ${err.code}, message is ${err.message}`);
1752});
1753```
1754
1755## notificationManager.setDoNotDisturbDate
1756
1757setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
1758
1759设置免打扰时间。使用callback异步回调。
1760
1761该接口不支持tv和wearable设备。
1762
1763**系统能力**:SystemCapability.Notification.Notification
1764
1765**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1766
1767**系统接口**:此接口为系统接口。
1768
1769**参数:**
1770
1771| 参数名     | 类型                  | 必填 | 说明                   |
1772| -------- | --------------------- | ---- | ---------------------- |
1773| date     | [DoNotDisturbDate](#donotdisturbdate)      | 是   | 免打扰时间选项。         |
1774| callback | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |
1775
1776**错误码:**
1777
1778以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1779
1780| 错误码ID | 错误信息                            |
1781| -------- | ----------------------------------- |
1782| 201      | Permission denied.     |
1783| 202      | Not system application to call the interface.                                      |
1784| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1785| 801 | Capability not supported. |
1786| 1600001  | Internal error.                     |
1787| 1600002  | Marshalling or unmarshalling error. |
1788| 1600003  | Failed to connect to the service.          |
1789| 1600012  | No memory space.                          |
1790
1791**示例:**
1792
1793```ts
1794import { BusinessError } from '@kit.BasicServicesKit';
1795
1796let setDoNotDisturbDateCallback = (err: BusinessError): void => {
1797    if (err) {
1798        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
1799    } else {
1800        console.info("setDoNotDisturbDate success");
1801    }
1802}
1803
1804let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1805    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1806    begin: new Date(),
1807    end: new Date(2021, 11, 15, 18, 0)
1808};
1809
1810notificationManager.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
1811```
1812
1813## notificationManager.setDoNotDisturbDate
1814
1815setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
1816
1817设置免打扰时间。使用Promise异步回调。
1818
1819该接口不支持tv和wearable设备。
1820
1821**系统能力**:SystemCapability.Notification.Notification
1822
1823**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1824
1825**系统接口**:此接口为系统接口。
1826
1827**参数:**
1828
1829| 参数名 | 类型             | 必填 | 说明           |
1830| ---- | ---------------- | ---- | -------------- |
1831| date | [DoNotDisturbDate](#donotdisturbdate) | 是   | 免打扰时间选项。 |
1832
1833
1834**返回值:**
1835
1836| 类型      | 说明        |
1837|---------|-----------|
1838| Promise\<void\> | 无返回结果的Promise对象。 |
1839
1840**错误码:**
1841
1842以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1843
1844| 错误码ID | 错误信息                            |
1845| -------- | ----------------------------------- |
1846| 201      | Permission denied.     |
1847| 202      | Not system application to call the interface.                                      |
1848| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1849| 801 | Capability not supported. |
1850| 1600001  | Internal error.                     |
1851| 1600002  | Marshalling or unmarshalling error. |
1852| 1600003  | Failed to connect to the service.          |
1853| 1600012  | No memory space.                          |
1854
1855**示例:**
1856
1857```ts
1858import { BusinessError } from '@kit.BasicServicesKit';
1859
1860let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1861    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1862    begin: new Date(),
1863    end: new Date(2021, 11, 15, 18, 0)
1864};
1865notificationManager.setDoNotDisturbDate(doNotDisturbDate).then(() => {
1866	console.info("setDoNotDisturbDate success");
1867}).catch((err: BusinessError) => {
1868    console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
1869});
1870```
1871
1872
1873## notificationManager.setDoNotDisturbDate
1874
1875setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void
1876
1877指定用户设置免打扰时间。使用callback异步回调。
1878
1879该接口不支持tv和wearable设备。
1880
1881**系统能力**:SystemCapability.Notification.Notification
1882
1883**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1884
1885**系统接口**:此接口为系统接口。
1886
1887**参数:**
1888
1889| 参数名     | 类型                  | 必填 | 说明                   |
1890| -------- | --------------------- | ---- | ---------------------- |
1891| date     | [DoNotDisturbDate](#donotdisturbdate)      | 是   | 免打扰时间选项。         |
1892| userId   | number                | 是   | 设置免打扰时间的用户ID。 |
1893| callback | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |
1894
1895**错误码:**
1896
1897以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1898
1899| 错误码ID | 错误信息                            |
1900| -------- | ----------------------------------- |
1901| 201      | Permission denied.     |
1902| 202      | Not system application to call the interface.                                      |
1903| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1904| 801 | Capability not supported. |
1905| 1600001  | Internal error.                     |
1906| 1600002  | Marshalling or unmarshalling error. |
1907| 1600003  | Failed to connect to the service.          |
1908| 1600008  | The user does not exist.              |
1909| 1600012  | No memory space.                          |
1910
1911**示例:**
1912
1913```ts
1914import { BusinessError } from '@kit.BasicServicesKit';
1915
1916let setDoNotDisturbDateCallback = (err: BusinessError): void => {
1917    if (err) {
1918        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
1919    } else {
1920        console.info("setDoNotDisturbDate success");
1921    }
1922}
1923
1924let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1925    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1926    begin: new Date(),
1927    end: new Date(2021, 11, 15, 18, 0)
1928};
1929
1930// 用户ID,使用时需替换为真实的userId。
1931let userId: number = 1;
1932
1933notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
1934```
1935
1936## notificationManager.setDoNotDisturbDate
1937
1938setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
1939
1940指定用户设置免打扰时间。使用Promise异步回调。
1941
1942该接口不支持tv和wearable设备。
1943
1944**系统能力**:SystemCapability.Notification.Notification
1945
1946**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
1947
1948**系统接口**:此接口为系统接口。
1949
1950**参数:**
1951
1952| 参数名   | 类型             | 必填 | 说明           |
1953| ------ | ---------------- | ---- | -------------- |
1954| date   | [DoNotDisturbDate](#donotdisturbdate) | 是   | 免打扰时间选项。 |
1955| userId | number           | 是   | 设置免打扰时间的用户ID。 |
1956
1957**返回值:**
1958
1959| 类型      | 说明        |
1960|---------|-----------|
1961| Promise\<void\> | 无返回结果的Promise对象。 |
1962
1963**错误码:**
1964
1965以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
1966
1967| 错误码ID | 错误信息                            |
1968| -------- | ----------------------------------- |
1969| 201      | Permission denied.     |
1970| 202      | Not system application to call the interface.                                      |
1971| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
1972| 801 | Capability not supported. |
1973| 1600001  | Internal error.                     |
1974| 1600002  | Marshalling or unmarshalling error. |
1975| 1600003  | Failed to connect to the service.          |
1976| 1600008  | The user does not exist.              |
1977| 1600012  | No memory space.                          |
1978
1979**示例:**
1980
1981```ts
1982import { BusinessError } from '@kit.BasicServicesKit';
1983
1984let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
1985    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
1986    begin: new Date(),
1987    end: new Date(2021, 11, 15, 18, 0)
1988};
1989
1990// 用户ID,使用时需替换为真实的userId。
1991let userId: number = 1;
1992
1993notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
1994	console.info("setDoNotDisturbDate success");
1995}).catch((err: BusinessError) => {
1996    console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
1997});
1998```
1999
2000
2001## notificationManager.getDoNotDisturbDate
2002
2003getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
2004
2005查询免打扰时间。使用callback异步回调。
2006
2007该接口不支持tv和wearable设备。
2008
2009**系统能力**:SystemCapability.Notification.Notification
2010
2011**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2012
2013**系统接口**:此接口为系统接口。
2014
2015**参数:**
2016
2017| 参数名     | 类型                              | 必填 | 说明                   |
2018| -------- | --------------------------------- | ---- | ---------------------- |
2019| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是   | 查询免打扰时间回调函数。 |
2020
2021**错误码:**
2022
2023以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2024
2025| 错误码ID | 错误信息                            |
2026| -------- | ----------------------------------- |
2027| 201      | Permission denied.     |
2028| 202      | Not system application to call the interface.                                      |
2029| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2030| 801 | Capability not supported. |
2031| 1600001  | Internal error.                     |
2032| 1600002  | Marshalling or unmarshalling error. |
2033| 1600003  | Failed to connect to the service.          |
2034| 1600012  | No memory space.                          |
2035
2036**示例:**
2037
2038```ts
2039import { BusinessError } from '@kit.BasicServicesKit';
2040
2041let getDoNotDisturbDateCallback = (err: BusinessError, data: notificationManager.DoNotDisturbDate): void => {
2042    if (err) {
2043        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2044    } else {
2045        console.info(`getDoNotDisturbDate success, data is ${JSON.stringify(data)}`);
2046    }
2047}
2048
2049notificationManager.getDoNotDisturbDate(getDoNotDisturbDateCallback);
2050```
2051
2052## notificationManager.getDoNotDisturbDate
2053
2054getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
2055
2056查询免打扰时间。使用Promise异步回调。
2057
2058该接口不支持tv和wearable设备。
2059
2060**系统能力**:SystemCapability.Notification.Notification
2061
2062**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2063
2064**系统接口**:此接口为系统接口。
2065
2066**返回值:**
2067
2068| 类型                                             | 说明                                      |
2069| ------------------------------------------------ | ----------------------------------------- |
2070| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
2071
2072**错误码:**
2073
2074以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2075
2076| 错误码ID | 错误信息                            |
2077| -------- | ----------------------------------- |
2078| 201      | Permission denied.     |
2079| 202      | Not system application to call the interface.                                      |
2080| 801 | Capability not supported. |
2081| 1600001  | Internal error.                     |
2082| 1600002  | Marshalling or unmarshalling error. |
2083| 1600003  | Failed to connect to the service.          |
2084| 1600012  | No memory space.                          |
2085
2086**示例:**
2087
2088```ts
2089import { BusinessError } from '@kit.BasicServicesKit';
2090
2091notificationManager.getDoNotDisturbDate().then((data: notificationManager.DoNotDisturbDate) => {
2092  console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
2093}).catch((err: BusinessError) => {
2094    console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2095});
2096```
2097
2098
2099## notificationManager.getDoNotDisturbDate
2100
2101getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
2102
2103查询指定用户的免打扰时间。使用callback异步回调。
2104
2105该接口不支持tv和wearable设备。
2106
2107**系统能力**:SystemCapability.Notification.Notification
2108
2109**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2110
2111**系统接口**:此接口为系统接口。
2112
2113**参数:**
2114
2115| 参数名     | 类型                              | 必填 | 说明                   |
2116| -------- | --------------------------------- | ---- | ---------------------- |
2117| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是   | 查询免打扰时间回调函数。 |
2118| userId   | number                            | 是   | 用户ID。 |
2119
2120**错误码:**
2121
2122以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2123
2124| 错误码ID | 错误信息                            |
2125| -------- | ----------------------------------- |
2126| 201      | Permission denied.     |
2127| 202      | Not system application to call the interface.                                      |
2128| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2129| 801 | Capability not supported. |
2130| 1600001  | Internal error.                     |
2131| 1600002  | Marshalling or unmarshalling error. |
2132| 1600003  | Failed to connect to the service.          |
2133| 1600008  | The user does not exist.              |
2134| 1600012  | No memory space.                          |
2135
2136**示例:**
2137
2138```ts
2139import { BusinessError } from '@kit.BasicServicesKit';
2140
2141let getDoNotDisturbDateCallback = (err: BusinessError, data: notificationManager.DoNotDisturbDate): void => {
2142    if (err) {
2143        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2144    } else {
2145        console.info(`getDoNotDisturbDate success, data is ${JSON.stringify(data)}`);
2146    }
2147}
2148
2149// 用户ID,使用时需替换为真实的userId。
2150let userId: number = 1;
2151
2152notificationManager.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
2153```
2154
2155## notificationManager.getDoNotDisturbDate
2156
2157getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
2158
2159查询指定用户的免打扰时间。使用Promise异步回调。
2160
2161该接口不支持tv和wearable设备。
2162
2163**系统能力**:SystemCapability.Notification.Notification
2164
2165**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2166
2167**系统接口**:此接口为系统接口。
2168
2169**参数:**
2170
2171| 参数名     | 类型                              | 必填 | 说明                   |
2172| -------- | --------------------------------- | ---- | ---------------------- |
2173| userId   | number                            | 是   | 用户ID。 |
2174
2175**返回值:**
2176
2177| 类型                                             | 说明                                      |
2178| ------------------------------------------------ | ----------------------------------------- |
2179| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
2180
2181**错误码:**
2182
2183以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2184
2185| 错误码ID | 错误信息                            |
2186| -------- | ----------------------------------- |
2187| 201      | Permission denied.     |
2188| 202      | Not system application to call the interface.                                      |
2189| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2190| 801 | Capability not supported. |
2191| 1600001  | Internal error.                     |
2192| 1600002  | Marshalling or unmarshalling error. |
2193| 1600003  | Failed to connect to the service.          |
2194| 1600008  | The user does not exist.              |
2195| 1600012  | No memory space.                          |
2196
2197**示例:**
2198
2199```ts
2200import { BusinessError } from '@kit.BasicServicesKit';
2201
2202// 用户ID,使用时需替换为真实的userId。
2203let userId: number = 1;
2204
2205notificationManager.getDoNotDisturbDate(userId).then((data: notificationManager.DoNotDisturbDate) => {
2206	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
2207}).catch((err: BusinessError) => {
2208    console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
2209});
2210```
2211
2212
2213## notificationManager.isSupportDoNotDisturbMode
2214
2215 isSupportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
2216
2217查询是否支持免打扰功能。使用callback异步回调。
2218
2219该接口不支持tv和wearable设备。
2220
2221**系统能力**:SystemCapability.Notification.Notification
2222
2223**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2224
2225**系统接口**:此接口为系统接口。
2226
2227**参数:**
2228
2229| 参数名     | 类型                     | 必填 | 说明                             |
2230| -------- | ------------------------ | ---- | -------------------------------- |
2231| callback | AsyncCallback\<boolean\> | 是   | 查询是否支持免打扰功能回调函数(true:支持,false:不支持)。 |
2232
2233**错误码:**
2234
2235以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2236
2237| 错误码ID | 错误信息                             |
2238| -------- | ----------------------------------- |
2239| 201      | Permission denied.     |
2240| 202      | Not system application to call the interface.                                      |
2241| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2242| 801 | Capability not supported. |
2243| 1600001  | Internal error.                     |
2244| 1600002  | Marshalling or unmarshalling error. |
2245| 1600003  | Failed to connect to the service.          |
2246
2247**示例:**
2248
2249```ts
2250import { BusinessError } from '@kit.BasicServicesKit';
2251
2252let isSupportDoNotDisturbModeCallback = (err: BusinessError, data: boolean): void => {
2253    if (err) {
2254        console.error(`isSupportDoNotDisturbMode failed, code is ${err.code}, message is ${err.message}`);
2255    } else {
2256        console.info("isSupportDoNotDisturbMode success, data: " + JSON.stringify(data));
2257    }
2258}
2259
2260notificationManager.isSupportDoNotDisturbMode(isSupportDoNotDisturbModeCallback);
2261```
2262
2263## notificationManager.isSupportDoNotDisturbMode
2264
2265isSupportDoNotDisturbMode(): Promise\<boolean\>
2266
2267查询是否支持免打扰功能。使用Promise异步回调。
2268
2269**系统能力**:SystemCapability.Notification.Notification
2270
2271**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2272
2273**系统接口**:此接口为系统接口。
2274
2275**返回值:**
2276
2277| 类型                                                        | 说明                                                         |
2278| ----------------------------------------------------------- | ------------------------------------------------------------ |
2279| Promise\<boolean\> | 以Promise形式返回获取是否支持免打扰功能的结果(true:支持,false:不支持)。 |
2280
2281**错误码:**
2282
2283以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2284
2285| 错误码ID | 错误信息                            |
2286| -------- | ----------------------------------- |
2287| 201      | Permission denied.     |
2288| 202      | Not system application to call the interface.                                      |
2289| 1600001  | Internal error.                     |
2290| 1600002  | Marshalling or unmarshalling error. |
2291| 1600003  | Failed to connect to the service.          |
2292
2293**示例:**
2294
2295```ts
2296import { BusinessError } from '@kit.BasicServicesKit';
2297
2298notificationManager.isSupportDoNotDisturbMode().then((data: boolean) => {
2299	console.info("isSupportDoNotDisturbMode success, data: " + JSON.stringify(data));
2300}).catch((err: BusinessError) => {
2301    console.error(`isSupportDoNotDisturbMode failed, code is ${err.code}, message is ${err.message}`);
2302});
2303```
2304
2305## notificationManager.setDistributedEnable
2306
2307setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
2308
2309设置设备是否支持分布式通知。使用callback异步回调。
2310
2311该接口不支持tv和wearable设备。
2312
2313**系统能力**:SystemCapability.Notification.Notification
2314
2315**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2316
2317**系统接口**:此接口为系统接口。
2318
2319**参数:**
2320
2321| 参数名   | 类型                     | 必填 | 说明                       |
2322| -------- | ------------------------ | ---- | -------------------------- |
2323| enable   | boolean                  | 是   | 是否支持(true:支持,false:不支持)。 |
2324| callback | AsyncCallback\<void\> | 是   | 设置设备是否支持分布式通知的回调函数。 |
2325
2326**错误码:**
2327
2328以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2329
2330| 错误码ID | 错误信息                            |
2331| -------- | ----------------------------------- |
2332| 201      | Permission denied.     |
2333| 202      | Not system application to call the interface.                                      |
2334| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2335| 801 | Capability not supported. |
2336| 1600001  | Internal error.                     |
2337| 1600002  | Marshalling or unmarshalling error. |
2338| 1600003  | Failed to connect to the service.          |
2339| 1600010  | Distributed operation failed.       |
2340
2341**示例:**
2342
2343```ts
2344import { BusinessError } from '@kit.BasicServicesKit';
2345
2346let setDistributedEnableCallback = (err: BusinessError): void => {
2347    if (err) {
2348        console.error(`setDistributedEnable failed, code is ${err.code}, message is ${err.message}`);
2349    } else {
2350        console.info("setDistributedEnable success");
2351    }
2352};
2353let enable: boolean = true;
2354notificationManager.setDistributedEnable(enable, setDistributedEnableCallback);
2355```
2356
2357## notificationManager.setDistributedEnable
2358
2359setDistributedEnable(enable: boolean): Promise\<void>
2360
2361设置设备是否支持分布式通知。使用Promise异步回调。
2362
2363该接口不支持tv和wearable设备。
2364
2365**系统能力**:SystemCapability.Notification.Notification
2366
2367**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2368
2369**系统接口**:此接口为系统接口。
2370
2371**参数:**
2372
2373| 参数名   | 类型                     | 必填 | 说明                       |
2374| -------- | ------------------------ | ---- | -------------------------- |
2375| enable   | boolean                  | 是   | 是否支持(true:支持,false:不支持)。 |
2376
2377**返回值:**
2378
2379| 类型              | 说明        |
2380|-----------------|-----------|
2381| Promise\<void\> | 无返回结果的Promise对象。 |
2382
2383**错误码:**
2384
2385以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2386
2387| 错误码ID | 错误信息                            |
2388| -------- | ----------------------------------- |
2389| 201      | Permission denied.     |
2390| 202      | Not system application to call the interface.                                      |
2391| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2392| 801 | Capability not supported. |
2393| 1600001  | Internal error.                     |
2394| 1600002  | Marshalling or unmarshalling error. |
2395| 1600003  | Failed to connect to the service.          |
2396| 1600010  | Distributed operation failed.       |
2397
2398**示例:**
2399
2400```ts
2401import { BusinessError } from '@kit.BasicServicesKit';
2402
2403let enable: boolean = true;
2404notificationManager.setDistributedEnable(enable).then(() => {
2405    console.info("setDistributedEnable success");
2406}).catch((err: BusinessError) => {
2407    console.error(`setDistributedEnable failed, code is ${err.code}, message is ${err.message}`);
2408});
2409```
2410
2411## notificationManager.setDistributedEnableByBundle
2412
2413setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
2414
2415设置指定应用是否支持分布式通知。使用callback异步回调。
2416
2417该接口不支持tv和wearable设备。
2418
2419**系统能力**:SystemCapability.Notification.Notification
2420
2421**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2422
2423**系统接口**:此接口为系统接口。
2424
2425**参数:**
2426
2427| 参数名   | 类型                     | 必填 | 说明                       |
2428| -------- | ------------------------ | ---- | -------------------------- |
2429| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包信息。                   |
2430| enable   | boolean                  | 是   | 指定应用是否支持分布式通知(true:支持,false:不支持)。|
2431| callback | AsyncCallback\<void\> | 是   | 应用程序是否支持分布式通知的回调函数。 |
2432
2433**错误码:**
2434
2435以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2436
2437| 错误码ID | 错误信息                                 |
2438| -------- | ---------------------------------------- |
2439| 201      | Permission denied.     |
2440| 202      | Not system application to call the interface.                                      |
2441| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2442| 801 | Capability not supported. |
2443| 1600001  | Internal error.                          |
2444| 1600002  | Marshalling or unmarshalling error.      |
2445| 1600003  | Failed to connect to the service.               |
2446| 1600010  | Distributed operation failed.            |
2447| 17700001 | The specified bundle name was not found. |
2448
2449**示例:**
2450
2451```ts
2452import { BusinessError } from '@kit.BasicServicesKit';
2453
2454let setDistributedEnableByBundleCallback = (err: BusinessError): void => {
2455    if (err) {
2456        console.error(`setDistributedEnableByBundle failed, code is ${err.code}, message is ${err.message}`);
2457    } else {
2458        console.info("setDistributedEnableByBundle success");
2459    }
2460};
2461let bundle: notificationManager.BundleOption = {
2462    bundle: "bundleName1",
2463};
2464let enable: boolean = true;
2465notificationManager.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback);
2466```
2467
2468
2469
2470## notificationManager.setDistributedEnableByBundle
2471
2472setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
2473
2474设置指定应用是否支持分布式通知。使用Promise异步回调。
2475
2476该接口不支持tv和wearable设备。
2477
2478**系统能力**:SystemCapability.Notification.Notification
2479
2480**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2481
2482**系统接口**:此接口为系统接口。
2483
2484**参数:**
2485
2486| 参数名   | 类型                     | 必填 | 说明                       |
2487| -------- | ------------------------ | ---- | -------------------------- |
2488| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                |
2489| enable   | boolean                  | 是   | 指定应用是否支持分布式通知(true:支持,false:不支持)。                  |
2490
2491**返回值:**
2492
2493| 类型              | 说明        |
2494|-----------------|-----------|
2495| Promise\<void\> | 无返回结果的Promise对象。 |
2496
2497**错误码:**
2498
2499以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2500
2501| 错误码ID | 错误信息                                 |
2502| -------- | ---------------------------------------- |
2503| 201      | Permission denied.     |
2504| 202      | Not system application to call the interface.                                      |
2505| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2506| 801 | Capability not supported. |
2507| 1600001  | Internal error.                          |
2508| 1600002  | Marshalling or unmarshalling error.      |
2509| 1600003  | Failed to connect to the service.               |
2510| 1600010  | Distributed operation failed.            |
2511| 17700001 | The specified bundle name was not found. |
2512
2513**示例:**
2514
2515```ts
2516import { BusinessError } from '@kit.BasicServicesKit';
2517
2518let bundle: notificationManager.BundleOption = {
2519    bundle: "bundleName1",
2520};
2521let enable: boolean = true;
2522notificationManager.setDistributedEnableByBundle(bundle, enable).then(() => {
2523    console.info("setDistributedEnableByBundle success");
2524}).catch((err: BusinessError) => {
2525    console.error(`setDistributedEnableByBundle failed, code is ${err.code}, message is ${err.message}`);
2526});
2527```
2528
2529## notificationManager.isDistributedEnabledByBundle
2530
2531isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
2532
2533根据应用的包获取应用程序是否支持分布式通知。使用callback异步回调。
2534
2535该接口不支持tv和wearable设备。
2536
2537**系统能力**:SystemCapability.Notification.Notification
2538
2539**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2540
2541**系统接口**:此接口为系统接口。
2542
2543**参数:**
2544
2545| 参数名   | 类型                     | 必填 | 说明                       |
2546| -------- | ------------------------ | ---- | -------------------------- |
2547| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                     |
2548| callback | AsyncCallback\<boolean\> | 是   | 查询指定应用是否支持分布式通知的回调函数(true:支持,false:不支持)。 |
2549
2550**错误码:**
2551
2552以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2553
2554| 错误码ID | 错误信息                                 |
2555| -------- | ---------------------------------------- |
2556| 201      | Permission denied.     |
2557| 202      | Not system application to call the interface.                                      |
2558| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2559| 801 | Capability not supported. |
2560| 1600001  | Internal error.                          |
2561| 1600002  | Marshalling or unmarshalling error.      |
2562| 1600003  | Failed to connect to the service.               |
2563| 1600010  | Distributed operation failed.            |
2564| 17700001 | The specified bundle name was not found. |
2565
2566**示例:**
2567
2568```ts
2569import { BusinessError } from '@kit.BasicServicesKit';
2570
2571let isDistributedEnabledByBundleCallback = (err: BusinessError, data: boolean): void => {
2572    if (err) {
2573        console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
2574    } else {
2575        console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
2576    }
2577};
2578let bundle: notificationManager.BundleOption = {
2579    bundle: "bundleName1",
2580};
2581notificationManager.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
2582```
2583
2584## notificationManager.isDistributedEnabledByBundle
2585
2586isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
2587
2588查询指定应用是否支持分布式通知。使用Promise异步回调。
2589
2590该接口不支持tv和wearable设备。
2591
2592**系统能力**:SystemCapability.Notification.Notification
2593
2594**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2595
2596**系统接口**:此接口为系统接口。
2597
2598**参数:**
2599
2600| 参数名   | 类型                     | 必填 | 说明                       |
2601| -------- | ------------------------ | ---- | -------------------------- |
2602| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包。                |
2603
2604**返回值:**
2605
2606| 类型               | 说明                                              |
2607| ------------------ | ------------------------------------------------- |
2608| Promise\<boolean\> | Promise方式返回指定应用是否支持分布式通知的结果(true:支持,false:不支持)。 |
2609
2610**错误码:**
2611
2612以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2613
2614| 错误码ID | 错误信息                                 |
2615| -------- | ---------------------------------------- |
2616| 201      | Permission denied.     |
2617| 202      | Not system application to call the interface.                                      |
2618| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2619| 801 | Capability not supported. |
2620| 1600001  | Internal error.                          |
2621| 1600002  | Marshalling or unmarshalling error.      |
2622| 1600003  | Failed to connect to the service.               |
2623| 1600010  | Distributed operation failed.            |
2624| 17700001 | The specified bundle name was not found. |
2625
2626**示例:**
2627
2628```ts
2629import { BusinessError } from '@kit.BasicServicesKit';
2630
2631let bundle: notificationManager.BundleOption = {
2632    bundle: "bundleName1",
2633};
2634notificationManager.isDistributedEnabledByBundle(bundle).then((data: boolean) => {
2635    console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
2636}).catch((err: BusinessError) => {
2637    console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
2638});
2639```
2640
2641
2642## notificationManager.getDeviceRemindType
2643
2644getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
2645
2646获取通知的提醒方式。使用callback异步回调。
2647
2648该接口不支持tv和wearable设备。
2649
2650**系统能力**:SystemCapability.Notification.Notification
2651
2652**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2653
2654**系统接口**:此接口为系统接口。
2655
2656**参数:**
2657
2658| 参数名   | 类型                               | 必填 | 说明                       |
2659| -------- | --------------------------------- | ---- | -------------------------- |
2660| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | 是   | 获取通知提醒方式的回调函数。 |
2661
2662**错误码:**
2663
2664以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2665
2666| 错误码ID | 错误信息                            |
2667| -------- | ----------------------------------- |
2668| 201      | Permission denied.     |
2669| 202      | Not system application to call the interface.                                      |
2670| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2671| 801 | Capability not supported. |
2672| 1600001  | Internal error.                     |
2673| 1600002  | Marshalling or unmarshalling error. |
2674| 1600003  | Failed to connect to the service.          |
2675
2676**示例:**
2677
2678```ts
2679import { BusinessError } from '@kit.BasicServicesKit';
2680
2681let getDeviceRemindTypeCallback = (err: BusinessError, data: notificationManager.DeviceRemindType): void => {
2682    if (err) {
2683        console.error(`getDeviceRemindType failed, code is ${err.code}, message is ${err.message}`);
2684    } else {
2685        console.info(`getDeviceRemindType success, data is ${JSON.stringify(data)}`);
2686    }
2687};
2688notificationManager.getDeviceRemindType(getDeviceRemindTypeCallback);
2689```
2690
2691## notificationManager.getDeviceRemindType
2692
2693getDeviceRemindType(): Promise\<DeviceRemindType\>
2694
2695获取通知的提醒方式。使用Promise异步回调。
2696
2697该接口不支持tv和wearable设备。
2698
2699**系统能力**:SystemCapability.Notification.Notification
2700
2701**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
2702
2703**系统接口**:此接口为系统接口。
2704
2705**返回值:**
2706
2707| 类型               | 说明            |
2708| ------------------ | --------------- |
2709| Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise方式返回获取通知提醒方式的结果。 |
2710
2711**错误码:**
2712
2713以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2714
2715| 错误码ID | 错误信息                            |
2716| -------- | ----------------------------------- |
2717| 201      | Permission denied.     |
2718| 202      | Not system application to call the interface.                                      |
2719| 801 | Capability not supported. |
2720| 1600001  | Internal error.                     |
2721| 1600002  | Marshalling or unmarshalling error. |
2722| 1600003  | Failed to connect to the service.          |
2723
2724**示例:**
2725
2726```ts
2727import { BusinessError } from '@kit.BasicServicesKit';
2728
2729notificationManager.getDeviceRemindType().then((data: notificationManager.DeviceRemindType) => {
2730    console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
2731}).catch((err: BusinessError) => {
2732    console.error(`getDeviceRemindType failed, code is ${err.code}, message is ${err.message}`);
2733});
2734```
2735
2736
2737## notificationManager.publishAsBundle
2738
2739publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
2740
2741发布代理通知。使用callback异步回调。
2742
2743**系统能力**:SystemCapability.Notification.Notification
2744
2745**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2746
2747**系统接口**:此接口为系统接口。
2748
2749**参数:**
2750
2751| 参数名               | 类型                                        | 必填 | 说明                                     |
2752| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
2753| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
2754| representativeBundle | string                                      | 是   | 被代理应用的包名。                       |
2755| userId               | number                                      | 是   | 用户ID。                                 |
2756| callback             | AsyncCallback\<void\>                        | 是   | 发布代理通知的回调方法。                 |
2757
2758**错误码:**
2759
2760以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2761
2762| 错误码ID | 错误信息                                  |
2763| -------- | ----------------------------------------- |
2764| 201      | Permission denied.     |
2765| 202      | Not system application to call the interface.                                      |
2766| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2767| 1600001  | Internal error.                           |
2768| 1600002  | Marshalling or unmarshalling error.       |
2769| 1600003  | Failed to connect to the service.                |
2770| 1600004  | Notification disabled.              |
2771| 1600005  | Notification slot disabled.         |
2772| 1600007  | The notification does not exist.      |
2773| 1600008  | The user does not exist.                    |
2774| 1600009  | The notification sending frequency reaches the upper limit. |
2775| 1600012  | No memory space.                          |
2776| 1600015  | The current notification status does not support duplicate configurations. |
2777| 1600016  | The notification version for this update is too low. |
2778| 1600020  | The application is not allowed to publish notifications due to permission control settings. |
2779| 2300007  | Network unreachable.                              |
2780
2781**示例:**
2782
2783```ts
2784import { BusinessError } from '@kit.BasicServicesKit';
2785
2786//publishAsBundle回调
2787let callback = (err: BusinessError): void => {
2788    if (err) {
2789        console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
2790    } else {
2791        console.info("publishAsBundle success");
2792    }
2793}
2794// 被代理应用的包名
2795let representativeBundle: string = "com.example.demo";
2796// 用户ID,使用时需替换为真实的userId。
2797let userId: number = 100;
2798// NotificationRequest对象
2799let request: notificationManager.NotificationRequest = {
2800    id: 1,
2801    content: {
2802        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2803        normal: {
2804            title: "test_title",
2805            text: "test_text",
2806            additionalText: "test_additionalText"
2807        }
2808    }
2809};
2810notificationManager.publishAsBundle(request, representativeBundle, userId, callback);
2811```
2812
2813## notificationManager.publishAsBundle
2814
2815publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
2816
2817发布代理通知。使用Promise异步回调。
2818
2819**系统能力**:SystemCapability.Notification.Notification
2820
2821**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2822
2823**系统接口**:此接口为系统接口。
2824
2825**参数:**
2826
2827
2828| 参数名               | 类型                                        | 必填 | 说明                                          |
2829| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
2830| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
2831| representativeBundle | string                                      | 是   | 被代理应用的包名。                            |
2832| userId               | number                                      | 是   | 用户ID。                            |
2833
2834**返回值:**
2835
2836| 类型              | 说明        |
2837|-----------------|-----------|
2838| Promise\<void\> | 无返回结果的Promise对象。 |
2839
2840**错误码:**
2841
2842以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2843
2844| 错误码ID | 错误信息                                  |
2845| -------- | ----------------------------------------- |
2846| 201      | Permission denied.     |
2847| 202      | Not system application to call the interface.                                      |
2848| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2849| 1600001  | Internal error.                           |
2850| 1600002  | Marshalling or unmarshalling error.       |
2851| 1600003  | Failed to connect to the service.                |
2852| 1600004  | Notification disabled.                    |
2853| 1600005  | Notification slot disabled.         |
2854| 1600007  | The notification does not exist.      |
2855| 1600008  | The user does not exist.                    |
2856| 1600009  | The notification sending frequency reaches the upper limit. |
2857| 1600012  | No memory space.                          |
2858| 1600015  | The current notification status does not support duplicate configurations. |
2859| 1600016  | The notification version for this update is too low. |
2860| 1600020  | The application is not allowed to publish notifications due to permission control settings. |
2861| 2300007  | Network unreachable.                              |
2862
2863**示例:**
2864
2865```ts
2866import { BusinessError } from '@kit.BasicServicesKit';
2867
2868// 被代理应用的包名
2869let representativeBundle: string = "com.example.demo";
2870// 用户ID,使用时需替换为真实的userId。
2871let userId: number = 100;
2872// NotificationRequest对象
2873let request: notificationManager.NotificationRequest = {
2874    id: 1,
2875    content: {
2876        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2877        normal: {
2878            title: "test_title",
2879            text: "test_text",
2880            additionalText: "test_additionalText"
2881        }
2882    }
2883};
2884notificationManager.publishAsBundle(request, representativeBundle, userId).then(() => {
2885	console.info("publishAsBundle success");
2886}).catch((err: BusinessError) => {
2887    console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
2888});
2889```
2890
2891## notificationManager.publishAsBundle<sup>12+</sup>
2892
2893publishAsBundle(representativeBundle: BundleOption, request: NotificationRequest): Promise\<void\>
2894
2895发布代理通知。使用Promise异步回调。
2896
2897**系统能力**:SystemCapability.Notification.Notification
2898
2899**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2900
2901**系统接口**:此接口为系统接口。
2902
2903**参数:**
2904
2905
2906| 参数名               | 类型                                        | 必填 | 说明                                          |
2907|----------------------|--------------------------------------------|------|-----------------------------------------------|
2908| representativeBundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)  | 是   | 被代理应用的包信息。                            |
2909| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationrequest) | 是   | 用于设置要发布通知的内容和相关配置信息。 |
2910
2911**返回值:**
2912
2913| 类型              | 说明        |
2914|-----------------|-----------|
2915| Promise\<void\> | 无返回结果的Promise对象。 |
2916
2917**错误码:**
2918
2919以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2920
2921| 错误码ID | 错误信息                                  |
2922| -------- | ----------------------------------------- |
2923| 201      | Permission denied.     |
2924| 202      | Not system application to call the interface.                                      |
2925| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2926| 1600001  | Internal error.                           |
2927| 1600002  | Marshalling or unmarshalling error.       |
2928| 1600003  | Failed to connect to the service.                |
2929| 1600004  | Notification is not enabled.              |
2930| 1600005  | Notification slot disabled.         |
2931| 1600007  | The notification does not exist.      |
2932| 1600008  | The user does not exist.                    |
2933| 1600009  | The notification sending frequency reaches the upper limit. |
2934| 1600012  | No memory space.                          |
2935| 1600015  | The current notification status does not support duplicate configurations. |
2936| 1600016  | The notification version for this update is too low. |
2937| 1600020  | The application is not allowed to publish notifications due to permission control settings. |
2938| 2300007  | Network unreachable.                              |
2939
2940**示例:**
2941
2942```ts
2943import { BusinessError } from '@kit.BasicServicesKit';
2944
2945// 被代理应用的包信息
2946let representativeBundle: notificationManager.BundleOption = {
2947  bundle: "bundleName1",
2948};
2949// NotificationRequest对象
2950let request: notificationManager.NotificationRequest = {
2951    id: 1,
2952    content: {
2953        notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
2954        normal: {
2955            title: "test_title",
2956            text: "test_text",
2957            additionalText: "test_additionalText"
2958        }
2959    }
2960};
2961notificationManager.publishAsBundle(representativeBundle, request).then(() => {
2962	console.info("publishAsBundle success");
2963}).catch((err: BusinessError) => {
2964    console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
2965});
2966```
2967
2968## notificationManager.cancelAsBundle
2969
2970cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
2971
2972取消代理通知。使用callback异步回调。
2973
2974**系统能力**:SystemCapability.Notification.Notification
2975
2976**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
2977
2978**系统接口**:此接口为系统接口。
2979
2980**参数:**
2981
2982| 参数名               | 类型          | 必填 | 说明                     |
2983| -------------------- | ------------- | ---- | ------------------------ |
2984| id                   | number        | 是   | 通知ID。                 |
2985| representativeBundle | string        | 是   | 被代理应用的包名。       |
2986| userId               | number        | 是   | 用户ID。       |
2987| callback             | AsyncCallback\<void\> | 是   | 取消代理通知的回调方法。 |
2988
2989**错误码:**
2990
2991以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
2992
2993| 错误码ID | 错误信息                            |
2994| -------- | ----------------------------------- |
2995| 201      | Permission denied.     |
2996| 202      | Not system application to call the interface.                                      |
2997| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
2998| 1600001  | Internal error.                     |
2999| 1600002  | Marshalling or unmarshalling error. |
3000| 1600003  | Failed to connect to the service.          |
3001| 1600007  | The notification does not exist.      |
3002| 1600008  | The user does not exist.              |
3003| 17700001 | The specified bundle name was not found. |
3004
3005**示例:**
3006
3007```ts
3008import { BusinessError } from '@kit.BasicServicesKit';
3009
3010// cancelAsBundle
3011let cancelAsBundleCallback = (err: BusinessError): void => {
3012    if (err) {
3013        console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
3014    } else {
3015        console.info("cancelAsBundle success");
3016    }
3017}
3018// 被代理应用的包名
3019let representativeBundle: string = "com.example.demo";
3020// 用户ID,使用时需替换为真实的userId。
3021let userId: number = 100;
3022notificationManager.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
3023```
3024
3025## notificationManager.cancelAsBundle
3026
3027cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
3028
3029取消代理通知。使用Promise异步回调。
3030
3031**系统能力**:SystemCapability.Notification.Notification
3032
3033**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3034
3035**系统接口**:此接口为系统接口。
3036
3037**参数:**
3038
3039| 参数名               | 类型   | 必填 | 说明               |
3040| -------------------- | ------ | ---- | ------------------ |
3041| id                   | number | 是   | 通知ID。           |
3042| representativeBundle | string | 是   | 被代理应用的包名。 |
3043| userId               | number | 是   | 用户ID。 |
3044
3045**返回值:**
3046
3047| 类型              | 说明        |
3048|-----------------|-----------|
3049| Promise\<void\> | 无返回结果的Promise对象。 |
3050
3051**错误码:**
3052
3053以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3054
3055| 错误码ID | 错误信息                            |
3056| -------- | ----------------------------------- |
3057| 201      | Permission denied.     |
3058| 202      | Not system application to call the interface.                                      |
3059| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3060| 1600001  | Internal error.                     |
3061| 1600002  | Marshalling or unmarshalling error. |
3062| 1600003  | Failed to connect to the service.          |
3063| 1600007  | The notification does not exist.      |
3064| 1600008  | The user does not exist.              |
3065| 17700001 | The specified bundle name was not found. |
3066
3067**示例:**
3068
3069```ts
3070import { BusinessError } from '@kit.BasicServicesKit';
3071
3072// 被代理应用的包名
3073let representativeBundle: string = "com.example.demo";
3074// 用户ID,使用时需替换为真实的userId。
3075let userId: number = 100;
3076notificationManager.cancelAsBundle(0, representativeBundle, userId).then(() => {
3077	console.info("cancelAsBundle success");
3078}).catch((err: BusinessError) => {
3079    console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
3080});
3081```
3082
3083
3084## notificationManager.cancelAsBundle<sup>12+</sup>
3085
3086cancelAsBundle(representativeBundle: BundleOption, id: number): Promise\<void\>
3087
3088取消代理通知。使用Promise异步回调。
3089
3090**系统能力**:SystemCapability.Notification.Notification
3091
3092**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3093
3094**系统接口**:此接口为系统接口。
3095
3096**参数:**
3097
3098
3099| 参数名               | 类型                                        | 必填 | 说明                                          |
3100| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
3101| representativeBundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)  |是   | 被代理应用的包信息。 |
3102| id                   | number                                     | 是   | 通知ID。           |
3103
3104**返回值:**
3105
3106| 类型              | 说明        |
3107|-----------------|-----------|
3108| Promise\<void\> | 无返回结果的Promise对象。 |
3109
3110**错误码:**
3111
3112以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3113
3114| 错误码ID | 错误信息                                  |
3115| -------- | ----------------------------------------- |
3116| 201      | Permission denied.     |
3117| 202      | Not system application to call the interface.                                      |
3118| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3119| 1600001  | Internal error.                           |
3120| 1600002  | Marshalling or unmarshalling error.       |
3121| 1600003  | Failed to connect to the service.                |
3122| 1600007  | The notification does not exist.            |
3123| 1600008  | The user does not exist.                    |
3124| 1600012  | No memory space.                          |
3125| 17700001 | The specified bundle name was not found. |
3126
3127**示例:**
3128
3129```ts
3130import { BusinessError } from '@kit.BasicServicesKit';
3131
3132let representativeBundle: notificationManager.BundleOption = {
3133  bundle: "bundleName1",
3134};
3135notificationManager.cancelAsBundle(representativeBundle, 1).then(() => {
3136	console.info("cancelAsBundle success");
3137}).catch((err: BusinessError) => {
3138    console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
3139});
3140```
3141
3142## notificationManager.cancel<sup>12+</sup>
3143
3144cancel(representativeBundle: BundleOption, id: number): Promise\<void\>
3145
3146代理取消当前用户其他应用的通知。使用Promise异步回调。
3147
3148需要当前应用与其他应用存在代理关系,或者当前应用有ohos.permission.NOTIFICATION_AGENT_CONTROLLER权限。
3149
3150**系统能力**:SystemCapability.Notification.Notification
3151
3152**系统接口**:此接口为系统接口。
3153
3154**参数:**
3155
3156| 参数名               | 类型   | 必填 | 说明               |
3157| -------------------- | ------ | ---- | ------------------ |
3158| representativeBundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3159|       id             | number | 是   | 通知ID。 |
3160
3161**返回值:**
3162
3163| 类型              | 说明        |
3164|-----------------|-----------|
3165| Promise\<void\> | 无返回结果的Promise对象。 |
3166
3167**错误码:**
3168
3169以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3170
3171| 错误码ID | 错误信息                            |
3172| -------- | ----------------------------------- |
3173| 202      | Not system application to call the interface.                                      |
3174| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3175| 1600001  | Internal error.                     |
3176| 1600002  | Marshalling or unmarshalling error. |
3177| 1600003  | Failed to connect to the service.          |
3178| 1600007  | The notification does not exist.      |
3179| 1600012  | No memory space.                    |
3180| 1600017  | There is no corresponding agent relationship configuration.    |
3181
3182**示例:**
3183
3184```ts
3185import { BusinessError } from '@kit.BasicServicesKit';
3186
3187let bundle: notificationManager.BundleOption = {
3188  bundle: "bundleName"
3189};
3190let id: number = 1;
3191notificationManager.cancel(bundle, id).then(() => {
3192  console.info("cancel success");
3193}).catch((err: BusinessError) => {
3194  console.error(`cancel failed, code is ${err.code}, message is ${err.message}`);
3195});
3196```
3197
3198## notificationManager.setNotificationEnableSlot
3199
3200setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
3201
3202设置指定应用的指定渠道类型的使能状态。使用callback异步回调。
3203
3204该接口不支持wearable设备。
3205
3206**系统能力**:SystemCapability.Notification.Notification
3207
3208**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3209
3210**系统接口**:此接口为系统接口。
3211
3212**参数:**
3213
3214| 参数名   | 类型                          | 必填 | 说明                   |
3215| -------- | ----------------------------- | ---- | ---------------------- |
3216| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3217| type     | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 指定渠道类型。         |
3218| enable   | boolean                       | 是   | 使能状态(true:使能,false:禁止)。             |
3219| callback | AsyncCallback\<void\>         | 是   | 设置渠道使能回调函数。 |
3220
3221**错误码:**
3222
3223以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3224
3225| 错误码ID | 错误信息                                 |
3226| -------- | ---------------------------------------- |
3227| 201      | Permission denied.     |
3228| 202      | Not system application to call the interface.                                      |
3229| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3230| 801 | Capability not supported. |
3231| 1600001  | Internal error.                          |
3232| 1600002  | Marshalling or unmarshalling error.      |
3233| 1600003  | Failed to connect to the service.               |
3234| 1600012  | No memory space.                         |
3235| 17700001 | The specified bundle name was not found. |
3236
3237**示例:**
3238
3239```ts
3240import { BusinessError } from '@kit.BasicServicesKit';
3241
3242// setNotificationEnableSlot
3243let setNotificationEnableSlotCallback = (err: BusinessError): void => {
3244    if (err) {
3245        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
3246    } else {
3247        console.info("setNotificationEnableSlot success");
3248    }
3249};
3250notificationManager.setNotificationEnableSlot(
3251    { bundle: "ohos.samples.notification", },
3252    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3253    true,
3254    setNotificationEnableSlotCallback);
3255```
3256
3257## notificationManager.setNotificationEnableSlot<sup>11+</sup>
3258
3259setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, isForceControl: boolean, callback: AsyncCallback\<void>): void
3260
3261设置指定应用的指定渠道类型的使能状态。使用callback异步回调。
3262
3263该接口不支持wearable设备。
3264
3265**系统能力**:SystemCapability.Notification.Notification
3266
3267**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3268
3269**系统接口**:此接口为系统接口。
3270
3271**参数:**
3272
3273| 参数名   | 类型                          | 必填 | 说明                     |
3274| -------- | ----------------------------- | ---- | ----------------------- |
3275| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。|
3276| type     | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 指定渠道类型。           |
3277| enable   | boolean                       | 是   | 使能状态(true:使能,false:禁止)。               |
3278| isForceControl<sup>11+</sup> | boolean                 | 是   | 渠道开关是否受通知授权开关影响(false:受影响,true:不受影响)。 |
3279| callback | AsyncCallback\<void\>         | 是   | 设置渠道使能回调函数。    |
3280
3281**错误码:**
3282
3283以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3284
3285| 错误码ID | 错误信息                                 |
3286| -------- | ---------------------------------------- |
3287| 201      | Permission denied.     |
3288| 202      | Not system application to call the interface.                                      |
3289| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3290| 801 | Capability not supported. |
3291| 1600001  | Internal error.                          |
3292| 1600002  | Marshalling or unmarshalling error.      |
3293| 1600003  | Failed to connect to the service.               |
3294| 1600012  | No memory space.                         |
3295| 17700001 | The specified bundle name was not found. |
3296
3297**示例:**
3298
3299```ts
3300import { BusinessError } from '@kit.BasicServicesKit';
3301
3302let setNotificationEnableSlotCallback = (err: BusinessError): void => {
3303    if (err) {
3304        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
3305    } else {
3306        console.info("setNotificationEnableSlot success");
3307    }
3308};
3309
3310notificationManager.setNotificationEnableSlot(
3311    { bundle: "ohos.samples.notification", },
3312    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3313    true,
3314    false,
3315    setNotificationEnableSlotCallback);
3316```
3317
3318## notificationManager.setNotificationEnableSlot
3319
3320setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, isForceControl?: boolean): Promise\<void>
3321
3322设置指定应用的指定渠道类型的使能状态。使用promise异步回调。
3323
3324该接口不支持wearable设备。
3325
3326**系统能力**:SystemCapability.Notification.Notification
3327
3328**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3329
3330**系统接口**:此接口为系统接口。
3331
3332**参数:**
3333
3334| 参数名 | 类型                          | 必填 | 说明           |
3335| ------ | ----------------------------- | ---- | -------------- |
3336| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。   |
3337| type   | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 渠道类型。 |
3338| enable | boolean                       | 是   | 使能状态(true:使能,false:禁止)。     |
3339| isForceControl<sup>11+</sup> | boolean               | 否   | 渠道开关是否受通知总开关影响(false:受总开关影响,true:不受总开关影响)。默认为false。     |
3340
3341**错误码:**
3342
3343以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3344
3345| 错误码ID | 错误信息                                 |
3346| -------- | ---------------------------------------- |
3347| 201      | Permission denied.     |
3348| 202      | Not system application to call the interface.                                      |
3349| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3350| 801 | Capability not supported. |
3351| 1600001  | Internal error.                          |
3352| 1600002  | Marshalling or unmarshalling error.      |
3353| 1600003  | Failed to connect to the service.               |
3354| 1600012  | No memory space.                         |
3355| 17700001 | The specified bundle name was not found. |
3356
3357**示例:**
3358
3359```ts
3360import { BusinessError } from '@kit.BasicServicesKit';
3361
3362// setNotificationEnableSlot
3363notificationManager.setNotificationEnableSlot(
3364    { bundle: "ohos.samples.notification", },
3365    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3366    true).then(() => {
3367        console.info("setNotificationEnableSlot success");
3368    }).catch((err: BusinessError) => {
3369        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
3370    });
3371```
3372
3373## notificationManager.isNotificationSlotEnabled
3374
3375isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
3376
3377获取指定应用的指定渠道类型的使能状态。使用callback异步回调。
3378
3379该接口不支持wearable设备。
3380
3381**系统能力**:SystemCapability.Notification.Notification
3382
3383**系统接口**:此接口为系统接口。
3384
3385**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3386
3387**参数:**
3388
3389| 参数名   | 类型                          | 必填 | 说明                   |
3390| -------- | ----------------------------- | ---- | ---------------------- |
3391| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。           |
3392| type     | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 渠道类型。         |
3393| callback | AsyncCallback\<boolean\>         | 是   | 获取渠道使能状态回调函数(true:使能,false:禁止)。 |
3394
3395**错误码:**
3396
3397以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3398
3399| 错误码ID | 错误信息                                 |
3400| -------- | ---------------------------------------- |
3401| 201      | Permission denied.     |
3402| 202      | Not system application to call the interface.                                      |
3403| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3404| 801 | Capability not supported. |
3405| 1600001  | Internal error.                          |
3406| 1600002  | Marshalling or unmarshalling error.      |
3407| 1600003  | Failed to connect to the service.               |
3408| 17700001 | The specified bundle name was not found. |
3409
3410**示例:**
3411
3412```ts
3413import { BusinessError } from '@kit.BasicServicesKit';
3414
3415// isNotificationSlotEnabledCallback
3416let isNotificationSlotEnabledCallback = (err: BusinessError, data: boolean): void => {
3417    if (err) {
3418        console.error(`isNotificationSlotEnabled failed, code is ${err.code}, message is ${err.message}`);
3419    } else {
3420        console.info(`isNotificationSlotEnabled success, data is ${JSON.stringify(data)}`);
3421    }
3422};
3423
3424notificationManager.isNotificationSlotEnabled(
3425    { bundle: "ohos.samples.notification", },
3426    notificationManager.SlotType.SOCIAL_COMMUNICATION,
3427    isNotificationSlotEnabledCallback);
3428```
3429
3430## notificationManager.isNotificationSlotEnabled
3431
3432isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
3433
3434获取指定应用的指定渠道类型的使能状态。使用Promise异步回调。
3435
3436该接口不支持wearable设备。
3437
3438**系统能力**:SystemCapability.Notification.Notification
3439
3440**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3441
3442**系统接口**:此接口为系统接口。
3443
3444**参数:**
3445
3446| 参数名 | 类型                          | 必填 | 说明           |
3447| ------ | ----------------------------- | ---- | -------------- |
3448| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 应用的包信息。   |
3449| type   | [SlotType](./js-apis-notificationManager.md#slottype)         | 是   | 渠道类型。 |
3450
3451**返回值:**
3452
3453| 类型                                                        | 说明                                                         |
3454| ----------------------------------------------------------- | ------------------------------------------------------------ |
3455| Promise\<boolean\> | 以Promise形式返回指定类型的渠道使能状态(true:使能,false:禁止)。 |
3456
3457**错误码:**
3458
3459以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3460
3461| 错误码ID | 错误信息                                 |
3462| -------- | ---------------------------------------- |
3463| 201      | Permission denied.     |
3464| 202      | Not system application to call the interface.                                      |
3465| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3466| 801 | Capability not supported. |
3467| 1600001  | Internal error.                          |
3468| 1600002  | Marshalling or unmarshalling error.      |
3469| 1600003  | Failed to connect to the service.               |
3470| 17700001 | The specified bundle name was not found. |
3471
3472**示例:**
3473
3474```ts
3475import { BusinessError } from '@kit.BasicServicesKit';
3476
3477// isNotificationSlotEnabled
3478notificationManager.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
3479    notificationManager.SlotType.SOCIAL_COMMUNICATION).then((data: boolean) => {
3480    console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
3481}).catch((err: BusinessError) => {
3482    console.error(`isNotificationSlotEnabled failed, code is ${err.code}, message is ${err.message}`);
3483});
3484```
3485
3486
3487## notificationManager.setSyncNotificationEnabledWithoutApp
3488
3489setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
3490
3491设置是否将通知同步到未安装应用程序的设备(callback形式)。
3492
3493该接口不支持tv和wearable设备。
3494
3495**系统能力**:SystemCapability.Notification.Notification
3496
3497**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3498
3499**系统接口**:此接口为系统接口。
3500
3501**参数:**
3502
3503| 参数名 | 类型                          | 必填 | 说明           |
3504| ------ | ----------------------------- | ---- | -------------- |
3505| userId | number | 是   | 用户ID。   |
3506| enable | boolean | 是   | 是否启用(true:使能,false:禁止)。   |
3507| callback | AsyncCallback\<void\>    | 是   | 设置是否将通知同步到未安装应用程序的设备的回调函数。 |
3508
3509**错误码:**
3510
3511以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3512
3513| 错误码ID | 错误信息                            |
3514| -------- | ----------------------------------- |
3515| 201      | Permission denied.     |
3516| 202      | Not system application to call the interface.                                      |
3517| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3518| 801 | Capability not supported. |
3519| 1600001  | Internal error.                     |
3520| 1600002  | Marshalling or unmarshalling error. |
3521| 1600003  | Failed to connect to the service.          |
3522| 1600008  | The user does not exist.              |
3523
3524**示例:**
3525
3526```ts
3527import { BusinessError } from '@kit.BasicServicesKit';
3528
3529// 用户ID,使用时需替换为真实的userId。
3530let userId: number = 100;
3531let enable: boolean = true;
3532let setSyncNotificationEnabledWithoutAppCallback = (err: BusinessError): void => {
3533    if (err) {
3534        console.error(`setSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
3535    } else {
3536        console.info("setSyncNotificationEnabledWithoutApp success");
3537    }
3538}
3539notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback);
3540```
3541
3542
3543## notificationManager.setSyncNotificationEnabledWithoutApp
3544
3545setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
3546
3547设置是否将通知同步到未安装应用程序的设备(Promise形式)。
3548
3549该接口不支持tv和wearable设备。
3550
3551**系统能力**:SystemCapability.Notification.Notification
3552
3553**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3554
3555**系统接口**:此接口为系统接口。
3556
3557**参数:**
3558
3559| 参数名 | 类型                          | 必填 | 说明           |
3560| ------ | ----------------------------- | ---- | -------------- |
3561| userId | number | 是   | 用户ID。   |
3562| enable | boolean | 是   | 是否启用(true:使能,false:禁止)。   |
3563
3564**返回值:**
3565
3566| 类型                                                        | 说明                                                         |
3567| ----------------------------------------------------------- | ------------------------------------------------------------ |
3568| Promise\<void\> | 以Promise形式返回设置是否将通知同步到未安装应用程序的设备的结果。 |
3569
3570**错误码:**
3571
3572以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3573
3574| 错误码ID | 错误信息                            |
3575| -------- | ----------------------------------- |
3576| 201      | Permission denied.     |
3577| 202      | Not system application to call the interface.                                      |
3578| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3579| 801 | Capability not supported. |
3580| 1600001  | Internal error.                     |
3581| 1600002  | Marshalling or unmarshalling error. |
3582| 1600003  | Failed to connect to the service.          |
3583| 1600008  | The user does not exist.              |
3584
3585**示例:**
3586
3587```ts
3588import { BusinessError } from '@kit.BasicServicesKit';
3589
3590// 用户ID,使用时需替换为真实的userId。
3591let userId: number = 100;
3592let enable: boolean = true;
3593notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
3594    console.info('setSyncNotificationEnabledWithoutApp success');
3595}).catch((err: BusinessError) => {
3596    console.error(`setSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
3597});
3598```
3599
3600
3601## notificationManager.getSyncNotificationEnabledWithoutApp
3602
3603getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
3604
3605获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。
3606
3607**系统能力**:SystemCapability.Notification.Notification
3608
3609**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3610
3611**系统接口**:此接口为系统接口。
3612
3613**参数:**
3614
3615| 参数名 | 类型                          | 必填 | 说明           |
3616| ------ | ----------------------------- | ---- | -------------- |
3617| userId | number | 是   | 用户ID。   |
3618| callback | AsyncCallback\<boolean\>         | 是   | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数(true:开启,false:未开启)。 |
3619
3620**错误码:**
3621
3622以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3623
3624| 错误码ID | 错误信息                            |
3625| -------- | ----------------------------------- |
3626| 201      | Permission denied.     |
3627| 202      | Not system application to call the interface.                                      |
3628| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3629| 1600001  | Internal error.                     |
3630| 1600002  | Marshalling or unmarshalling error. |
3631| 1600003  | Failed to connect to the service.          |
3632| 1600008  | The user does not exist.              |
3633
3634**示例:**
3635
3636```ts
3637import { BusinessError } from '@kit.BasicServicesKit';
3638
3639// 用户ID,使用时需替换为真实的userId。
3640let userId: number = 100;
3641let getSyncNotificationEnabledWithoutAppCallback = (err: BusinessError, data: boolean): void => {
3642    if (err) {
3643        console.error(`getSyncNotificationEnabledWithoutAppCallback failed, code is ${err.code}, message is ${err.message}`);
3644    } else {
3645        console.info("getSyncNotificationEnabledWithoutAppCallback success, data: " + JSON.stringify(data));
3646    }
3647}
3648notificationManager.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
3649```
3650
3651
3652## notificationManager.getSyncNotificationEnabledWithoutApp
3653
3654getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
3655
3656获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。
3657
3658**系统能力**:SystemCapability.Notification.Notification
3659
3660**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3661
3662**系统接口**:此接口为系统接口。
3663
3664**参数:**
3665
3666| 参数名 | 类型                          | 必填 | 说明           |
3667| ------ | ----------------------------- | ---- | -------------- |
3668| userId | number | 是   | 用户ID。   |
3669
3670**返回值:**
3671
3672| 类型               | 说明                                                         |
3673| ------------------ | ------------------------------------------------------------ |
3674| Promise\<boolean\> | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果(true:开启,false:未开启)。 |
3675
3676**错误码:**
3677
3678以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3679
3680| 错误码ID | 错误信息                            |
3681| -------- | ----------------------------------- |
3682| 201      | Permission denied.     |
3683| 202      | Not system application to call the interface.                                      |
3684| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3685| 1600001  | Internal error.                     |
3686| 1600002  | Marshalling or unmarshalling error. |
3687| 1600003  | Failed to connect to the service.          |
3688| 1600008  | The user does not exist.              |
3689
3690**示例:**
3691
3692```ts
3693import { BusinessError } from '@kit.BasicServicesKit';
3694
3695// 用户ID,使用时需替换为真实的userId。
3696let userId: number = 100;
3697notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data: boolean) => {
3698  console.info('getSyncNotificationEnabledWithoutApp, data: ' + JSON.stringify(data));
3699}).catch((err: BusinessError) => {
3700    console.error(`getSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
3701});
3702```
3703
3704## notificationManager.on<sup>10+</sup>
3705
3706on(type: 'checkNotification', callback: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void
3707
3708注册通知监听回调。通知服务将通知信息回调给校验程序,校验程序返回校验结果决定该通知是否发布,如营销类通知发布频率控制等。
3709
3710系统中每个[SlotType](./js-apis-notificationManager.md#slottype)只允许存在一个注册者。
3711
3712该接口不支持wearable设备。
3713
3714**系统能力**:SystemCapability.Notification.Notification
3715
3716**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3717
3718**系统接口**:此接口为系统接口。
3719
3720**参数:**
3721
3722| 参数名 | 类型                                                                                                                      | 必填 | 说明           |
3723| ------ |-------------------------------------------------------------------------------------------------------------------------| ---- | -------------- |
3724| type | string                                                                                                                  | 是   | 回调函数类型名,固定为'checkNotification'。 |
3725| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  [NotificationCheckResult](#notificationcheckresult10) | 是   | 消息验证函数指针。 |
3726
3727**错误码:**
3728
3729以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3730
3731| 错误码ID | 错误信息                            |
3732| -------- | ----------------------------------- |
3733| 202      | Not system application.                                      |
3734| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3735| 801 | Capability not supported. |
3736| 1600001  | Internal error.                     |
3737
3738**示例:**
3739
3740```ts
3741import { BusinessError } from '@kit.BasicServicesKit';
3742
3743let onCheckNotification = (info : notificationManager.NotificationCheckInfo): notificationManager.NotificationCheckResult => {
3744    console.info(`====>OnCheckNotification info: ${JSON.stringify(info)}`);
3745    if(info.notificationId == 1){
3746        let result: notificationManager.NotificationCheckResult =  { code: 1, message: "testMsg1"};
3747        return result;
3748    } else {
3749        let result: notificationManager.NotificationCheckResult =   { code: 0, message: "testMsg0"};
3750        return result;
3751    }
3752}
3753try{
3754    notificationManager.on("checkNotification", onCheckNotification);
3755} catch (err: BusinessError){
3756    console.error(`notificationManager.on failed, code is ${err.code}, message is ${err.message}`);
3757}
3758```
3759
3760## notificationManager.on<sup>11+</sup>
3761
3762on(type: 'checkNotification', checkRequest: NotificationCheckRequest, callback: (checkInfo: NotificationCheckInfo) => Promise\<NotificationCheckResult\>): void
3763
3764注册通知监听回调。通知服务将通知信息回调给校验程序,校验程序返回校验结果决定该通知是否发布,如营销类通知发布频率控制等。使用Promise异步回调。
3765
3766系统中每个[SlotType](./js-apis-notificationManager.md#slottype)只允许存在一个注册者。
3767
3768该接口不支持wearable设备。
3769
3770**系统能力**:SystemCapability.Notification.Notification
3771
3772**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3773
3774**系统接口**:此接口为系统接口。
3775
3776**参数:**
3777
3778| 参数名 | 类型                                                                                                             | 必填 | 说明           |
3779| ------ |-----------------------------------------------------------------------------------------------------------------| ---- | -------------- |
3780| type | string                                                                                                            | 是   | 回调函数类型名,固定为'checkNotification'。 |
3781| checkRequest | [NotificationCheckRequest](js-apis-inner-notification-notificationRequest-sys.md#notificationcheckrequest11)    | 是   | 通知请求验证内容。 |
3782| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  Promise\<[NotificationCheckResult](#notificationcheckresult10)\> | 是   | 消息验证函数指针。 |
3783
3784**错误码:**
3785
3786以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3787
3788| 错误码ID | 错误信息                            |
3789| -------- | ----------------------------------- |
3790| 201      | Permission denied.     |
3791| 202      | Not system application.                                      |
3792| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3793| 801 | Capability not supported. |
3794| 1600001  | Internal error.                     |
3795| 1600002  | Marshalling or unmarshalling error.      |
3796| 1600003  | Failed to connect to the service.               |
3797
3798**示例:**
3799
3800```ts
3801import { BusinessError } from '@kit.BasicServicesKit';
3802
3803try{
3804  notificationManager.on('checkNotification',{
3805    contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LIVE_VIEW,
3806    slotType: notificationManager.SlotType.LIVE_VIEW ,
3807    extraInfoKeys: ["event"],
3808  },
3809    async (checkInfo)=>{
3810      return { code: 1, message: "INVALID_PARAMETERS"};
3811  },);
3812} catch (err: BusinessError) {
3813  console.error(`notificationManager.on failed, code is ${err.code}, message is ${err.message}`);
3814}
3815```
3816
3817## notificationManager.off<sup>10+</sup>
3818
3819off(type: 'checkNotification', callback?: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void
3820
3821取消通知监听回调。
3822
3823该接口不支持wearable设备。
3824
3825**系统能力**:SystemCapability.Notification.Notification
3826
3827**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
3828
3829**系统接口**:此接口为系统接口。
3830
3831**参数:**
3832
3833| 参数名 | 类型                                                                                                                      | 必填 | 说明           |
3834| ------ |-------------------------------------------------------------------------------------------------------------------------| ---- | -------------- |
3835| type | string                                                                                                                  | 是   | 回调函数类型名,固定为'checkNotification'。 |
3836| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  [NotificationCheckResult](#notificationcheckresult10) | 否   | 消息验证函数指针。 |
3837
3838**错误码:**
3839
3840以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3841
3842| 错误码ID | 错误信息                            |
3843| -------- | ----------------------------------- |
3844| 201      | The application dose not have permission to call the interface.     |
3845| 202      | Not system application.                                      |
3846| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3847| 801 | Capability not supported. |
3848| 1600001  | Internal error.                     |
3849
3850**示例:**
3851
3852```ts
3853import { BusinessError } from '@kit.BasicServicesKit';
3854
3855try{
3856    notificationManager.off("checkNotification");
3857} catch (err: BusinessError){
3858    console.error(`notificationManager.off failed, code is ${err.code}, message is ${err.message}`);
3859}
3860```
3861
3862## notificationManager.triggerSystemLiveView<sup>11+</sup>
3863
3864triggerSystemLiveView(bundle: BundleOption, notificationId: number, buttonOptions: ButtonOptions): Promise\<void>
3865
3866触发系统实况窗。使用Promise异步回调。
3867
3868该接口不支持wearable设备。
3869
3870**系统能力**:SystemCapability.Notification.Notification
3871
3872**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3873
3874**系统接口**:此接口为系统接口。
3875
3876**参数:**
3877
3878| 参数名 | 类型                   | 必填 | 说明           |
3879| -------------- | ------------- | ---- | -------------- |
3880| bundle         | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)  | 是   |指定应用的包信息。 |
3881| notificationId | number        | 是   | 通知ID。 |
3882| buttonOptions  | [ButtonOptions](#buttonoptions11) | 是   | 按钮信息。 |
3883
3884**返回值:**
3885
3886| 类型 | 说明 |
3887| ---- | ----|
3888| Promise\<void> | 无返回结果的Promise对象。 |
3889
3890**错误码:**
3891
3892以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3893
3894| 错误码ID | 错误信息                            |
3895| -------- | ----------------------------------- |
3896| 201      | Permission denied.     |
3897| 202      | Not system application to call the interface.                                      |
3898| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3899| 801 | Capability not supported. |
3900| 1600001  | Internal error.                     |
3901| 1600002  | Marshalling or unmarshalling error. |
3902| 1600003  | Failed to connect to the service.          |
3903| 1600007  | The notification does not exist.      |
3904| 17700001 | The specified bundle name was not found. |
3905
3906**示例:**
3907
3908```ts
3909import { BusinessError } from '@kit.BasicServicesKit';
3910
3911// 包信息
3912let bundle: notificationManager.BundleOption = {
3913    bundle: "bundleName1",
3914};
3915// 通知ID
3916let notificationId = 1;
3917// 按钮信息
3918let buttonOptions: notificationManager.ButtonOptions = {
3919    buttonName: "buttonName1",
3920}
3921notificationManager.triggerSystemLiveView(bundle, notificationId, buttonOptions).then(() => {
3922  console.info("triggerSystemLiveView success");
3923}).catch((err: BusinessError) => {
3924  console.error(`triggerSystemLiveView failed, code is ${err.code}, message is ${err.message}`);
3925});
3926```
3927
3928
3929## notificationManager.subscribeSystemLiveView<sup>11+</sup>
3930
3931subscribeSystemLiveView(subscriber: SystemLiveViewSubscriber): Promise\<void>
3932
3933订阅系统实况窗。使用Promise异步回调。
3934
3935该接口不支持wearable设备。
3936
3937**系统能力**:SystemCapability.Notification.Notification
3938
3939**系统接口**:此接口为系统接口。
3940
3941**参数:**
3942
3943| 参数名 | 类型                   | 必填 | 说明           |
3944| -------------- | ------------- | ---- | -------------- |
3945| subscriber | [SystemLiveViewSubscriber](#systemliveviewsubscriber11)  | 是   | 系统实况窗订阅者。|
3946
3947**返回值:**
3948
3949| 类型 | 说明 |
3950| ---- | ----|
3951| Promise\<void> | 无返回结果的Promise对象。 |
3952
3953**错误码:**
3954
3955以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
3956
3957| 错误码ID | 错误信息                            |
3958| -------- | ----------------------------------- |
3959| 202      | Not system application to call the interface.                                      |
3960| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
3961| 801 | Capability not supported. |
3962| 1600001  | Internal error.                     |
3963| 1600002  | Marshalling or unmarshalling error. |
3964| 1600003  | Failed to connect to the service.          |
3965| 1600012  | No memory space.                    |
3966
3967**示例:**
3968
3969```ts
3970import { BusinessError } from '@kit.BasicServicesKit';
3971
3972let onResponseCallback = (id:number, option:notificationManager.ButtonOptions) => {
3973    console.info("onResponseCallback: " + JSON.stringify(option) + "notificationId" + id);
3974}
3975let subscriber: notificationManager.SystemLiveViewSubscriber  = {
3976    onResponse: onResponseCallback,
3977};
3978notificationManager.subscribeSystemLiveView(subscriber).then(() => {
3979	console.info("subscribeSystemLiveView success");
3980}).catch((err: BusinessError) => {
3981    console.error(`subscribeSystemLiveView failed, code is ${err.code}, message is ${err.message}`);
3982});
3983```
3984
3985## notificationManager.setDistributedEnabledByBundle<sup>12+</sup>
3986
3987setDistributedEnabledByBundle(bundle: BundleOption, deviceType: string, enable: boolean): Promise<void\>
3988
3989设置指定应用是否支持跨设备协同。使用Promise异步回调。
3990
3991该接口不支持tv和wearable设备。
3992
3993**系统能力**:SystemCapability.Notification.Notification
3994
3995**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
3996
3997**系统接口**:此接口为系统接口。
3998
3999**参数:**
4000
4001| 参数名   | 类型                     | 必填 | 说明                       |
4002| -------- | ------------------------ | ---- | -------------------------- |
4003| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包信息。                   |
4004| deviceType | string | 是   | 设备类型。|
4005| enable   | boolean                  | 是   | 指定应用是否支持跨设备协同(true:支持,false:不支持)。|
4006
4007**返回值:**
4008
4009| 类型 | 说明 |
4010| ---- | ----|
4011| Promise\<void> | 无返回结果的Promise对象。 |
4012
4013**错误码:**
4014
4015以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4016
4017| 错误码ID | 错误信息                                 |
4018| -------- | ---------------------------------------- |
4019| 201      | Permission denied.     |
4020| 202      | Not system application to call the interface.                                      |
4021| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4022| 801 | Capability not supported. |
4023| 1600001  | Internal error.                          |
4024| 1600002  | Marshalling or unmarshalling error.      |
4025| 1600003  | Failed to connect to the service.               |
4026| 1600010  | Distributed operation failed.            |
4027| 1600012  | No memory space.                    |
4028| 17700001 | The specified bundle name was not found. |
4029
4030**示例:**
4031
4032```ts
4033import { BusinessError } from '@kit.BasicServicesKit';
4034
4035let bundle: notificationManager.BundleOption = {
4036    bundle: "bundleName1",
4037    uid: 1
4038};
4039let enable: boolean = true;
4040let deviceType: string = "phone";
4041notificationManager.setDistributedEnabledByBundle(bundle, deviceType, enable).then(() => {
4042    console.info("setDistributedEnabledByBundle success");
4043}).catch((err: BusinessError) => {
4044    console.error(`setDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
4045});
4046```
4047
4048## notificationManager.isDistributedEnabledByBundle<sup>12+</sup>
4049
4050isDistributedEnabledByBundle(bundle: BundleOption, deviceType: string): Promise<boolean\>
4051
4052获取指定应用是否支持跨设备协同。使用Promise异步回调。
4053
4054该接口不支持tv和wearable设备。
4055
4056**系统能力**:SystemCapability.Notification.Notification
4057
4058**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4059
4060**系统接口**:此接口为系统接口。
4061
4062**参数:**
4063
4064| 参数名   | 类型                     | 必填 | 说明                       |
4065| -------- | ------------------------ | ---- | -------------------------- |
4066| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | 是   | 应用的包信息。                   |
4067| deviceType | string | 是   | 设备类型。 |
4068
4069**返回值:**
4070
4071| 类型 | 说明 |
4072| ---- | ----|
4073| Promise\<boolean\> | 以Promise形式返回指定应用是否支持跨设备协同的开关是否开启的结果(true:开启,false:未开启)。 |
4074
4075**错误码:**
4076
4077以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4078
4079| 错误码ID | 错误信息                                 |
4080| -------- | ---------------------------------------- |
4081| 201      | Permission denied.     |
4082| 202      | Not system application to call the interface.                                      |
4083| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4084| 801 | Capability not supported. |
4085| 1600001  | Internal error.                          |
4086| 1600002  | Marshalling or unmarshalling error.      |
4087| 1600003  | Failed to connect to the service.               |
4088| 1600010  | Distributed operation failed.            |
4089| 1600012  | No memory space.                    |
4090| 17700001 | The specified bundle name was not found. |
4091
4092**示例:**
4093
4094```ts
4095import { BusinessError } from '@kit.BasicServicesKit';
4096
4097let bundle: notificationManager.BundleOption = {
4098    bundle: "bundleName1",
4099    uid: 1
4100};
4101let deviceType: string = "phone";
4102notificationManager.isDistributedEnabledByBundle(bundle, deviceType).then((data: boolean) => {
4103    console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
4104}).catch((err: BusinessError) => {
4105    console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
4106});
4107```
4108
4109## notificationManager.setSmartReminderEnabled<sup>12+</sup>
4110
4111setSmartReminderEnabled(deviceType: string, enable: boolean): Promise<void\>
4112
4113设置设备是否与其他设备协同智能提醒。使用Promise异步回调。
4114
4115该接口不支持tv和wearable设备。
4116
4117**系统能力**:SystemCapability.Notification.Notification
4118
4119**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4120
4121**系统接口**:此接口为系统接口。
4122
4123**参数:**
4124
4125| 参数名   | 类型                     | 必填 | 说明                       |
4126| -------- | ------------------------ | ---- | -------------------------- |
4127| deviceType | string | 是   | 设备类型。 |
4128| enable   | boolean                  | 是   | 指定应用是否支持设备是否与其他设备协同智能提醒(true:支持,false:不支持)。|
4129
4130**返回值:**
4131
4132| 类型 | 说明 |
4133| ---- | ----|
4134| Promise\<void> | 无返回结果的Promise对象。 |
4135
4136**错误码:**
4137
4138以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4139
4140| 错误码ID | 错误信息                                 |
4141| -------- | ---------------------------------------- |
4142| 201      | Permission denied.     |
4143| 202      | Not system application to call the interface.                                      |
4144| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4145| 801 | Capability not supported. |
4146| 1600001  | Internal error.                          |
4147| 1600002  | Marshalling or unmarshalling error.      |
4148| 1600003  | Failed to connect to the service.               |
4149| 1600010  | Distributed operation failed.            |
4150| 1600012  | No memory space.                    |
4151| 17700001 | The specified bundle name was not found. |
4152
4153**示例:**
4154
4155```ts
4156import { BusinessError } from '@kit.BasicServicesKit';
4157
4158let deviceType: string = "phone";
4159let enable: boolean = true;
4160notificationManager.setSmartReminderEnabled(deviceType, enable).then(() => {
4161    console.info("setSmartReminderEnabled success");
4162}).catch((err: BusinessError) => {
4163    console.error(`setSmartReminderEnabled failed, code is ${err.code}, message is ${err.message}`);
4164});
4165```
4166
4167## notificationManager.isSmartReminderEnabled<sup>12+</sup>
4168
4169isSmartReminderEnabled(deviceType: string): Promise<boolean\>
4170
4171获取设备是否与其他设备协同智能提醒。使用Promise异步回调。
4172
4173该接口不支持tv和wearable设备。
4174
4175**系统能力**:SystemCapability.Notification.Notification
4176
4177**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4178
4179**系统接口**:此接口为系统接口。
4180
4181**参数:**
4182
4183| 参数名   | 类型                     | 必填 | 说明                       |
4184| -------- | ------------------------ | ---- | -------------------------- |
4185| deviceType | string | 是   | 设备类型。 |
4186
4187**返回值:**
4188
4189| 类型 | 说明 |
4190| ---- | ----|
4191| Promise\<boolean\> | 以Promise形式返回设备与其他设备协同智能提醒的开关是否开启的结果(true:开启,false:未开启)。 |
4192
4193**错误码:**
4194
4195以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4196
4197| 错误码ID | 错误信息                                 |
4198| -------- | ---------------------------------------- |
4199| 201      | Permission denied.     |
4200| 202      | Not system application to call the interface.                                      |
4201| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4202| 801 | Capability not supported. |
4203| 1600001  | Internal error.                          |
4204| 1600002  | Marshalling or unmarshalling error.      |
4205| 1600003  | Failed to connect to the service.               |
4206| 1600010  | Distributed operation failed.            |
4207| 1600012  | No memory space.                    |
4208| 17700001 | The specified bundle name was not found. |
4209
4210**示例:**
4211
4212```ts
4213import { BusinessError } from '@kit.BasicServicesKit';
4214
4215let deviceType: string = "phone";
4216notificationManager.isSmartReminderEnabled(deviceType).then((data: boolean) => {
4217    console.info("isSmartReminderEnabled success, data:" + data);
4218}).catch((err: BusinessError) => {
4219    console.error(`isSmartReminderEnabled failed, code is ${err.code}, message is ${err.message}`);
4220});
4221```
4222
4223## notificationManager.setBadgeNumberByBundle<sup>12+</sup>
4224
4225setBadgeNumberByBundle(bundle: BundleOption, badgeNumber: number): Promise\<void\>
4226
4227代理其他应用设定角标个数。使用Promise异步回调。
4228
4229该接口不支持wearable设备。
4230
4231**系统能力**:SystemCapability.Notification.Notification
4232
4233**系统接口**:此接口为系统接口。
4234
4235**参数:**
4236
4237| 参数名      | 类型   | 必填 | 说明       |
4238| ----------- | ------ | ---- | ---------- |
4239| bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
4240| badgeNumber | number | 是   | 角标个数。 |
4241
4242**返回值:**
4243
4244| 类型            | 说明                      |
4245| --------------- | ------------------------- |
4246| Promise\<void\> | 无返回结果的Promise对象。 |
4247
4248**错误码:**
4249
4250以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4251
4252| 错误码ID | 错误信息                            |
4253| -------- | ----------------------------------- |
4254| 202      | Not system application to call the interface.                                      |
4255| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4256| 801 | Capability not supported. |
4257| 1600001  | Internal error.                     |
4258| 1600002  | Marshalling or unmarshalling error. |
4259| 1600003  | Failed to connect to the service.          |
4260| 1600012  | No memory space.                    |
4261| 1600017  | There is no corresponding agent relationship configuration.     |
4262| 17700001 | The specified bundle name was not found.   |
4263
4264**示例:**
4265
4266```ts
4267import { BusinessError } from '@kit.BasicServicesKit';
4268
4269let bundle: notificationManager.BundleOption = {
4270    bundle: 'com.example.bundleName',
4271};
4272let badgeNumber: number = 10;
4273
4274notificationManager.setBadgeNumberByBundle(bundle, badgeNumber).then(() => {
4275    console.info('setBadgeNumberByBundle success');
4276}).catch((err: BusinessError) => {
4277    console.error(`setBadgeNumberByBundle failed, code is ${err.code}, message is ${err.message}`);
4278});
4279```
4280
4281## notificationManager.getSlotByBundle<sup>12+</sup>
4282
4283getSlotByBundle(bundle: BundleOption, slotType: SlotType): Promise\<NotificationSlot>
4284
4285获取指定应用指定类型的通知渠道。使用Promise异步回调。
4286
4287该接口不支持wearable设备。
4288
4289获取前需要先通过[addSlot](#notificationmanageraddslot)创建通知渠道。
4290
4291**系统能力**:SystemCapability.Notification.Notification
4292
4293**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4294
4295**系统接口**:此接口为系统接口。
4296
4297**参数:**
4298
4299| 参数名   | 类型         | 必填 | 说明       |
4300| ------ | ------------ | ---- | ---------- |
4301| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是   | 指定应用的包信息。 |
4302| slotType | [SlotType](././js-apis-notificationManager.md#slottype) | 是   | 渠道类型。 |
4303
4304**返回值:**
4305
4306| 类型                                                        | 说明                                                         |
4307| ----------------------------------------------------------- | ------------------------------------------------------------ |
4308| Promise\<[NotificationSlot](js-apis-inner-notification-notificationSlot-sys.md)> | 以Promise形式返回获取指定应用指定类型的通知渠道。 |
4309
4310**错误码:**
4311
4312以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4313
4314| 错误码ID | 错误信息                                 |
4315| -------- | ---------------------------------------- |
4316| 201      | Permission denied.     |
4317| 202      | Not system application to call the interface.                                      |
4318| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4319| 801 | Capability not supported. |
4320| 1600001  | Internal error.                          |
4321| 1600002  | Marshalling or unmarshalling error.      |
4322| 1600003  | Failed to connect to the service.               |
4323| 1600012  | No memory space.                         |
4324| 17700001 | The specified bundle name was not found. |
4325
4326**示例:**
4327
4328```ts
4329import { BusinessError } from '@kit.BasicServicesKit';
4330
4331let bundle: notificationManager.BundleOption = {
4332    bundle: "bundleName1",
4333};
4334
4335let slotType = notificationManager.SlotType.LIVE_VIEW;
4336
4337notificationManager.getSlotByBundle(bundle, slotType).then((data: notificationManager.NotificationSlot) => {
4338	console.info("getSlotByBundle success, data: " + JSON.stringify(data));
4339}).catch((err: BusinessError) => {
4340    console.error(`getSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
4341});
4342```
4343
4344## notificationManager.addDoNotDisturbProfile<sup>12+</sup>
4345
4346addDoNotDisturbProfile(templates: Array\<DoNotDisturbProfile>): Promise\<void\>
4347
4348添加勿扰模式配置信息。使用Promise异步回调。
4349
4350该接口不支持wearable设备。
4351
4352**系统能力**:SystemCapability.Notification.Notification
4353
4354**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4355
4356**系统接口**:此接口为系统接口。
4357
4358**参数:**
4359
4360| 参数名   | 类型             | 必填 | 说明           |
4361| ------ | ---------------- | ---- | -------------- |
4362| templates   | Array\<[DoNotDisturbProfile](#donotdisturbprofile12)> | 是 | 勿扰模式的配置信息。 |
4363
4364**返回值:**
4365
4366| 类型      | 说明        |
4367|---------|-----------|
4368| Promise\<void\> | 无返回结果的Promise对象。 |
4369
4370**错误码:**
4371
4372以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4373
4374| 错误码ID | 错误信息                            |
4375| -------- | ----------------------------------- |
4376| 201      | Permission denied.     |
4377| 202      | Not system application to call the interface.                                      |
4378| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4379| 801 | Capability not supported. |
4380| 1600001  | Internal error.                     |
4381| 1600002  | Marshalling or unmarshalling error. |
4382| 1600003  | Failed to connect to the service.          |
4383| 1600012  | No memory space.                    |
4384
4385**示例:**
4386
4387```ts
4388import { BusinessError } from '@kit.BasicServicesKit';
4389
4390let trustlist: Array<notificationManager.BundleOption> = [
4391  {
4392    bundle: 'com.example.bundleName',
4393    uid: 0
4394  },
4395  {
4396    bundle: 'com.example.bundleName1',
4397    uid: 1
4398  }
4399]
4400let templates: Array<notificationManager.DoNotDisturbProfile> = [
4401  {
4402    id: 3,
4403    name: '工作模式',
4404    trustlist: trustlist
4405  }
4406]
4407
4408notificationManager.addDoNotDisturbProfile(templates).then(() => {
4409  console.info("addDoNotDisturbProfile success.");
4410}).catch((err: BusinessError) => {
4411  console.error(`addDoNotDisturbProfile failed, code is ${err.code}, message is ${err.message}`);
4412});
4413```
4414
4415## notificationManager.removeDoNotDisturbProfile<sup>12+</sup>
4416
4417removeDoNotDisturbProfile(templates: Array\<DoNotDisturbProfile>): Promise\<void\>
4418
4419删除勿扰模式配置。使用Promise异步回调。
4420
4421该接口不支持tv和wearable设备。
4422
4423**系统能力**:SystemCapability.Notification.Notification
4424
4425**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4426
4427**系统接口**:此接口为系统接口。
4428
4429**参数:**
4430
4431| 参数名   | 类型             | 必填 | 说明           |
4432| ------ | ---------------- | ---- | -------------- |
4433| templates   | Array\<[DoNotDisturbProfile](#donotdisturbprofile12)> | 是  | 勿扰模式的配置信息。 |
4434
4435**返回值:**
4436
4437| 类型      | 说明        |
4438|---------|-----------|
4439| Promise\<void\> | 无返回结果的Promise对象。 |
4440
4441**错误码:**
4442
4443以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4444
4445| 错误码ID | 错误信息                            |
4446| -------- | ----------------------------------- |
4447| 201      | Permission denied.     |
4448| 202      | Not system application to call the interface.                                      |
4449| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4450| 801 | Capability not supported. |
4451| 1600001  | Internal error.                     |
4452| 1600002  | Marshalling or unmarshalling error. |
4453| 1600003  | Failed to connect to the service.          |
4454| 1600012  | No memory space.                    |
4455
4456**示例:**
4457
4458```ts
4459import { BusinessError } from '@kit.BasicServicesKit';
4460
4461let templates: Array<notificationManager.DoNotDisturbProfile> = [
4462  {
4463    id: 3,
4464    name: '工作模式'
4465  }
4466]
4467notificationManager.removeDoNotDisturbProfile(templates).then(() => {
4468  console.info("removeDoNotDisturbProfile success.");
4469}).catch((err: BusinessError) => {
4470  console.error(`removeDoNotDisturbProfile failed, code is ${err.code}, message is ${err.message}`);
4471});
4472```
4473
4474## notificationManager.setAdditionalConfig<sup>12+</sup>
4475
4476setAdditionalConfig(key: string, value: string): Promise\<number\>
4477
4478设置通知的系统附加配置信息。使用Promise异步回调。
4479
4480该接口不支持tv和wearable设备。
4481
4482**系统能力**:SystemCapability.Notification.Notification
4483
4484**需要权限**:ohos.permission.NOTIFICATION_AGENT_CONTROLLER
4485
4486**系统接口**:此接口为系统接口。
4487
4488**参数:**
4489
4490| 参数名   | 类型             | 必填 | 说明           |
4491| ------ | ---------------- | ---- | -------------- |
4492| key   | string | 是  | 附加配置键。目前仅支持`RING_TRUSTLIST_PKG`,表示应用支持使用[自定义铃声](./js-apis-inner-notification-notificationRequest.md#notificationrequest-1)。 |
4493| value   | string | 是  | 附加配置值。参数示例:[bundleName1,bundleName2]。 |
4494
4495**返回值:**
4496
4497| 类型      | 说明        |
4498|---------|-----------|
4499| Promise\<number\> | Promise对象,返回0表示设置成功,返回其他值表示设置失败。 |
4500
4501**错误码:**
4502
4503以下错误码的详细介绍请参见[通知错误码](./errorcode-notification.md)。
4504
4505| 错误码ID | 错误信息                            |
4506| -------- | ----------------------------------- |
4507| 201      | Permission denied.     |
4508| 202      | Not system application to call the interface.                                      |
4509| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4510| 801 | Capability not supported. |
4511| 1600001  | Internal error.                     |
4512| 1600002  | Marshalling or unmarshalling error. |
4513| 1600003  | Failed to connect to the service.          |
4514
4515**示例:**
4516
4517```ts
4518import { BusinessError } from '@kit.BasicServicesKit';
4519
4520notificationManager.setAdditionalConfig('RING_TRUSTLIST_PKG','[bundleName1,bundleName2]').then((data: number) => {
4521  console.info("setAdditionalConfig success, data: " + JSON.stringify(data));
4522}).catch((err: BusinessError) => {
4523  console.error(`setAdditionalConfig failed, code is ${err.code}, message is ${err.message}`);
4524});
4525```
4526
4527## notificationManager.getDoNotDisturbProfile<sup>13+</sup>
4528
4529getDoNotDisturbProfile(id: number): Promise\<DoNotDisturbProfile\>
4530
4531查询勿扰模式配置信息。使用Promise异步回调。
4532
4533该接口不支持tv和wearable设备。
4534
4535**系统能力**:SystemCapability.Notification.Notification
4536
4537**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4538
4539**系统接口**:此接口为系统接口。
4540
4541**参数:**
4542
4543| 参数名   | 类型             | 必填 | 说明           |
4544| ------ | ---------------- | ---- | -------------- |
4545| id   | number | 是  | 勿扰模式编号。 |
4546
4547**返回值:**
4548
4549| 类型      | 说明        |
4550|---------|-----------|
4551| Promise\<[DoNotDisturbProfile](#donotdisturbprofile12)\> | Promise对象,返回勿扰模式的配置信息。 |
4552
4553**错误码:**
4554
4555以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4556
4557| 错误码ID | 错误信息                            |
4558| -------- | ----------------------------------- |
4559| 201      | Permission denied.     |
4560| 202      | Not system application to call the interface.                                      |
4561| 401     | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed.      |
4562| 801 | Capability not supported. |
4563| 1600001  | Internal error.                     |
4564| 1600002  | Marshalling or unmarshalling error. |
4565| 1600003  | Failed to connect to the service.          |
4566| 1600019  | The do-not-disturb profile does not exist.                    |
4567
4568**示例:**
4569
4570```ts
4571import { BusinessError } from '@kit.BasicServicesKit';
4572
4573notificationManager.getDoNotDisturbProfile(1).then((data: notificationManager.DoNotDisturbProfile) => {
4574  console.info("getDoNotDisturbProfile success: " + JSON.stringify(data));
4575}).catch((err: BusinessError) => {
4576  console.error(`getDoNotDisturbProfile failed, code is ${err.code}, message is ${err.message}`);
4577});
4578```
4579
4580## notificationManager.disableNotificationFeature<sup>18+</sup>
4581
4582disableNotificationFeature(disabled: boolean, bundleList: Array\<string\>): Promise\<void\>
4583
4584将应用包名添加到通知发布权限管控名单,以阻止应用发布通知。支持启用或关闭该功能。
4585
4586该接口不支持wearable设备。
4587
4588**系统能力**:SystemCapability.Notification.Notification
4589
4590**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4591
4592**系统接口**:此接口为系统接口。
4593
4594**参数:**
4595
4596| 参数名   | 类型                                                         | 必填 | 说明                     |
4597| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4598| disabled | boolean | 是   | 是否启用通知发布权限管控名单(true:开启,false:关闭)。 |
4599| bundleList | Array\<string\> | 是   | 指定通知发布权限管控名单的应用列表,使用包名代表应用。 |
4600
4601**返回值:**
4602
4603| 类型            | 说明                     |
4604|-----------------|-------------------------|
4605| Promise\<void\> | 无返回结果的Promise对象。 |
4606
4607**错误码**:
4608
4609以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[通知错误码](./errorcode-notification.md)。
4610
4611| 错误码ID | 错误信息                                                     |
4612| -------- | ------------------------------------------------------------ |
4613| 201      | Permission verification failed. The application does not have the permission required to call the API. |
4614| 202      | Permission verification failed. A non-system application calls a system API. |
4615| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4616| 801 | Capability not supported. |
4617| 1600001      | Internal error.                     |
4618| 1600002      | Marshalling or unmarshalling error. |
4619
4620**示例:**
4621
4622```ts
4623import { notificationManager } from '@kit.NotificationKit';
4624import { BusinessError } from '@kit.BasicServicesKit';
4625import { hilog } from '@kit.PerformanceAnalysisKit';
4626
4627let disabled: boolean = true;
4628let bundleList: Array<string> = ["com.example.myapplication"];
4629try {
4630  notificationManager.disableNotificationFeature(disabled, bundleList).then(() => {
4631    hilog.info(0x0000, 'testTag', '%{public}s', `disableNotificationFeature success.`);
4632  }).catch((err: BusinessError) => {
4633    hilog.error(0x0000, 'testTag', '%{public}s', `disableNotificationFeature failed, code is ${err.code}, message is ${err.message}`);
4634  });
4635} catch (err) {
4636  hilog.error(0x0000, 'testTag', '%{public}s', `testTag failed, code is ${err.code}, message is ${err.message}`);
4637}
4638```
4639
4640## notificationManager.setTargetDeviceStatus<sup>18+</sup>
4641
4642setTargetDeviceStatus(deviceType: string, status: number): Promise\<void\>
4643
4644设置设备配对成功后的状态。当发布通知时,会根据各个设备的状态来确定当前设备的通知提醒方式。
4645
4646**系统能力**:SystemCapability.Notification.Notification
4647
4648**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4649
4650**系统接口**:此接口为系统接口。
4651
4652**参数:**
4653
4654| 参数名   | 类型                                                         | 必填 | 说明                     |
4655| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4656| deviceType | string | 是   | 设备类型。当前仅支持`headset`(可穿戴式音频设备)、`liteWearable`(轻量级智能穿戴设备)、`wearable`(智能穿戴设备)、`current`(本设备)。 |
4657| status | number | 是   | 设备状态。<br>- bit0:设备是否正在被使用。0表示未使用,1表示使用中。<br>- bit1:当前设备使用者是否为机主。0表示为非机主,1表示为机主。<br>- bit2:设备是否处于勿扰模式。0表示处于非勿扰模式,1表示处于勿扰模式。 |
4658
4659**返回值:**
4660
4661| 类型            | 说明                     |
4662|-----------------|-------------------------|
4663| Promise\<void\> | 无返回结果的Promise对象。 |
4664
4665**错误码**:
4666
4667以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
4668
4669| 错误码ID | 错误信息                                                     |
4670| -------- | ------------------------------------------------------------ |
4671| 201      | Permission verification failed. The application does not have the permission required to call the API. |
4672| 202      | Permission verification failed. A non-system application calls a system API. |
4673| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4674
4675**示例:**
4676
4677```ts
4678import { BusinessError } from '@kit.BasicServicesKit';
4679
4680notificationManager.setTargetDeviceStatus("current", 1).then(() => {
4681  console.info(`Succeeded in setting target device status.`);
4682}).catch((err: BusinessError) => {
4683  console.error(`Failed to set target device status. Code is ${err.code}, message is ${err.message}`);
4684});
4685```
4686
4687## notificationManager.setDistributedEnabledBySlot<sup>18+</sup>
4688
4689setDistributedEnabledBySlot(slot: SlotType, deviceType: string, enabled: boolean): Promise\<void\>
4690
4691设置指定渠道的通知是否支持通知跨设备协同至指定类型设备。使用Promise异步回调。
4692
4693**系统能力**:SystemCapability.Notification.Notification
4694
4695**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4696
4697**系统接口**:此接口为系统接口。
4698
4699**参数:**
4700
4701| 参数名   | 类型                                                         | 必填 | 说明                     |
4702| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4703| slot | [SlotType](js-apis-notificationManager.md#slottype) | 是   | 通知渠道类型。 |
4704| deviceType | string | 是   | 设备类型。取值范围包括:wearable(智能穿戴设备)、litewearable(轻量级智能穿戴设备)、headset(可穿戴式音频设备)。 |
4705| enabled | boolean | 是   | 是否开启通知跨设备协同开关。取值为true表示打开,取值为false表示关闭。 |
4706
4707**返回值:**
4708
4709| 类型            | 说明                     |
4710|-----------------|-------------------------|
4711| Promise\<void\> | 无返回结果的Promise对象。 |
4712
4713**错误码**:
4714
4715以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
4716
4717| 错误码ID | 错误信息                                                     |
4718| -------- | ------------------------------------------------------------ |
4719| 201      | Permission verification failed. The application does not have the permission required to call the API. |
4720| 202      | Permission verification failed. A non-system application calls a system API. |
4721| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4722
4723**示例:**
4724
4725```ts
4726import { notificationManager } from '@kit.NotificationKit';
4727import { BusinessError } from '@kit.BasicServicesKit';
4728import { hilog } from '@kit.PerformanceAnalysisKit';
4729
4730let slot: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
4731let deviceType: string = 'wearable';
4732let enabled: boolean = true;
4733
4734notificationManager.setDistributedEnabledBySlot(slot, deviceType, enabled).then(() => {
4735    hilog.info(0x0000, 'testTag', '%{public}s', `setDistributedEnabledBySlot success.`);
4736}).catch((err: BusinessError) => {
4737    hilog.error(0x0000, 'testTag', '%{public}s', `setDistributedEnabledBySlot failed, code is ${err.code}, message is ${err.message}`);
4738});
4739```
4740
4741## notificationManager.isDistributedEnabledBySlot<sup>18+</sup>
4742
4743isDistributedEnabledBySlot(slot: SlotType, deviceType: string): Promise\<boolean\>
4744
4745查询指定渠道的通知是否支持通知跨设备协同至指定类型设备。使用Promise异步回调。
4746
4747**系统能力**:SystemCapability.Notification.Notification
4748
4749**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER
4750
4751**系统接口**:此接口为系统接口。
4752
4753**参数:**
4754
4755| 参数名   | 类型                                                         | 必填 | 说明                     |
4756| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
4757| slot | [SlotType](js-apis-notificationManager.md#slottype) | 是   | 通知渠道类型。 |
4758| deviceType | string | 是   | 设备类型。取值范围包括:wearable(智能穿戴设备)、litewearable(轻量级智能穿戴设备)、headset(可穿戴式音频设备)。 |
4759
4760**返回值:**
4761
4762| 类型            | 说明                     |
4763|-----------------|-------------------------|
4764| Promise\<boolean\> | Promise对象,返回true表示指定渠道的通知支持通知跨设备协同至指定类型设备;返回false表示指定渠道的通知不支持通知跨设备协同至指定类型设备。 |
4765
4766**错误码**:
4767
4768以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
4769
4770| 错误码ID | 错误信息                                                     |
4771| -------- | ------------------------------------------------------------ |
4772| 201      | Permission verification failed. The application does not have the permission required to call the API. |
4773| 202      | Permission verification failed. A non-system application calls a system API. |
4774| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4775
4776**示例:**
4777
4778```ts
4779import { notificationManager } from '@kit.NotificationKit';
4780import { BusinessError } from '@kit.BasicServicesKit';
4781import { hilog } from '@kit.PerformanceAnalysisKit';
4782
4783let slot: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
4784let deviceType: string = 'wearable';
4785
4786notificationManager.isDistributedEnabledBySlot(slot, deviceType).then((data: boolean) => {
4787    hilog.info(0x0000, 'testTag', '%{public}s', `isDistributedEnabledBySlot success.`);
4788}).catch((err: BusinessError) => {
4789    hilog.error(0x0000, 'testTag', '%{public}s', `isDistributedEnabledBySlot failed, code is ${err.code}, message is ${err.message}`);
4790});
4791```
4792
4793## DoNotDisturbDate
4794
4795**系统能力**:SystemCapability.Notification.Notification
4796
4797**系统接口**:此接口为系统接口。
4798
4799| 名称  | 类型                                  | 必填 | 说明                   |
4800| ----- | ------------------------------------- | ---- | ---------------------- |
4801| type  | [DoNotDisturbType](#donotdisturbtype) | 是   | 免打扰设置的时间类型。 |
4802| begin | Date                                  | 是   | 免打扰设置的起点时间。 |
4803| end   | Date                                  | 是   | 免打扰设置的终点时间。 |
4804
4805## DoNotDisturbType
4806
4807**系统能力**:SystemCapability.Notification.Notification
4808
4809**系统接口**:此接口为系统接口。
4810
4811| 名称         | 值               | 说明                                       |
4812| ------------ | ---------------- | ------------------------------------------ |
4813| TYPE_NONE    | 0 | 非通知勿扰类型。                           |
4814| TYPE_ONCE    | 1 | 以设置时间段(只看小时和分钟)一次执行勿扰。 |
4815| TYPE_DAILY   | 2 | 以设置时间段(只看小时和分钟)每天执行勿扰。 |
4816| TYPE_CLEARLY | 3 | 以设置时间段(明确月日时)执行勿扰。     |
4817
4818
4819## DeviceRemindType
4820
4821**系统能力**:SystemCapability.Notification.Notification
4822
4823**系统接口**:此接口为系统接口。
4824
4825| 名称                 | 值  | 说明                               |
4826| -------------------- | --- | --------------------------------- |
4827| IDLE_DONOT_REMIND    | 0   | 设备未被使用,无需提醒。            |
4828| IDLE_REMIND          | 1   | 提醒设备未被使用。                 |
4829| ACTIVE_DONOT_REMIND  | 2   | 设备正在使用,无需提醒。            |
4830| ACTIVE_REMIND        | 3   | 提醒设备正在使用。                 |
4831
4832
4833## SourceType
4834
4835**系统能力**:SystemCapability.Notification.Notification
4836
4837**系统接口**:此接口为系统接口。
4838
4839| 名称                 | 值  | 说明                  |
4840| -------------------- | --- | -------------------- |
4841| TYPE_NORMAL          | 0   | 一般通知。            |
4842| TYPE_CONTINUOUS      | 1   | 连续通知。            |
4843| TYPE_TIMER           | 2   | 计划通知。            |
4844
4845## NotificationCheckInfo<sup>10+</sup>
4846
4847**系统能力**:SystemCapability.Notification.Notification
4848
4849**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
4850
4851**系统接口**:此接口为系统接口。
4852
4853| 名称                         | 类型                         | 必填 | 说明            |
4854| ---------------------------- | ---------------------------- | --- | --------------- |
4855| bundleName                   | string                       | 是   | Bundle名称。    |
4856| notificationId               | number                       | 是   | 通知ID。        |
4857| label<sup>11+</sup>          | string                       | 否   | 通知标签。      |
4858| contentType                  | [ContentType](./js-apis-notificationManager.md#contenttype)  | 是   | 通知类型。      |
4859| creatorUserId<sup>11+</sup>  | number                       | 是   | 通知的user ID。 |
4860| slotType<sup>11+</sup>       | [SlotType](./js-apis-notificationManager.md#slottype)        | 是   | 渠道类型。      |
4861| extraInfos<sup>11+</sup>     | [key: string]: object        | 否   | 实况通知的附加信息。 |
4862
4863## NotificationCheckResult<sup>10+</sup>
4864
4865**系统能力**:SystemCapability.Notification.Notification
4866
4867**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
4868
4869**系统接口**:此接口为系统接口。
4870
4871| 名称    | 类型                                  | 必填 | 说明                   |
4872| ------- | ------------------------------------ | ---- | ---------------------- |
4873| code    | number                               | 是   | 0-display,1-no display。 |
4874| message | string                               | 是   | 结果信息。    |
4875
4876
4877## ButtonOptions<sup>11+</sup>
4878
4879描述触发按钮信息。
4880
4881**系统能力**:SystemCapability.Notification.Notification
4882
4883**需要权限**:ohos.permission.NOTIFICATION_CONTROLLERohos.permission.NOTIFICATION_AGENT_CONTROLLER
4884
4885**系统接口**:此接口为系统接口。
4886
4887| 名称    | 类型                                  | 必填 | 说明                   |
4888| ------- | ------------------------------------ | ---- | ---------------------- |
4889| buttonName    | string                         | 是   | 按钮名称。 |
4890
4891
4892## SystemLiveViewSubscriber<sup>11+</sup>
4893
4894系统实况窗订阅者。
4895
4896**系统能力**:SystemCapability.Notification.Notification
4897
4898**系统接口**:此接口为系统接口。
4899
4900
4901| 名称    | 类型                                  | 必填 | 说明                   |
4902| ------- | ------------------------------------ | ---- | ---------------------- |
4903| onResponse    | (notificationId: number, buttonOptions: [ButtonOptions](#buttonoptions11)) => void                         | 否   | 点击按钮的回调。 |
4904
4905
4906## SlotType
4907
4908**系统能力**:SystemCapability.Notification.Notification
4909
4910| 名称                                | 值     | 说明                                                         |
4911| ----------------------------------- | ------ | ------------------------------------------------------------ |
4912| EMERGENCY_INFORMATION<sup>12+</sup> | 10     | 紧急事件。**系统接口**:此接口为系统接口。                               |
4913
4914
4915## NotificationControlFlagStatus<sup>12+</sup>
4916每个bit位都可以控制通知的提示方式。当notificationControlFlags和下表中枚举值进行按位或操作,则表示关闭其提示方式。
4917
4918**系统能力**:SystemCapability.Notification.Notification
4919
4920**系统接口**:此接口为系统接口。
4921
4922| 名称                                 | 值   | 说明     |
4923| ------------------------------------ | ---- | -------- |
4924| NOTIFICATION_STATUS_CLOSE_SOUND      | 1<<0 | 关闭声音提示功能。 |
4925| NOTIFICATION_STATUS_CLOSE_LOCKSCREEN |  1<<1    |     关闭锁屏提示功能。     |
4926| NOTIFICATION_STATUS_CLOSE_BANNER     |    1<<2   |     关闭横幅提示功能。     |
4927| NOTIFICATION_STATUS_CLOSE_LIGHT_SCREEN     |   1<<3   |     关闭亮屏提示功能。     |
4928| NOTIFICATION_STATUS_CLOSE_VIBRATION     |   1<<4   |     关闭振动提示功能。     |
4929| NOTIFICATION_STATUS_CLOSE_STATUSBAR_ICON     |  1<<5    |     关闭状态栏图标提示功能。     |
4930
4931## DoNotDisturbProfile<sup>12+</sup>
4932
4933**系统能力**:SystemCapability.Notification.Notification
4934
4935**系统接口**:此接口为系统接口。
4936
4937| 名称  | 类型                                  | 必填 | 说明                   |
4938| ----- | ------------------------------------- | ---- | ---------------------- |
4939| id | number | 是 | 勿扰模式编号。 |
4940| name | string  | 是 | 勿扰模式名称。 |
4941| trustlist | Array\<[BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)> | 否 | 勿扰模式的信任列表。 |
4942
4943## NotificationLiveViewContent<sup>11+</sup>
4944
4945type NotificationLiveViewContent = _NotificationLiveViewContent
4946
4947描述普通实况通知。
4948
4949**系统能力:** SystemCapability.Notification.Notification
4950
4951**系统接口**:此接口为系统接口。
4952
4953| 类型 | 说明 |
4954| --- | --- |
4955| [_NotificationLiveViewContent](js-apis-inner-notification-notificationContent-sys.md#notificationliveviewcontent11) | 描述普通实况通知。 |
4956
4957