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