js-apis-notificationManager.md 149.3 KB
Newer Older
E
ester.zhou 已提交
1
# @ohos.notificationManager (NotificationManager)
E
esterzhou 已提交
2 3 4 5 6 7 8 9 10

The **notificationManager** module provides notification management capabilities, covering notifications, notification slots, notification enabled status, and notification badge status.

> **NOTE**
>
> 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.

## Modules to Import

E
ester.zhou 已提交
11 12
```ts
import notificationManager from '@ohos.notificationManager';
13
import Base from '@ohos.base';
E
esterzhou 已提交
14 15
```

E
ester.zhou 已提交
16
## notificationManager.publish
E
esterzhou 已提交
17 18 19 20 21 22 23 24 25 26 27

publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void

Publishes a notification. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
E
ester.zhou 已提交
28
| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
29 30 31 32
| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                       |

**Error codes**

E
ester.zhou 已提交
33 34
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
35 36 37 38 39 40 41 42
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
| 1600001  | Internal error.                           |
| 1600002  | Marshalling or unmarshalling error.       |
| 1600003  | Failed to connect service.                |
| 1600004  | Notification is not enabled.              |
| 1600005  | Notification slot is not enabled.         |
| 1600009  | Over max number notifications per second. |
E
ester.zhou 已提交
43
| 1600012  | No memory space.                          |
E
esterzhou 已提交
44 45 46

**Example**

E
ester.zhou 已提交
47
```ts
E
esterzhou 已提交
48
// publish callback
49
function publishCallback(err: Base.BusinessError) {
E
esterzhou 已提交
50
    if (err) {
E
ester.zhou 已提交
51
        console.error(`publish failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
52 53 54 55 56
    } else {
        console.info("publish success");
    }
}
// NotificationRequest object
E
ester.zhou 已提交
57
let notificationRequest: notificationManager.NotificationRequest = {
E
esterzhou 已提交
58 59
    id: 1,
    content: {
E
ester.zhou 已提交
60
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
61 62 63 64 65 66
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
67 68
};
notificationManager.publish(notificationRequest, publishCallback);
E
esterzhou 已提交
69 70
```

E
ester.zhou 已提交
71
## notificationManager.publish
E
esterzhou 已提交
72 73 74 75 76 77 78 79 80 81 82

publish(request: NotificationRequest): Promise\<void\>

Publishes a notification. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
E
ester.zhou 已提交
83
| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
84 85 86

**Error codes**

E
ester.zhou 已提交
87 88
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
89 90 91 92 93 94 95 96
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
| 1600001  | Internal error.                           |
| 1600002  | Marshalling or unmarshalling error.       |
| 1600003  | Failed to connect service.                |
| 1600004  | Notification is not enabled.              |
| 1600005  | Notification slot is not enabled.         |
| 1600009  | Over max number notifications per second. |
E
ester.zhou 已提交
97
| 1600012  | No memory space.                          |
E
esterzhou 已提交
98 99 100

**Example**

E
ester.zhou 已提交
101
```ts
E
esterzhou 已提交
102
// NotificationRequest object
E
ester.zhou 已提交
103
let notificationRequest: notificationManager.NotificationRequest = {
E
ester.zhou 已提交
104
    id: 1,
E
esterzhou 已提交
105
    content: {
E
ester.zhou 已提交
106
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
107 108 109 110 111 112
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
113 114
};
notificationManager.publish(notificationRequest).then(() => {
E
esterzhou 已提交
115 116 117 118 119
	console.info("publish success");
});

```

E
ester.zhou 已提交
120
## notificationManager.publish
E
esterzhou 已提交
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135

publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void

Publishes a notification to a specified user. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
E
ester.zhou 已提交
136
| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
137 138 139 140 141
| userId   | number                                      | Yes  | User ID.                          |
| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |

**Error codes**

E
ester.zhou 已提交
142 143
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
144 145 146 147 148 149 150 151 152
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
| 1600001  | Internal error.                           |
| 1600002  | Marshalling or unmarshalling error.       |
| 1600003  | Failed to connect service.                |
| 1600004  | Notification is not enabled.              |
| 1600005  | Notification slot is not enabled.         |
| 1600008  | The user is not exist.                    |
| 1600009  | Over max number notifications per second. |
E
ester.zhou 已提交
153
| 1600012  | No memory space.                          |
E
esterzhou 已提交
154 155 156

**Example**

E
ester.zhou 已提交
157
```ts
E
esterzhou 已提交
158
// publish callback
159
function publishCallback(err: Base.BusinessError) {
E
esterzhou 已提交
160
    if (err) {
E
ester.zhou 已提交
161
        console.error(`publish failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
162 163 164 165 166
    } else {
        console.info("publish success");
    }
}
// User ID
167
let userId: number = 1;
E
esterzhou 已提交
168
// NotificationRequest object
E
ester.zhou 已提交
169
let notificationRequest: notificationManager.NotificationRequest = {
E
esterzhou 已提交
170 171
    id: 1,
    content: {
E
ester.zhou 已提交
172
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
173 174 175 176 177 178
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
179 180
};
notificationManager.publish(notificationRequest, userId, publishCallback);
E
esterzhou 已提交
181 182
```

E
ester.zhou 已提交
183
## notificationManager.publish
E
esterzhou 已提交
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198

publish(request: NotificationRequest, userId: number): Promise\<void\>

Publishes a notification to a specified user. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    |  Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
E
ester.zhou 已提交
199
| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
200 201 202 203
| userId   | number                                      | Yes  | User ID.                          |

**Error codes**

E
ester.zhou 已提交
204 205
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
206 207 208 209 210 211 212 213 214
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
| 1600001  | Internal error.                           |
| 1600002  | Marshalling or unmarshalling error.       |
| 1600003  | Failed to connect service.                |
| 1600004  | Notification is not enabled.              |
| 1600005  | Notification slot is not enabled.         |
| 1600008  | The user is not exist.                    |
| 1600009  | Over max number notifications per second. |
E
ester.zhou 已提交
215
| 1600012  | No memory space.                          |
E
esterzhou 已提交
216 217 218

**Example**

E
ester.zhou 已提交
219
```ts
E
ester.zhou 已提交
220
let notificationRequest: notificationManager.NotificationRequest = {
E
ester.zhou 已提交
221
    id: 1,
E
esterzhou 已提交
222
    content: {
E
ester.zhou 已提交
223
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
224 225 226 227 228 229
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
230
};
E
esterzhou 已提交
231

232
let userId: number = 1;
E
esterzhou 已提交
233

E
ester.zhou 已提交
234
notificationManager.publish(notificationRequest, userId).then(() => {
E
esterzhou 已提交
235 236 237 238 239
	console.info("publish success");
});
```


E
ester.zhou 已提交
240
## notificationManager.cancel
E
esterzhou 已提交
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257

cancel(id: number, label: string, callback: AsyncCallback\<void\>): void

Cancels a notification with the specified ID and label. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| id       | number                | Yes  | Notification ID.              |
| label    | string                | Yes  | Notification label.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
258 259
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
260 261 262 263 264 265 266 267 268
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |

**Example**

E
ester.zhou 已提交
269
```ts
E
esterzhou 已提交
270
// cancel callback
271
function cancelCallback(err: Base.BusinessError) {
E
esterzhou 已提交
272
    if (err) {
E
ester.zhou 已提交
273
        console.error(`cancel failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
274 275 276 277
    } else {
        console.info("cancel success");
    }
}
E
ester.zhou 已提交
278
notificationManager.cancel(0, "label", cancelCallback);
E
esterzhou 已提交
279 280
```

E
ester.zhou 已提交
281
## notificationManager.cancel
E
esterzhou 已提交
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297

cancel(id: number, label?: string): Promise\<void\>

Cancels a notification with the specified ID and optional label. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name | Type  | Mandatory| Description    |
| ----- | ------ | ---- | -------- |
| id    | number | Yes  | Notification ID.  |
| label | string | No  | Notification label.|

**Error codes**

E
ester.zhou 已提交
298 299
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
300 301 302 303 304 305 306 307 308
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |

**Example**

E
ester.zhou 已提交
309 310
```ts
notificationManager.cancel(0).then(() => {
E
esterzhou 已提交
311 312 313 314
	console.info("cancel success");
});
```

E
ester.zhou 已提交
315
## notificationManager.cancel
E
esterzhou 已提交
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331

cancel(id: number, callback: AsyncCallback\<void\>): void

Cancels a notification with the specified ID. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| id       | number                | Yes  | Notification ID.              |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
332 333
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
334 335 336 337 338 339 340 341 342
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |

**Example**

E
ester.zhou 已提交
343
```ts
E
esterzhou 已提交
344
// cancel callback
345
function cancelCallback(err: Base.BusinessError) {
E
esterzhou 已提交
346
    if (err) {
E
ester.zhou 已提交
347
        console.error(`cancel failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
348 349 350 351
    } else {
        console.info("cancel success");
    }
}
E
ester.zhou 已提交
352
notificationManager.cancel(0, cancelCallback);
E
esterzhou 已提交
353 354
```

E
ester.zhou 已提交
355
## notificationManager.cancelAll
E
esterzhou 已提交
356 357 358 359 360 361 362 363 364

cancelAll(callback: AsyncCallback\<void\>): void

Cancels all notifications. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Error codes**

E
ester.zhou 已提交
365 366
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
367 368 369 370 371 372 373 374 375 376 377 378 379 380
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Example**

E
ester.zhou 已提交
381
```ts
E
esterzhou 已提交
382
// cancel callback
383
function cancelAllCallback(err: Base.BusinessError) {
E
esterzhou 已提交
384
    if (err) {
E
ester.zhou 已提交
385
        console.error(`cancelAll failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
386 387 388 389
    } else {
        console.info("cancelAll success");
    }
}
E
ester.zhou 已提交
390
notificationManager.cancelAll(cancelAllCallback);
E
esterzhou 已提交
391 392
```

E
ester.zhou 已提交
393
## notificationManager.cancelAll
E
esterzhou 已提交
394 395 396 397 398 399 400 401 402

cancelAll(): Promise\<void\>

Cancels all notifications. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Error codes**

E
ester.zhou 已提交
403 404
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
405 406 407 408 409 410 411 412
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
413 414
```ts
notificationManager.cancelAll().then(() => {
E
esterzhou 已提交
415 416 417 418
	console.info("cancelAll success");
});
```

E
ester.zhou 已提交
419
## notificationManager.addSlot
E
esterzhou 已提交
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434

addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void

Adds a notification slot. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
ester.zhou 已提交
435
| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot.md)       | Yes  | Notification slot to add.|
E
esterzhou 已提交
436 437 438 439
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
440 441
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
442 443 444 445 446
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
447
| 1600012  | No memory space.                          |
E
esterzhou 已提交
448 449 450

**Example**

E
ester.zhou 已提交
451
```ts
E
esterzhou 已提交
452
// addSlot callback
453
function addSlotCallBack(err: Base.BusinessError) {
E
esterzhou 已提交
454
    if (err) {
E
ester.zhou 已提交
455
        console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
456 457 458 459 460
    } else {
        console.info("addSlot success");
    }
}
// NotificationSlot object
461
let notificationSlot: notificationManager.NotificationSlot = {
E
ester.zhou 已提交
462 463 464
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
notificationManager.addSlot(notificationSlot, addSlotCallBack);
E
esterzhou 已提交
465 466
```

E
ester.zhou 已提交
467
## notificationManager.addSlot
E
esterzhou 已提交
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482

addSlot(slot: NotificationSlot): Promise\<void\>

Adds a notification slot. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name| Type            | Mandatory| Description                |
| ---- | ---------------- | ---- | -------------------- |
E
ester.zhou 已提交
483
| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes  | Notification slot to add.|
E
esterzhou 已提交
484 485 486

**Error codes**

E
ester.zhou 已提交
487 488
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
489 490 491 492 493
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
494
| 1600012  | No memory space.                          |
E
esterzhou 已提交
495 496 497

**Example**

E
ester.zhou 已提交
498
```ts
E
esterzhou 已提交
499
// NotificationSlot object
500
let notificationSlot: notificationManager.NotificationSlot = {
E
ester.zhou 已提交
501 502 503
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
notificationManager.addSlot(notificationSlot).then(() => {
E
esterzhou 已提交
504 505 506 507
	console.info("addSlot success");
});
```

E
ester.zhou 已提交
508
## notificationManager.addSlot
E
esterzhou 已提交
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524

addSlot(type: SlotType, callback: AsyncCallback\<void\>): void

Adds a notification slot of a specified type. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| type     | [SlotType](#slottype)              | Yes  | Type of the notification slot to add.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.  |

**Error codes**

E
ester.zhou 已提交
525 526
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
527 528 529 530 531
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
532
| 1600012  | No memory space.                    |
E
esterzhou 已提交
533 534 535

**Example**

E
ester.zhou 已提交
536
```ts
E
esterzhou 已提交
537
// addSlot callback
538
function addSlotCallBack(err: Base.BusinessError) {
E
esterzhou 已提交
539
    if (err) {
E
ester.zhou 已提交
540
        console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
541 542 543 544
    } else {
        console.info("addSlot success");
    }
}
E
ester.zhou 已提交
545
notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
E
esterzhou 已提交
546 547
```

E
ester.zhou 已提交
548
## notificationManager.addSlot
E
esterzhou 已提交
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563

addSlot(type: SlotType): Promise\<void\>

Adds a notification slot of a specified type. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name| Type    | Mandatory| Description                  |
| ---- | -------- | ---- | ---------------------- |
| type | [SlotType](#slottype) | Yes  | Type of the notification slot to add.|

**Error codes**

E
ester.zhou 已提交
564 565
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
566 567 568 569 570
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
571
| 1600012  | No memory space.                    |
E
esterzhou 已提交
572 573 574

**Example**

E
ester.zhou 已提交
575 576
```ts
notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {
E
esterzhou 已提交
577 578 579 580
	console.info("addSlot success");
});
```

E
ester.zhou 已提交
581
## notificationManager.addSlots
E
esterzhou 已提交
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596

addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void

Adds an array of notification slots. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                     | Mandatory| Description                    |
| -------- | ------------------------- | ---- | ------------------------ |
E
ester.zhou 已提交
597
| slots    | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes  | Notification slots to add.|
E
esterzhou 已提交
598 599 600 601
| callback | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |

**Error codes**

E
ester.zhou 已提交
602 603
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
604 605 606 607 608
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
609
| 1600012  | No memory space.                          |
E
esterzhou 已提交
610 611 612

**Example**

E
ester.zhou 已提交
613
```ts
E
esterzhou 已提交
614
// addSlots callback
615
function addSlotsCallBack(err: Base.BusinessError) {
E
esterzhou 已提交
616
    if (err) {
E
ester.zhou 已提交
617
        console.error(`addSlots failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
618 619 620 621 622
    } else {
        console.info("addSlots success");
    }
}
// NotificationSlot object
623
let notificationSlot: notificationManager.NotificationSlot = {
E
ester.zhou 已提交
624 625
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
E
esterzhou 已提交
626
// NotificationSlotArray object
627
let notificationSlotArray: notificationManager.NotificationSlot[] = new Array();
E
esterzhou 已提交
628 629
notificationSlotArray[0] = notificationSlot;

E
ester.zhou 已提交
630
notificationManager.addSlots(notificationSlotArray, addSlotsCallBack);
E
esterzhou 已提交
631 632
```

E
ester.zhou 已提交
633
## notificationManager.addSlots
E
esterzhou 已提交
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648

addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>

Adds an array of notification slots. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name | Type                     | Mandatory| Description                    |
| ----- | ------------------------- | ---- | ------------------------ |
E
ester.zhou 已提交
649
| slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes  | Notification slots to add.|
E
esterzhou 已提交
650 651 652

**Error codes**

E
ester.zhou 已提交
653 654
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
655 656 657 658 659
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
660
| 1600012  | No memory space.                          |
E
esterzhou 已提交
661 662 663

**Example**

E
ester.zhou 已提交
664
```ts
E
esterzhou 已提交
665
// NotificationSlot object
666
let notificationSlot: notificationManager.NotificationSlot = {
E
ester.zhou 已提交
667 668
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
E
esterzhou 已提交
669
// NotificationSlotArray object
670
let notificationSlotArray: notificationManager.NotificationSlot[] = new Array();
E
esterzhou 已提交
671 672
notificationSlotArray[0] = notificationSlot;

E
ester.zhou 已提交
673
notificationManager.addSlots(notificationSlotArray).then(() => {
E
esterzhou 已提交
674 675 676 677
	console.info("addSlots success");
});
```

E
ester.zhou 已提交
678
## notificationManager.getSlot
E
esterzhou 已提交
679 680 681 682 683 684 685 686 687 688 689 690

getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void

Obtains a notification slot of a specified type. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                             | Mandatory| Description                                                       |
| -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype)                          | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
E
ester.zhou 已提交
691
| callback | AsyncCallback\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes  | Callback used to return the result.                                       |
E
esterzhou 已提交
692 693 694

**Error codes**

E
ester.zhou 已提交
695 696
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
697 698 699 700 701 702 703 704
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
705
```ts
E
esterzhou 已提交
706
// getSlot callback
707
function getSlotCallback(err: Base.BusinessError, data: notificationManager.NotificationSlot) {
E
esterzhou 已提交
708
    if (err) {
E
ester.zhou 已提交
709
        console.error(`getSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
710
    } else {
711
        console.info(`getSlot success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
712 713
    }
}
714
let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
715
notificationManager.getSlot(slotType, getSlotCallback);
E
esterzhou 已提交
716 717
```

E
ester.zhou 已提交
718
## notificationManager.getSlot
E
esterzhou 已提交
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739

getSlot(slotType: SlotType): Promise\<NotificationSlot\>

Obtains a notification slot of a specified type. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type    | Mandatory| Description                                                       |
| -------- | -------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
740 741
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
742 743 744 745 746 747 748 749
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
750
```ts
751 752 753
let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;

notificationManager.getSlot(slotType).then((data: notificationManager.NotificationSlot) => {
E
esterzhou 已提交
754 755 756 757
	console.info("getSlot success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
758
## notificationManager.getSlots
E
esterzhou 已提交
759

E
ester.zhou 已提交
760
getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
E
esterzhou 已提交
761 762 763 764 765 766 767

Obtains all notification slots of this application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

E
ester.zhou 已提交
768 769
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
770 771
| Name    | Type                             | Mandatory| Description                |
| -------- | --------------------------------- | ---- | -------------------- |
E
ester.zhou 已提交
772
| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | Yes  | Callback used to return all notification slots of the current application.|
E
esterzhou 已提交
773 774 775 776 777 778 779 780 781 782 783

**Error codes**

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
784
```ts
E
esterzhou 已提交
785
// getSlots callback
786
function getSlotsCallback(err: Base.BusinessError, data: Array<notificationManager.NotificationSlot>) {
E
esterzhou 已提交
787
    if (err) {
E
ester.zhou 已提交
788
        console.error(`getSlots failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
789
    } else {
790
        console.info(`getSlots success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
791 792
    }
}
E
ester.zhou 已提交
793
notificationManager.getSlots(getSlotsCallback);
E
esterzhou 已提交
794 795
```

E
ester.zhou 已提交
796
## notificationManager.getSlots
E
esterzhou 已提交
797

E
ester.zhou 已提交
798
getSlots(): Promise\<Array\<NotificationSlot>>
E
esterzhou 已提交
799 800 801 802 803 804 805 806 807

Obtains all notification slots of this application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
E
ester.zhou 已提交
808
| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | Promise used to return all notification slots of the current application.|
E
esterzhou 已提交
809 810 811

**Error codes**

E
ester.zhou 已提交
812 813
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
814 815 816 817 818 819 820 821
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
822
```ts
823
notificationManager.getSlots().then((data: Array<notificationManager.NotificationSlot>) => {
E
esterzhou 已提交
824 825 826 827
	console.info("getSlots success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
828
## notificationManager.removeSlot
E
esterzhou 已提交
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844

removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void

Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                 | Mandatory| Description                                                       |
| -------- | --------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype)              | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                                       |

**Error codes**

E
ester.zhou 已提交
845 846
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
847 848 849 850 851 852 853 854
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
855
```ts
E
esterzhou 已提交
856
// removeSlot callback
857
function removeSlotCallback(err: Base.BusinessError) {
E
esterzhou 已提交
858
    if (err) {
E
ester.zhou 已提交
859
        console.error(`removeSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
860 861 862 863
    } else {
        console.info("removeSlot success");
    }
}
E
ester.zhou 已提交
864
let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
865
notificationManager.removeSlot(slotType, removeSlotCallback);
E
esterzhou 已提交
866 867
```

E
ester.zhou 已提交
868
## notificationManager.removeSlot
E
esterzhou 已提交
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883

removeSlot(slotType: SlotType): Promise\<void\>

Removes a notification slot of a specified type. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type    | Mandatory| Description                                                       |
| -------- | -------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|

**Error codes**

E
ester.zhou 已提交
884 885
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
886 887 888 889 890 891 892 893
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
894
```ts
895
let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
896
notificationManager.removeSlot(slotType).then(() => {
E
esterzhou 已提交
897 898 899 900
	console.info("removeSlot success");
});
```

E
ester.zhou 已提交
901
## notificationManager.removeAllSlots
E
esterzhou 已提交
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916

removeAllSlots(callback: AsyncCallback\<void\>): void

Removes all notification slots. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
917 918
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
919 920 921 922 923 924 925 926
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
927
```ts
928
function removeAllCallBack(err: Base.BusinessError) {
E
esterzhou 已提交
929
    if (err) {
E
ester.zhou 已提交
930
        console.error(`removeAllSlots failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
931 932 933 934
    } else {
        console.info("removeAllSlots success");
    }
}
E
ester.zhou 已提交
935
notificationManager.removeAllSlots(removeAllCallBack);
E
esterzhou 已提交
936 937
```

E
ester.zhou 已提交
938
## notificationManager.removeAllSlots
E
esterzhou 已提交
939 940 941 942 943 944 945 946 947

removeAllSlots(): Promise\<void\>

Removes all notification slots. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Error codes**

E
ester.zhou 已提交
948 949
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
950 951 952 953 954 955 956 957
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
958 959
```ts
notificationManager.removeAllSlots().then(() => {
E
esterzhou 已提交
960 961 962 963
	console.info("removeAllSlots success");
});
```

E
ester.zhou 已提交
964
## notificationManager.setNotificationEnable
E
esterzhou 已提交
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979

setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void

Sets whether to enable notification for a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
ester.zhou 已提交
980
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)   | Yes  | Bundle of the application.       |
E
esterzhou 已提交
981 982 983 984 985
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
986 987
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
988 989 990 991 992 993 994 995 996
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
997
```ts
998
function setNotificationEnableCallback(err: Base.BusinessError) {
E
esterzhou 已提交
999
    if (err) {
1000
        console.error(`setNotificationEnableCallback failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1001
    } else {
1002
        console.info("setNotificationEnableCallback success");
E
esterzhou 已提交
1003 1004
    }
}
1005
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1006
    bundle: "bundleName1",
E
ester.zhou 已提交
1007
};
1008
notificationManager.setNotificationEnable(bundle, false, setNotificationEnableCallback);
E
esterzhou 已提交
1009 1010
```

E
ester.zhou 已提交
1011
## notificationManager.setNotificationEnable
E
esterzhou 已提交
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026

setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>

Sets whether to enable notification for a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1027
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1028 1029 1030 1031
| enable | boolean      | Yes  | Whether to enable notification.  |

**Error codes**

E
ester.zhou 已提交
1032 1033
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1034 1035 1036 1037 1038 1039 1040 1041 1042
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1043
```ts
1044
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1045
    bundle: "bundleName1",
E
ester.zhou 已提交
1046 1047
};
notificationManager.setNotificationEnable(bundle, false).then(() => {
E
esterzhou 已提交
1048 1049 1050 1051
	console.info("setNotificationEnable success");
});
```

E
ester.zhou 已提交
1052
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067

isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void

Checks whether notification is enabled for a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
E
ester.zhou 已提交
1068
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle of the application.           |
E
ester.zhou 已提交
1069
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
1070 1071 1072

**Error codes**

E
ester.zhou 已提交
1073 1074
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1075 1076 1077 1078 1079 1080 1081 1082 1083
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1084
```ts
1085
function isNotificationEnabledCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
1086
    if (err) {
E
ester.zhou 已提交
1087
        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1088
    } else {
1089
        console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
1090 1091
    }
}
1092 1093

let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1094
    bundle: "bundleName1",
E
ester.zhou 已提交
1095
};
1096

E
ester.zhou 已提交
1097
notificationManager.isNotificationEnabled(bundle, isNotificationEnabledCallback);
E
esterzhou 已提交
1098 1099
```

E
ester.zhou 已提交
1100
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115

isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>

Checks whether notification is enabled for a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1116
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1117 1118 1119 1120 1121 1122 1123 1124 1125

**Return value**

| Type              | Description                                               |
| ------------------ | --------------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
1126 1127
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1128 1129 1130 1131 1132 1133 1134 1135 1136
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1137
```ts
1138
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1139
    bundle: "bundleName1",
E
ester.zhou 已提交
1140
};
1141
notificationManager.isNotificationEnabled(bundle).then((data: boolean) => {
E
esterzhou 已提交
1142 1143 1144 1145
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1146
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161

isNotificationEnabled(callback: AsyncCallback\<boolean\>): void

Checks whether notification is enabled for this application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
E
ester.zhou 已提交
1162
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
1163 1164 1165

**Error codes**

E
ester.zhou 已提交
1166 1167
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1168 1169 1170 1171 1172 1173 1174 1175
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1176
```ts
1177
function isNotificationEnabledCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
1178
    if (err) {
E
ester.zhou 已提交
1179
        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1180
    } else {
1181
        console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
1182 1183 1184
    }
}

E
ester.zhou 已提交
1185
notificationManager.isNotificationEnabled(isNotificationEnabledCallback);
E
esterzhou 已提交
1186 1187
```

E
ester.zhou 已提交
1188
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199

isNotificationEnabled(): Promise\<boolean\>

Checks whether notification is enabled for the current application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218
**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |

**Example**

```ts
1219
notificationManager.isNotificationEnabled().then((data: boolean) => {
E
ester.zhou 已提交
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```

## notificationManager.isNotificationEnabled

isNotificationEnabled(userId: number, callback: AsyncCallback\<boolean\>): void

Checks whether notification is enabled for a specified user. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
| userId   | number                | Yes  | User ID.|
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

```ts
1257
function isNotificationEnabledCallback(err: Base.BusinessError, data: boolean) {
E
ester.zhou 已提交
1258 1259 1260
    if (err) {
        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
    } else {
1261
        console.info(`isNotificationEnabled success, data is ${JSON.stringify(data)}`);
E
ester.zhou 已提交
1262 1263 1264
    }
}

1265
let userId: number = 1;
E
ester.zhou 已提交
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281

notificationManager.isNotificationEnabled(userId, isNotificationEnabledCallback);
```

## notificationManager.isNotificationEnabled

isNotificationEnabled(userId: number): Promise\<boolean\>

Checks whether notification is enabled for a specified user. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

E
esterzhou 已提交
1282 1283 1284 1285
**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1286
| userId | number       | Yes  | User ID.|
E
esterzhou 已提交
1287 1288 1289 1290 1291 1292 1293 1294 1295

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
1296 1297
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1298 1299 1300 1301 1302
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
E
ester.zhou 已提交
1303
| 1600008  | The user is not exist..                  |
E
esterzhou 已提交
1304 1305 1306

**Example**

E
ester.zhou 已提交
1307
```ts
1308
let userId: number = 1;
E
ester.zhou 已提交
1309

1310
notificationManager.isNotificationEnabled(userId).then((data: boolean) => {
E
esterzhou 已提交
1311 1312 1313 1314
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1315
## notificationManager.displayBadge
E
esterzhou 已提交
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330

displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void

Sets whether to enable the notification badge for a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
ester.zhou 已提交
1331
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle of the application.          |
E
esterzhou 已提交
1332 1333 1334 1335 1336
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
1337 1338
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1339 1340 1341 1342 1343 1344 1345 1346 1347
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1348
```ts
1349
function displayBadgeCallback(err: Base.BusinessError) {
E
esterzhou 已提交
1350
    if (err) {
E
ester.zhou 已提交
1351
        console.error(`displayBadge failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1352 1353 1354 1355
    } else {
        console.info("displayBadge success");
    }
}
1356
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1357
    bundle: "bundleName1",
E
ester.zhou 已提交
1358 1359
};
notificationManager.displayBadge(bundle, false, displayBadgeCallback);
E
esterzhou 已提交
1360 1361
```

E
ester.zhou 已提交
1362
## notificationManager.displayBadge
E
esterzhou 已提交
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377

displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>

Sets whether to enable the notification badge for a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1378
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1379 1380 1381 1382
| enable | boolean      | Yes  | Whether to enable notification.  |

**Error codes**

E
ester.zhou 已提交
1383 1384
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1385 1386 1387 1388 1389 1390 1391 1392 1393
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1394
```ts
1395
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1396
    bundle: "bundleName1",
E
ester.zhou 已提交
1397 1398
};
notificationManager.displayBadge(bundle, false).then(() => {
E
esterzhou 已提交
1399 1400 1401 1402
	console.info("displayBadge success");
});
```

E
ester.zhou 已提交
1403
## notificationManager.isBadgeDisplayed
E
esterzhou 已提交
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418

isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void

Checks whether the notification badge is enabled for a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
E
ester.zhou 已提交
1419
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle of the application.              |
1420
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
1421 1422 1423

**Error codes**

E
ester.zhou 已提交
1424 1425
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1426 1427 1428 1429 1430 1431 1432 1433 1434
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1435
```ts
1436
function isBadgeDisplayedCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
1437
    if (err) {
E
ester.zhou 已提交
1438
        console.error(`isBadgeDisplayed failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1439
    } else {
1440
        console.info(`isBadgeDisplayed success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
1441 1442
    }
}
1443
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1444
    bundle: "bundleName1",
E
ester.zhou 已提交
1445 1446
};
notificationManager.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
E
esterzhou 已提交
1447 1448
```

E
ester.zhou 已提交
1449
## notificationManager.isBadgeDisplayed
E
esterzhou 已提交
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464

isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>

Checks whether the notification badge is enabled for a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1465
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1466 1467 1468 1469 1470 1471 1472 1473 1474

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
1475 1476
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1477 1478 1479 1480 1481 1482 1483 1484 1485
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1486
```ts
1487
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1488
    bundle: "bundleName1",
E
ester.zhou 已提交
1489
};
1490 1491

notificationManager.isBadgeDisplayed(bundle).then((data: boolean) => {
E
esterzhou 已提交
1492 1493 1494 1495
	console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516
## notificationManager.setBadgeNumber<sup>10+</sup>

setBadgeNumber(badgeNumber: number): Promise\<void\>

Sets the notification badge number. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name     | Type  | Mandatory| Description      |
| ----------- | ------ | ---- | ---------- |
| badgeNumber | number | Yes  | Notification badge number to set.|

**Error codes**

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
1517
| 1600012  | No memory space.                          |
E
ester.zhou 已提交
1518 1519 1520 1521

**Example**

```ts
1522 1523
let badgeNumber: number = 10

E
ester.zhou 已提交
1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552
notificationManager.setBadgeNumber(badgeNumber).then(() => {
	console.info("displayBadge success");
});
```

## notificationManager.setBadgeNumber<sup>10+</sup>

setBadgeNumber(badgeNumber: number, callback: AsyncCallback\<void\>): void

Sets the notification badge number. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name     | Type                 | Mandatory| Description              |
| ----------- | --------------------- | ---- | ------------------ |
| badgeNumber | number                | Yes  | Notification badge number to set.        |
| callback    | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
1553
| 1600012  | No memory space.                          |
E
ester.zhou 已提交
1554 1555 1556 1557

**Example**

```ts
1558
function setBadgeNumberCallback(err: Base.BusinessError) {
E
ester.zhou 已提交
1559 1560 1561 1562 1563 1564 1565
    if (err) {
        console.info(`displayBadge failed code is ${err.code}, message is ${err.message}`);
    } else {
        console.info("displayBadge success");
    }
}

1566
let badgeNumber: number = 10
E
ester.zhou 已提交
1567 1568 1569
notificationManager.setBadgeNumber(badgeNumber, setBadgeNumberCallback);
```

E
ester.zhou 已提交
1570
## notificationManager.setSlotByBundle
E
esterzhou 已提交
1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585

setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void

Sets the notification slot for a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
ester.zhou 已提交
1586 1587
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle of the application.          |
| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot.md)      | Yes  | Notification slot.            |
E
esterzhou 已提交
1588 1589 1590 1591
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
1592 1593
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1594 1595 1596 1597 1598 1599 1600 1601 1602
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1603
```ts
1604
function setSlotByBundleCallback(err: Base.BusinessError) {
E
esterzhou 已提交
1605
    if (err) {
E
ester.zhou 已提交
1606
        console.error(`setSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1607 1608 1609 1610
    } else {
        console.info("setSlotByBundle success");
    }
}
1611
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1612
    bundle: "bundleName1",
E
ester.zhou 已提交
1613
};
1614
let notificationSlot: notificationManager.NotificationSlots = {
E
ester.zhou 已提交
1615 1616 1617
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
notificationManager.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
E
esterzhou 已提交
1618 1619
```

E
ester.zhou 已提交
1620
## notificationManager.setSlotByBundle
E
esterzhou 已提交
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635

setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>

Sets the notification slot for a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1636 1637
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
| slot   | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes  | Notification slot.|
E
esterzhou 已提交
1638 1639 1640

**Error codes**

E
ester.zhou 已提交
1641 1642
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1643 1644 1645 1646 1647 1648 1649 1650 1651
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1652
```ts
1653
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1654
    bundle: "bundleName1",
E
ester.zhou 已提交
1655
};
1656 1657

let notificationSlot: notificationManager.NotificationSlot = {
E
ester.zhou 已提交
1658 1659
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
1660

E
ester.zhou 已提交
1661
notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => {
E
esterzhou 已提交
1662 1663 1664 1665
	console.info("setSlotByBundle success");
});
```

E
ester.zhou 已提交
1666
## notificationManager.getSlotsByBundle
E
esterzhou 已提交
1667

E
ester.zhou 已提交
1668
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void
E
esterzhou 已提交
1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681

Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                                    | Mandatory| Description                |
| -------- | ---------------------------------------- | ---- | -------------------- |
E
ester.zhou 已提交
1682
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)                             | Yes  | Bundle of the application.          |
E
ester.zhou 已提交
1683
| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
1684 1685 1686

**Error codes**

E
ester.zhou 已提交
1687 1688
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1689 1690 1691 1692 1693 1694 1695 1696 1697
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1698
```ts
1699
function getSlotsByBundleCallback(err: Base.BusinessError, data: Array<notificationManager.NotificationSlot>) {
E
esterzhou 已提交
1700
    if (err) {
E
ester.zhou 已提交
1701
        console.error(`getSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1702
    } else {
1703
        console.info(`getSlotsByBundle success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
1704 1705
    }
}
1706
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1707
    bundle: "bundleName1",
E
ester.zhou 已提交
1708 1709
};
notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback);
E
esterzhou 已提交
1710 1711
```

E
ester.zhou 已提交
1712
## notificationManager.getSlotsByBundle
E
esterzhou 已提交
1713

E
ester.zhou 已提交
1714
getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>>
E
esterzhou 已提交
1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727

Obtains the notification slots of a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1728
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1729 1730 1731 1732 1733

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
E
ester.zhou 已提交
1734
| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)>> | Promise used to return the result.|
E
esterzhou 已提交
1735 1736 1737

**Error codes**

E
ester.zhou 已提交
1738 1739
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1740 1741 1742 1743 1744 1745 1746 1747 1748
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1749
```ts
1750
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1751
    bundle: "bundleName1",
E
ester.zhou 已提交
1752
};
1753 1754

notificationManager.getSlotsByBundle(bundle).then((data: Array<notificationManager.NotificationSlot>) => {
E
esterzhou 已提交
1755 1756 1757 1758
	console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1759
## notificationManager.getSlotNumByBundle
E
esterzhou 已提交
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774

getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void

Obtains the number of notification slots of a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                     | Mandatory| Description                  |
| -------- | ------------------------- | ---- | ---------------------- |
E
ester.zhou 已提交
1775
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)              | Yes  | Bundle of the application.            |
E
esterzhou 已提交
1776 1777 1778 1779
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
1780 1781
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1782 1783 1784 1785 1786 1787 1788 1789 1790
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1791
```ts
1792
function getSlotNumByBundleCallback(err: Base.BusinessError, data: number) {
E
esterzhou 已提交
1793
    if (err) {
E
ester.zhou 已提交
1794
        console.error(`getSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1795
    } else {
1796
        console.info(`getSlotNumByBundle success data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
1797 1798
    }
}
1799 1800

let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1801
    bundle: "bundleName1",
E
ester.zhou 已提交
1802
};
1803

E
ester.zhou 已提交
1804
notificationManager.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
E
esterzhou 已提交
1805 1806
```

E
ester.zhou 已提交
1807
## notificationManager.getSlotNumByBundle
E
esterzhou 已提交
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822

getSlotNumByBundle(bundle: BundleOption): Promise\<number\>

Obtains the number of notification slots of a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1823
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1824 1825 1826 1827 1828 1829 1830 1831 1832

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
1833 1834
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1835 1836 1837 1838 1839 1840 1841 1842 1843
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
1844
```ts
1845
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
1846
    bundle: "bundleName1",
E
ester.zhou 已提交
1847
};
1848 1849

notificationManager.getSlotNumByBundle(bundle).then((data: number) => {
E
esterzhou 已提交
1850 1851 1852 1853 1854
	console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
1855
## notificationManager.getAllActiveNotifications
E
esterzhou 已提交
1856

E
ester.zhou 已提交
1857
getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
E
esterzhou 已提交
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870

Obtains all active notifications. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                                                        | Mandatory| Description                |
| -------- | ------------------------------------------------------------ | ---- | -------------------- |
E
ester.zhou 已提交
1871
| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882

**Error codes**

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1883
```ts
1884
function getAllActiveNotificationsCallback(err: Base.BusinessError, data: Array<notificationManager.NotificationRequest>) {
E
esterzhou 已提交
1885
    if (err) {
E
ester.zhou 已提交
1886
        console.error(`getAllActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1887
    } else {
1888
        console.info(`getAllActiveNotifications success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
1889 1890 1891
    }
}

E
ester.zhou 已提交
1892
notificationManager.getAllActiveNotifications(getAllActiveNotificationsCallback);
E
esterzhou 已提交
1893 1894
```

E
ester.zhou 已提交
1895
## notificationManager.getAllActiveNotifications
E
esterzhou 已提交
1896

E
ester.zhou 已提交
1897
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\>
E
esterzhou 已提交
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910

Obtains all active notifications. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
E
ester.zhou 已提交
1911
| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | Promise used to return the result.|
E
esterzhou 已提交
1912 1913 1914

**Error codes**

E
ester.zhou 已提交
1915 1916
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1917 1918 1919 1920 1921 1922 1923 1924
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1925
```ts
1926
notificationManager.getAllActiveNotifications().then((data: Array<notificationManager.NotificationRequest>) => {
E
esterzhou 已提交
1927 1928 1929 1930
	console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1931
## notificationManager.getActiveNotificationCount
E
esterzhou 已提交
1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946

getActiveNotificationCount(callback: AsyncCallback\<number\>): void

Obtains the number of active notifications of this application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                  | Mandatory| Description                  |
| -------- | ---------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
1947 1948
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1949 1950 1951 1952 1953 1954 1955 1956
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1957
```ts
1958
function getActiveNotificationCountCallback(err: Base.BusinessError, data: number) {
E
esterzhou 已提交
1959
    if (err) {
E
ester.zhou 已提交
1960
        console.error(`getActiveNotificationCount failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1961
    } else {
1962
        console.info(`getActiveNotificationCount success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
1963 1964 1965
    }
}

E
ester.zhou 已提交
1966
notificationManager.getActiveNotificationCount(getActiveNotificationCountCallback);
E
esterzhou 已提交
1967 1968
```

E
ester.zhou 已提交
1969
## notificationManager.getActiveNotificationCount
E
esterzhou 已提交
1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984

getActiveNotificationCount(): Promise\<number\>

Obtains the number of active notifications of this application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Return value**

| Type             | Description                                       |
| ----------------- | ------------------------------------------- |
| Promise\<number\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
1985 1986
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1987 1988 1989 1990 1991 1992 1993 1994
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1995
```ts
1996
notificationManager.getActiveNotificationCount().then((data: number) => {
E
esterzhou 已提交
1997 1998 1999 2000
	console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
2001
## notificationManager.getActiveNotifications
E
esterzhou 已提交
2002

E
ester.zhou 已提交
2003
getActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void
E
esterzhou 已提交
2004 2005 2006 2007 2008 2009 2010 2011 2012

Obtains active notifications of this application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name    | Type                                                        | Mandatory| Description                          |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
E
ester.zhou 已提交
2013
| callback | AsyncCallback\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)>> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
2014 2015 2016

**Error codes**

E
ester.zhou 已提交
2017 2018
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2019 2020 2021 2022 2023 2024 2025 2026
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2027
```ts
2028
function getActiveNotificationsCallback(err: Base.BusinessError, data: Array<notificationManager.NotificationRequest>) {
E
esterzhou 已提交
2029
    if (err) {
E
ester.zhou 已提交
2030
        console.error(`getActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2031 2032 2033 2034 2035
    } else {
        console.info("getActiveNotifications success");
    }
}

E
ester.zhou 已提交
2036
notificationManager.getActiveNotifications(getActiveNotificationsCallback);
E
esterzhou 已提交
2037 2038
```

E
ester.zhou 已提交
2039
## notificationManager.getActiveNotifications
E
esterzhou 已提交
2040

E
ester.zhou 已提交
2041
getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\>
E
esterzhou 已提交
2042 2043 2044 2045 2046 2047 2048 2049 2050

Obtains active notifications of this application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Return value**

| Type                                                        | Description                                   |
| ------------------------------------------------------------ | --------------------------------------- |
E
ester.zhou 已提交
2051
| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | Promise used to return the result.|
E
esterzhou 已提交
2052 2053 2054

**Error codes**

E
ester.zhou 已提交
2055 2056
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2057 2058 2059 2060 2061 2062 2063 2064
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2065
```ts
2066
notificationManager.getActiveNotifications().then((data: Array<notificationManager.NotificationRequest>) => {
E
esterzhou 已提交
2067 2068 2069 2070
	console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
2071
## notificationManager.cancelGroup
E
esterzhou 已提交
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082

cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void

Cancels notifications under a notification group of this application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
E
ester.zhou 已提交
2083
| groupName | string                | Yes  | Name of the notification group, which is specified through [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) when the notification is published.|
E
esterzhou 已提交
2084 2085 2086 2087
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2088 2089
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2090 2091 2092 2093 2094 2095 2096 2097
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2098
```ts
2099
function cancelGroupCallback(err: Base.BusinessError) {
E
esterzhou 已提交
2100
    if (err) {
E
ester.zhou 已提交
2101
        console.error(`cancelGroup failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2102 2103 2104 2105 2106
    } else {
        console.info("cancelGroup success");
    }
}

2107
let groupName: string = "GroupName";
E
esterzhou 已提交
2108

E
ester.zhou 已提交
2109
notificationManager.cancelGroup(groupName, cancelGroupCallback);
E
esterzhou 已提交
2110 2111
```

E
ester.zhou 已提交
2112
## notificationManager.cancelGroup
E
esterzhou 已提交
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127

cancelGroup(groupName: string): Promise\<void\>

Cancels notifications under a notification group of this application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name     | Type  | Mandatory| Description          |
| --------- | ------ | ---- | -------------- |
| groupName | string | Yes  | Name of the notification group.|

**Error codes**

E
ester.zhou 已提交
2128 2129
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2130 2131 2132 2133 2134 2135 2136 2137
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2138
```ts
2139
let groupName: string = "GroupName";
E
ester.zhou 已提交
2140
notificationManager.cancelGroup(groupName).then(() => {
E
esterzhou 已提交
2141 2142 2143 2144
	console.info("cancelGroup success");
});
```

E
ester.zhou 已提交
2145
## notificationManager.removeGroupByBundle
E
esterzhou 已提交
2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160

removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void

Removes notifications under a notification group of a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
E
ester.zhou 已提交
2161
| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle information of the application.                  |
E
esterzhou 已提交
2162 2163 2164 2165 2166
| groupName | string                | Yes  | Name of the notification group.              |
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2167 2168
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2169 2170 2171 2172 2173 2174 2175 2176 2177
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
2178
```ts
2179
function removeGroupByBundleCallback(err: Base.BusinessError) {
E
esterzhou 已提交
2180
    if (err) {
E
ester.zhou 已提交
2181
        console.error(`removeGroupByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2182 2183 2184 2185 2186
    } else {
        console.info("removeGroupByBundle success");
    }
}

2187 2188
let bundleOption: notificationManager.BundleOption = { bundle: "Bundle" };
let groupName: string = "GroupName";
E
esterzhou 已提交
2189

E
ester.zhou 已提交
2190
notificationManager.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
E
esterzhou 已提交
2191 2192
```

E
ester.zhou 已提交
2193
## notificationManager.removeGroupByBundle
E
esterzhou 已提交
2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208

removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>

Removes notifications under a notification group of a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name     | Type        | Mandatory| Description          |
| --------- | ------------ | ---- | -------------- |
E
ester.zhou 已提交
2209
| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.    |
E
esterzhou 已提交
2210 2211 2212 2213
| groupName | string       | Yes  | Name of the notification group.|

**Error codes**

E
ester.zhou 已提交
2214 2215
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2216 2217 2218 2219 2220 2221 2222 2223 2224
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
2225
```ts
2226 2227 2228
let bundleOption: notificationManager.BundleOption = { bundle: "Bundle" };
let groupName: string = "GroupName";

E
ester.zhou 已提交
2229
notificationManager.removeGroupByBundle(bundleOption, groupName).then(() => {
E
esterzhou 已提交
2230 2231 2232 2233
	console.info("removeGroupByBundle success");
});
```

E
ester.zhou 已提交
2234
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254

setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void

Sets the DND time. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate)      | Yes  | DND time to set.        |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2255 2256
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2257 2258 2259 2260 2261
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2262
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2263 2264 2265

**Example**

E
ester.zhou 已提交
2266
```ts
2267
function setDoNotDisturbDateCallback(err: notificationManager.BundleOption) {
E
esterzhou 已提交
2268
    if (err) {
E
ester.zhou 已提交
2269
        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2270 2271 2272 2273 2274
    } else {
        console.info("setDoNotDisturbDate success");
    }
}

2275
let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
E
ester.zhou 已提交
2276
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2277 2278
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2279
};
E
esterzhou 已提交
2280

E
ester.zhou 已提交
2281
notificationManager.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
E
esterzhou 已提交
2282 2283
```

E
ester.zhou 已提交
2284
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303

setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>

Sets the DND time. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name| Type            | Mandatory| Description          |
| ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate) | Yes  | DND time to set.|

**Error codes**

E
ester.zhou 已提交
2304 2305
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2306 2307 2308 2309 2310
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2311
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2312 2313 2314

**Example**

E
ester.zhou 已提交
2315
```ts
2316
let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
E
ester.zhou 已提交
2317
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2318 2319
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2320 2321
};
notificationManager.setDoNotDisturbDate(doNotDisturbDate).then(() => {
E
esterzhou 已提交
2322 2323 2324 2325 2326
	console.info("setDoNotDisturbDate success");
});
```


E
ester.zhou 已提交
2327
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348

setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void

Sets the DND time for a specified user. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate)      | Yes  | DND time to set.        |
| userId   | number                | Yes  | ID of the user for whom you want to set the DND time.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2349 2350
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2351 2352 2353 2354 2355 2356
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2357
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2358 2359 2360

**Example**

E
ester.zhou 已提交
2361
```ts
2362
function setDoNotDisturbDateCallback(err: Base.BusinessError) {
E
esterzhou 已提交
2363
    if (err) {
E
ester.zhou 已提交
2364
        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2365 2366 2367 2368 2369
    } else {
        console.info("setDoNotDisturbDate success");
    }
}

2370
let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
E
ester.zhou 已提交
2371
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2372 2373
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2374
};
E
esterzhou 已提交
2375

2376
let userId: number = 1;
E
esterzhou 已提交
2377

E
ester.zhou 已提交
2378
notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
E
esterzhou 已提交
2379 2380
```

E
ester.zhou 已提交
2381
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401

setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>

Sets the DND time for a specified user. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type            | Mandatory| Description          |
| ------ | ---------------- | ---- | -------------- |
| date   | [DoNotDisturbDate](#donotdisturbdate) | Yes  | DND time to set.|
| userId | number           | Yes  | ID of the user for whom you want to set the DND time.|

**Error codes**

E
ester.zhou 已提交
2402 2403
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2404 2405 2406 2407 2408 2409
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2410
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2411 2412 2413

**Example**

E
ester.zhou 已提交
2414
```ts
2415
let doNotDisturbDate: notificationManager.DoNotDisturbDate = {
E
ester.zhou 已提交
2416
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2417 2418
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2419
};
E
esterzhou 已提交
2420

2421
let userId: number = 1;
E
esterzhou 已提交
2422

E
ester.zhou 已提交
2423
notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
E
esterzhou 已提交
2424 2425 2426 2427 2428
	console.info("setDoNotDisturbDate success");
});
```


E
ester.zhou 已提交
2429
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448

getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void

Obtains the DND time. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2449 2450
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2451 2452 2453 2454 2455
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2456
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2457 2458 2459

**Example**

E
ester.zhou 已提交
2460
```ts
2461
function getDoNotDisturbDateCallback(err: Base.BusinessError, data: notificationManager.DoNotDisturbDate) {
E
esterzhou 已提交
2462
    if (err) {
E
ester.zhou 已提交
2463
        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2464
    } else {
2465
        console.info(`getDoNotDisturbDate success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
2466 2467 2468
    }
}

E
ester.zhou 已提交
2469
notificationManager.getDoNotDisturbDate(getDoNotDisturbDateCallback);
E
esterzhou 已提交
2470 2471
```

E
ester.zhou 已提交
2472
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491

getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>

Obtains the DND time. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Return value**

| Type                                            | Description                                     |
| ------------------------------------------------ | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
2492 2493
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2494 2495 2496 2497 2498
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2499
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2500 2501 2502

**Example**

E
ester.zhou 已提交
2503
```ts
2504
notificationManager.getDoNotDisturbDate().then((data: notificationManager.DoNotDisturbDate) => {
E
esterzhou 已提交
2505 2506 2507 2508 2509
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
2510
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530

getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void

Obtains the DND time of a specified user. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | Yes  | Callback used to return the result.|
| userId   | number                            | Yes  | User ID.|

**Error codes**

E
ester.zhou 已提交
2531 2532
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2533 2534 2535 2536 2537 2538
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2539
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2540 2541 2542

**Example**

E
ester.zhou 已提交
2543
```ts
2544
function getDoNotDisturbDateCallback(err: Base.BusinessError, data: notificationManager.DoNotDisturbDate) {
E
esterzhou 已提交
2545
    if (err) {
E
ester.zhou 已提交
2546
        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2547
    } else {
2548
        console.info(`getDoNotDisturbDate success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
2549 2550 2551
    }
}

2552
let userId: number = 1;
E
esterzhou 已提交
2553

E
ester.zhou 已提交
2554
notificationManager.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
E
esterzhou 已提交
2555 2556
```

E
ester.zhou 已提交
2557
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582

getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>

Obtains the DND time of a specified user. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| userId   | number                            | Yes  | User ID.|

**Return value**

| Type                                            | Description                                     |
| ------------------------------------------------ | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
2583 2584
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2585 2586 2587 2588 2589 2590
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2591
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2592 2593 2594

**Example**

E
ester.zhou 已提交
2595
```ts
2596
let userId: number = 1;
E
esterzhou 已提交
2597

2598
notificationManager.getDoNotDisturbDate(userId).then((data: notificationManager.DoNotDisturbDate) => {
E
esterzhou 已提交
2599 2600 2601 2602 2603
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
2604
## notificationManager.isSupportDoNotDisturbMode
E
esterzhou 已提交
2605

E
ester.zhou 已提交
2606
 isSupportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
E
esterzhou 已提交
2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631

Checks whether DND mode is supported. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name    | Type                    | Mandatory| Description                            |
| -------- | ------------------------ | ---- | -------------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|

**Error codes**

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2632
```ts
2633
function isSupportDoNotDisturbModeCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
2634
    if (err) {
E
ester.zhou 已提交
2635
        console.error(`isSupportDoNotDisturbMode failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2636
    } else {
E
ester.zhou 已提交
2637
        console.info("isSupportDoNotDisturbMode success");
E
esterzhou 已提交
2638 2639 2640
    }
}

E
ester.zhou 已提交
2641
notificationManager.isSupportDoNotDisturbMode(isSupportDoNotDisturbModeCallback);
E
esterzhou 已提交
2642 2643
```

E
ester.zhou 已提交
2644
## notificationManager.isSupportDoNotDisturbMode
E
esterzhou 已提交
2645

E
ester.zhou 已提交
2646
isSupportDoNotDisturbMode(): Promise\<boolean\>
E
esterzhou 已提交
2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663

Checks whether DND mode is supported. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
2664 2665
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2666 2667 2668 2669 2670 2671 2672 2673
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2674
```ts
2675
notificationManager.isSupportDoNotDisturbMode().then((data: data) => {
E
esterzhou 已提交
2676 2677 2678 2679
	console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
2680
## notificationManager.isSupportTemplate
E
esterzhou 已提交
2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696

isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void

Checks whether a specified template is supported. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name      | Type                    | Mandatory| Description                      |
| ------------ | ------------------------ | ---- | -------------------------- |
| templateName | string                   | Yes  | Template name.                  |
| callback     | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2697 2698
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2699 2700 2701 2702 2703 2704 2705 2706 2707
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
2708 2709
let templateName: string = 'process';
function isSupportTemplateCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
2710
    if (err) {
E
ester.zhou 已提交
2711
        console.error(`isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2712 2713 2714 2715 2716
    } else {
        console.info("isSupportTemplate success");
    }
}

E
ester.zhou 已提交
2717
notificationManager.isSupportTemplate(templateName, isSupportTemplateCallback);
E
esterzhou 已提交
2718 2719
```

E
ester.zhou 已提交
2720
## notificationManager.isSupportTemplate
E
esterzhou 已提交
2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741

isSupportTemplate(templateName: string): Promise\<boolean\>

Checks whether a specified template is supported. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name      | Type  | Mandatory| Description    |
| ------------ | ------ | ---- | -------- |
| templateName | string | Yes  | Template name.|

**Return value**

| Type              | Description           |
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
2742 2743
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2744 2745 2746 2747 2748 2749 2750 2751 2752
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
2753
let templateName: string = 'process';
E
esterzhou 已提交
2754

2755
notificationManager.isSupportTemplate(templateName).then((data: boolean) => {
E
esterzhou 已提交
2756 2757 2758 2759
    console.info("isSupportTemplate success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
2760
## notificationManager.requestEnableNotification
E
esterzhou 已提交
2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775

requestEnableNotification(callback: AsyncCallback\<void\>): void

Requests notification to be enabled for this application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2776 2777
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2778 2779 2780 2781 2782 2783 2784 2785 2786
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
2787
function requestEnableNotificationCallback(err: Base.BusinessError) {
E
esterzhou 已提交
2788
    if (err) {
E
ester.zhou 已提交
2789
        console.error(`requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2790 2791 2792 2793 2794
    } else {
        console.info("requestEnableNotification success");
    }
};

E
ester.zhou 已提交
2795
notificationManager.requestEnableNotification(requestEnableNotificationCallback);
E
esterzhou 已提交
2796 2797
```

E
ester.zhou 已提交
2798
## notificationManager.requestEnableNotification
E
esterzhou 已提交
2799 2800 2801 2802 2803 2804 2805 2806 2807

requestEnableNotification(): Promise\<void\>

Requests notification to be enabled for this application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Error codes**

E
ester.zhou 已提交
2808 2809
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2810 2811 2812 2813 2814 2815 2816 2817 2818
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
E
ester.zhou 已提交
2819
notificationManager.requestEnableNotification().then(() => {
E
esterzhou 已提交
2820 2821 2822 2823 2824 2825
    console.info("requestEnableNotification success");
});
```



E
ester.zhou 已提交
2826
## notificationManager.setDistributedEnable
E
esterzhou 已提交
2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846

setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void

Sets whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2847 2848
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2849 2850 2851 2852 2853 2854 2855 2856 2857 2858
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
2859
function setDistributedEnableCallback(err: Base.BusinessError) {
E
esterzhou 已提交
2860
    if (err) {
E
ester.zhou 已提交
2861
        console.error(`setDistributedEnable failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2862 2863 2864 2865 2866
    } else {
        console.info("setDistributedEnable success");
    }
};

2867
let enable: boolean = true;
E
esterzhou 已提交
2868

E
ester.zhou 已提交
2869
notificationManager.setDistributedEnable(enable, setDistributedEnableCallback);
E
esterzhou 已提交
2870 2871
```

E
ester.zhou 已提交
2872
## notificationManager.setDistributedEnable
E
esterzhou 已提交
2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891

setDistributedEnable(enable: boolean): Promise\<void>

Sets whether this device supports distributed notifications. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|

**Error codes**

E
ester.zhou 已提交
2892 2893
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2894 2895 2896 2897 2898 2899 2900 2901 2902 2903
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
2904
let enable: boolean = true;
E
esterzhou 已提交
2905

E
ester.zhou 已提交
2906
notificationManager.setDistributedEnable(enable).then(() => {
2907 2908
    console.info("setDistributedEnable success");
});
E
esterzhou 已提交
2909 2910 2911
```


E
ester.zhou 已提交
2912
## notificationManager.isDistributedEnabled
E
esterzhou 已提交
2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927

isDistributedEnabled(callback: AsyncCallback\<boolean>): void

Checks whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
2928 2929
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2930 2931 2932 2933 2934 2935 2936 2937 2938 2939
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
2940
function isDistributedEnabledCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
2941
    if (err) {
E
ester.zhou 已提交
2942
        console.error(`isDistributedEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2943 2944 2945 2946 2947
    } else {
        console.info("isDistributedEnabled success " + JSON.stringify(data));
    }
};

E
ester.zhou 已提交
2948
notificationManager.isDistributedEnabled(isDistributedEnabledCallback);
E
esterzhou 已提交
2949 2950 2951 2952
```



E
ester.zhou 已提交
2953
## notificationManager.isDistributedEnabled
E
esterzhou 已提交
2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968

isDistributedEnabled(): Promise\<boolean>

Checks whether this device supports distributed notifications. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Return value**

| Type              | Description                                         |
| ------------------ | --------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
2969 2970
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2971 2972 2973 2974 2975 2976 2977 2978 2979 2980
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
E
ester.zhou 已提交
2981
notificationManager.isDistributedEnabled()
2982
    .then((data: boolean) => {
E
esterzhou 已提交
2983 2984 2985 2986 2987
        console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
    });
```


E
ester.zhou 已提交
2988
## notificationManager.setDistributedEnableByBundle
E
esterzhou 已提交
2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003

setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void

Sets whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3004
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
3005
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                      |
E
esterzhou 已提交
3006 3007 3008 3009
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3010 3011
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 1600010  | Distributed operation failed.            |
| 17700001 | The specified bundle name was not found. |

**Example**

```javascript
3023
function setDistributedEnableByBundleCallback(err: Base.BusinessError) {
E
esterzhou 已提交
3024
    if (err) {
E
ester.zhou 已提交
3025
        console.error(`setDistributedEnableByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3026 3027 3028 3029 3030
    } else {
        console.info("enableDistributedByBundle success");
    }
};

3031
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
3032
    bundle: "bundleName1",
E
ester.zhou 已提交
3033
};
E
esterzhou 已提交
3034

3035
let enable: boolean = true
E
esterzhou 已提交
3036

E
ester.zhou 已提交
3037
notificationManager.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback);
E
esterzhou 已提交
3038 3039 3040 3041
```



E
ester.zhou 已提交
3042
## notificationManager.setDistributedEnableByBundle
E
esterzhou 已提交
3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057

setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void>

Sets whether a specified application supports distributed notifications. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3058
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.               |
E
ester.zhou 已提交
3059
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                 |
E
esterzhou 已提交
3060 3061 3062

**Error codes**

E
ester.zhou 已提交
3063 3064
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 1600010  | Distributed operation failed.            |
| 17700001 | The specified bundle name was not found. |

**Example**

```javascript
3076
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
3077
    bundle: "bundleName1",
E
ester.zhou 已提交
3078
};
E
esterzhou 已提交
3079

3080
let enable: boolean = true
E
esterzhou 已提交
3081

E
ester.zhou 已提交
3082 3083 3084
notificationManager.setDistributedEnableByBundle(bundle, enable).then(() => {
    console.info("setDistributedEnableByBundle success");
});
E
esterzhou 已提交
3085 3086
```

E
ester.zhou 已提交
3087
## notificationManager.isDistributedEnabledByBundle
E
esterzhou 已提交
3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102

isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void

Checks whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3103
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.                    |
E
esterzhou 已提交
3104 3105 3106 3107
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3108 3109
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 1600010  | Distributed operation failed.            |
| 17700001 | The specified bundle name was not found. |

**Example**

```javascript
3121
function isDistributedEnabledByBundleCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
3122
    if (err) {
E
ester.zhou 已提交
3123
        console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3124 3125 3126 3127 3128
    } else {
        console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
    }
};

3129
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
3130
    bundle: "bundleName1",
E
ester.zhou 已提交
3131
};
E
esterzhou 已提交
3132

E
ester.zhou 已提交
3133
notificationManager.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
esterzhou 已提交
3134 3135
```

E
ester.zhou 已提交
3136
## notificationManager.isDistributedEnabledByBundle
E
esterzhou 已提交
3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151

isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>

Checks whether a specified application supports distributed notifications. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3152
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.               |
E
esterzhou 已提交
3153 3154 3155 3156 3157 3158 3159 3160 3161

**Return value**

| Type              | Description                                             |
| ------------------ | ------------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
3162 3163
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 1600010  | Distributed operation failed.            |
| 17700001 | The specified bundle name was not found. |

**Example**

```javascript
3175
let bundle: notificationManager.BundleOption = {
E
esterzhou 已提交
3176
    bundle: "bundleName1",
E
ester.zhou 已提交
3177
};
E
esterzhou 已提交
3178

3179
notificationManager.isDistributedEnabledByBundle(bundle).then((data: boolean) => {
E
esterzhou 已提交
3180 3181 3182 3183 3184
    console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
3185
## notificationManager.getDeviceRemindType
E
esterzhou 已提交
3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204

getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void

Obtains the notification reminder type. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name  | Type                              | Mandatory| Description                      |
| -------- | --------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3205 3206
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3207 3208 3209 3210 3211 3212 3213 3214 3215
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
3216
function getDeviceRemindTypeCallback(err: Base.BusinessError, data: notificationManager.DeviceRemindType) {
E
esterzhou 已提交
3217
    if (err) {
E
ester.zhou 已提交
3218
        console.error(`getDeviceRemindType failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3219
    } else {
3220
        console.info(`getDeviceRemindType success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
3221 3222 3223
    }
};

E
ester.zhou 已提交
3224
notificationManager.getDeviceRemindType(getDeviceRemindTypeCallback);
E
esterzhou 已提交
3225 3226
```

E
ester.zhou 已提交
3227
## notificationManager.getDeviceRemindType
E
esterzhou 已提交
3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246

getDeviceRemindType(): Promise\<DeviceRemindType\>

Obtains the notification reminder type. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Return value**

| Type              | Description           |
| ------------------ | --------------- |
| Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
3247 3248
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3249 3250 3251 3252 3253 3254 3255 3256 3257
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
3258
notificationManager.getDeviceRemindType().then((data: notificationManager.DeviceRemindType) => {
E
esterzhou 已提交
3259 3260 3261 3262 3263
    console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
3264
## notificationManager.publishAsBundle
E
esterzhou 已提交
3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279

publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void

Publishes a notification through the reminder agent. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name              | Type                                       | Mandatory| Description                                    |
| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
E
ester.zhou 已提交
3280
| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
3281 3282 3283 3284 3285 3286
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                      |
| userId               | number                                      | Yes  | User ID.                                |
| callback             | AsyncCallback                               | Yes  | Callback used to return the result.                |

**Error codes**

E
ester.zhou 已提交
3287 3288
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3289 3290 3291 3292 3293 3294 3295 3296 3297
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
| 1600001  | Internal error.                           |
| 1600002  | Marshalling or unmarshalling error.       |
| 1600003  | Failed to connect service.                |
| 1600004  | Notification is not enabled.              |
| 1600005  | Notification slot is not enabled.         |
| 1600008  | The user is not exist.                    |
| 1600009  | Over max number notifications per second. |
E
ester.zhou 已提交
3298
| 1600012  | No memory space.                          |
E
esterzhou 已提交
3299 3300 3301

**Example**

E
ester.zhou 已提交
3302
```ts
E
esterzhou 已提交
3303
// publishAsBundle callback
3304
function callback(err: Base.BusinessError) {
E
esterzhou 已提交
3305
    if (err) {
E
ester.zhou 已提交
3306
        console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3307 3308 3309 3310 3311
    } else {
        console.info("publishAsBundle success");
    }
}
// Bundle name of the application whose notification function is taken over by the reminder agent
3312
let representativeBundle: string = "com.example.demo";
E
esterzhou 已提交
3313
// User ID
3314
let userId: number = 100;
E
esterzhou 已提交
3315
// NotificationRequest object
3316
let request: notificationManager.NotificationRequest = {
E
esterzhou 已提交
3317 3318
    id: 1,
    content: {
E
ester.zhou 已提交
3319
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
3320 3321 3322 3323 3324 3325
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
3326
};
E
esterzhou 已提交
3327

E
ester.zhou 已提交
3328
notificationManager.publishAsBundle(request, representativeBundle, userId, callback);
E
esterzhou 已提交
3329 3330
```

E
ester.zhou 已提交
3331
## notificationManager.publishAsBundle
E
esterzhou 已提交
3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347

publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>

Publishes a notification through the reminder agent. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
3348
| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
3349 3350 3351 3352 3353
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                           |
| userId               | number                                      | Yes  | User ID.                           |

**Error codes**

E
ester.zhou 已提交
3354 3355
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3356 3357 3358 3359 3360 3361 3362 3363 3364
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
| 1600001  | Internal error.                           |
| 1600002  | Marshalling or unmarshalling error.       |
| 1600003  | Failed to connect service.                |
| 1600004  | Notification is not enabled.              |
| 1600005  | Notification slot is not enabled.         |
| 1600008  | The user is not exist.                    |
| 1600009  | Over max number notifications per second. |
E
ester.zhou 已提交
3365
| 1600012  | No memory space.                          |
E
esterzhou 已提交
3366 3367 3368

**Example**

E
ester.zhou 已提交
3369
```ts
E
esterzhou 已提交
3370
// Bundle name of the application whose notification function is taken over by the reminder agent
3371
let representativeBundle: string = "com.example.demo";
E
esterzhou 已提交
3372
// User ID
3373
let userId: number = 100;
E
esterzhou 已提交
3374
// NotificationRequest object
3375
let request: notificationManager.NotificationRequest = {
E
esterzhou 已提交
3376 3377
    id: 1,
    content: {
E
ester.zhou 已提交
3378
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
3379 3380 3381 3382 3383 3384
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
3385
};
E
esterzhou 已提交
3386

E
ester.zhou 已提交
3387
notificationManager.publishAsBundle(request, representativeBundle, userId).then(() => {
E
esterzhou 已提交
3388 3389 3390 3391
	console.info("publishAsBundle success");
});
```

E
ester.zhou 已提交
3392
## notificationManager.cancelAsBundle
E
esterzhou 已提交
3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416

cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void

Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name              | Type         | Mandatory| Description                    |
| -------------------- | ------------- | ---- | ------------------------ |
| id                   | number        | Yes  | Notification ID.                |
| representativeBundle | string        | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.      |
| userId               | number        | Yes  | User ID.      |
| callback             | AsyncCallback | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3417 3418
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3419 3420 3421 3422 3423 3424 3425 3426 3427 3428
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3429
```ts
E
esterzhou 已提交
3430
// cancelAsBundle
3431
function cancelAsBundleCallback(err: Base.BusinessError) {
E
esterzhou 已提交
3432
    if (err) {
E
ester.zhou 已提交
3433
        console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3434 3435 3436 3437 3438
    } else {
        console.info("cancelAsBundle success");
    }
}
// Bundle name of the application whose notification function is taken over by the reminder agent
3439
let representativeBundle: string = "com.example.demo";
E
esterzhou 已提交
3440
// User ID
3441
let userId: number = 100;
E
esterzhou 已提交
3442

E
ester.zhou 已提交
3443
notificationManager.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
E
esterzhou 已提交
3444 3445
```

E
ester.zhou 已提交
3446
## notificationManager.cancelAsBundle
E
esterzhou 已提交
3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469

cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>

Cancels a notification published by the reminder agent. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name              | Type  | Mandatory| Description              |
| -------------------- | ------ | ---- | ------------------ |
| id                   | number | Yes  | Notification ID.          |
| representativeBundle | string | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.|
| userId               | number | Yes  | User ID.|

**Error codes**

E
ester.zhou 已提交
3470 3471
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3472 3473 3474 3475 3476 3477 3478 3479 3480 3481
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3482
```ts
E
esterzhou 已提交
3483
// Bundle name of the application whose notification function is taken over by the reminder agent
3484
let representativeBundle: string = "com.example.demo";
E
esterzhou 已提交
3485
// User ID
3486
let userId: number = 100;
E
esterzhou 已提交
3487

E
ester.zhou 已提交
3488
notificationManager.cancelAsBundle(0, representativeBundle, userId).then(() => {
E
esterzhou 已提交
3489 3490 3491 3492
	console.info("cancelAsBundle success");
});
```

E
ester.zhou 已提交
3493
## notificationManager.setNotificationEnableSlot 
E
esterzhou 已提交
3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508

setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void

Sets whether to enable a specified notification slot type for a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
E
ester.zhou 已提交
3509
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.          |
E
esterzhou 已提交
3510
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
3511
| enable   | boolean                       | Yes  | Whether to enable notification.            |
E
esterzhou 已提交
3512 3513 3514 3515
| callback | AsyncCallback\<void\>         | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3516 3517
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3518 3519 3520 3521 3522 3523 3524 3525 3526
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
3527
```ts
E
esterzhou 已提交
3528
// setNotificationEnableSlot
3529
function setNotificationEnableSlotCallback(err: Base.BusinessError) {
E
esterzhou 已提交
3530
    if (err) {
E
ester.zhou 已提交
3531
        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3532 3533 3534 3535 3536
    } else {
        console.info("setNotificationEnableSlot success");
    }
};

E
ester.zhou 已提交
3537
notificationManager.setNotificationEnableSlot(
E
esterzhou 已提交
3538
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3539
    notificationManager.SlotType.SOCIAL_COMMUNICATION,
E
esterzhou 已提交
3540 3541 3542 3543
    true,
    setNotificationEnableSlotCallback);
```

E
ester.zhou 已提交
3544
## notificationManager.setNotificationEnableSlot
E
esterzhou 已提交
3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559

setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> 

Sets whether to enable a specified notification slot type for a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
E
ester.zhou 已提交
3560
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.  |
E
esterzhou 已提交
3561
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|
E
ester.zhou 已提交
3562
| enable | boolean                       | Yes  | Whether to enable notification.    |
E
esterzhou 已提交
3563 3564 3565

**Error codes**

E
ester.zhou 已提交
3566 3567
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3568 3569 3570 3571 3572 3573 3574 3575 3576
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
3577
```ts
E
esterzhou 已提交
3578
// setNotificationEnableSlot
E
ester.zhou 已提交
3579
notificationManager.setNotificationEnableSlot(
E
esterzhou 已提交
3580
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3581
    notificationManager.SlotType.SOCIAL_COMMUNICATION,
E
esterzhou 已提交
3582 3583 3584 3585 3586
    true).then(() => {
        console.info("setNotificationEnableSlot success");
    });
```

E
ester.zhou 已提交
3587
## notificationManager.isNotificationSlotEnabled
E
esterzhou 已提交
3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void

Checks whether a specified notification slot type is enabled for a specified application. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
E
ester.zhou 已提交
3603
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.          |
E
esterzhou 已提交
3604 3605 3606 3607 3608
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3609 3610
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3611 3612 3613 3614 3615 3616 3617 3618 3619
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
3620
```ts
E
esterzhou 已提交
3621
// isNotificationSlotEnabled
3622
function getEnableSlotCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
3623
    if (err) {
E
ester.zhou 已提交
3624
        console.error(`isNotificationSlotEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3625
    } else {
3626
        console.info(`isNotificationSlotEnabled success, data is ${JSON.stringify(data)}`);
E
esterzhou 已提交
3627 3628 3629
    }
};

E
ester.zhou 已提交
3630
notificationManager.isNotificationSlotEnabled(
E
esterzhou 已提交
3631
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3632
    notificationManager.SlotType.SOCIAL_COMMUNICATION,
E
esterzhou 已提交
3633 3634 3635
    getEnableSlotCallback);
```

E
ester.zhou 已提交
3636
## notificationManager.isNotificationSlotEnabled
E
esterzhou 已提交
3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>  

Checks whether a specified notification slot type is enabled for a specified application. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
E
ester.zhou 已提交
3652
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.  |
E
esterzhou 已提交
3653 3654 3655 3656 3657 3658 3659 3660 3661 3662
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
3663 3664
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3665 3666 3667 3668 3669 3670 3671 3672 3673
| ID| Error Message                                |
| -------- | ---------------------------------------- |
| 1600001  | Internal error.                          |
| 1600002  | Marshalling or unmarshalling error.      |
| 1600003  | Failed to connect service.               |
| 17700001 | The specified bundle name was not found. |

**Example**

E
ester.zhou 已提交
3674
```ts
E
esterzhou 已提交
3675
// isNotificationSlotEnabled
E
ester.zhou 已提交
3676
notificationManager.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
3677
    notificationManager.SlotType.SOCIAL_COMMUNICATION).then((data: boolean) => {
E
esterzhou 已提交
3678 3679 3680 3681 3682
    console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
3683
## notificationManager.setSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704

setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void

Sets 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.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
| enable | boolean | Yes  | Whether the feature is enabled.  |
| callback | AsyncCallback\<void\>    | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3705 3706
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3707 3708 3709 3710 3711 3712 3713 3714 3715
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3716
```ts
3717 3718
let userId: number = 100;
let enable: boolean = true;
E
esterzhou 已提交
3719

3720
function callback(err: Base.BusinessError) {
E
esterzhou 已提交
3721
    if (err) {
E
ester.zhou 已提交
3722
        console.error(`setSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3723 3724 3725 3726 3727
    } else {
        console.info("setSyncNotificationEnabledWithoutApp success");
    }
}

E
ester.zhou 已提交
3728
notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
E
esterzhou 已提交
3729 3730 3731
```


E
ester.zhou 已提交
3732
## notificationManager.setSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758

setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>

Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
| enable | boolean | Yes  | Whether the feature is enabled.  |

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
3759 3760
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3761 3762 3763 3764 3765 3766 3767 3768 3769
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3770
```ts
3771 3772
let userId: number = 100;
let enable: boolean = true;
E
esterzhou 已提交
3773

E
ester.zhou 已提交
3774
notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
E
esterzhou 已提交
3775 3776 3777 3778 3779
    console.info('setSyncNotificationEnabledWithoutApp success');
});
```


E
ester.zhou 已提交
3780
## notificationManager.getSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800

getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void

Obtains 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.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|

**Error codes**

E
ester.zhou 已提交
3801 3802
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3803 3804 3805 3806 3807 3808 3809 3810 3811
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3812
```ts
3813
let userId: number = 100;
E
esterzhou 已提交
3814

3815
function getSyncNotificationEnabledWithoutAppCallback(err: Base.BusinessError, data: boolean) {
E
esterzhou 已提交
3816 3817 3818 3819 3820 3821 3822
    if (err) {
        console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
    } else {
        console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
    }
}

E
ester.zhou 已提交
3823
notificationManager.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
E
esterzhou 已提交
3824 3825 3826
```


E
ester.zhou 已提交
3827
## notificationManager.getSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852

getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>

Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses a promise to return the result.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |

**Return value**

| Type              | Description                                                        |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|

**Error codes**

E
ester.zhou 已提交
3853 3854
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3855 3856 3857 3858 3859 3860 3861 3862 3863
| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3864
```ts
3865 3866 3867
let userId: number = 100;

notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data: boolean) => {
E
esterzhou 已提交
3868 3869 3870 3871
    console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
});
```

E
ester.zhou 已提交
3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909
## notificationManager.on<sup>10+</sup>

on(type: 'checkNotification', callback: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;

Subscribes 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.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| type | string | Yes  | Event type. The value is fixed to **'checkNotification'**.|
| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  [NotificationCheckResult](#notificationcheckresult10)    | Yes  | Pointer to the notification verification function.|

**Error codes**

For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |

**Example**

```ts
try{
    notificationManager.on("checkNotification", OnCheckNotification);
} catch (error){
    console.info(`notificationManager.on error: ${JSON.stringify(error)}`);
}
function OnCheckNotification(info : notificationManager.NotificationCheckInfo) {
    console.info(`====>OnCheckNotification info: ${JSON.stringify(info)}`);
    if(info.notificationId == 1){
3910 3911
        let result: notificationManager.NotificationCheckResult =  { code: 1, message: "testMsg1"};
        return result;
E
ester.zhou 已提交
3912
    } else {
3913 3914
        let result: notificationManager.NotificationCheckResult =   { code: 0, message: "testMsg0"};
        return result;
E
ester.zhou 已提交
3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954
    }
}
```

## notificationManager.off<sup>10+</sup>

off(type: 'checkNotification', callback?: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;

Unsubscribes from notification events.

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| type | string                                                       | Yes  | Event type. The value is fixed to **'checkNotification'**.|
| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo10)) =>  [NotificationCheckResult](#notificationcheckresult10)  | No  | Pointer to the notification verification function.|

**Error codes**

For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

| ID| Error Message                           |
| -------- | ----------------------------------- |
| 1600001  | Internal error.                     |

**Example**

```ts
try{
    notificationManager.off("checkNotification");
} catch (error){
    console.info(`notificationManager.off error: ${JSON.stringify(error)}`);
}
```
E
esterzhou 已提交
3955 3956 3957 3958 3959 3960 3961

## DoNotDisturbDate

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3962 3963 3964 3965 3966
| Name | Type                                 | Mandatory| Description                  |
| ----- | ------------------------------------- | ---- | ---------------------- |
| type  | [DoNotDisturbType](#donotdisturbtype) | Yes  | DND time type.|
| begin | Date                                  | Yes  | DND start time.|
| end   | Date                                  | Yes  | DND end time.|
E
esterzhou 已提交
3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986

## DoNotDisturbType

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
| TYPE_NONE    | 0 | Non-DND.                          |
| TYPE_ONCE    | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
| TYPE_DAILY   | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute).    |


## ContentType

**System capability**: SystemCapability.Notification.Notification

| Name                             | Value         | Description              |
E
ester.zhou 已提交
3987 3988 3989 3990 3991 3992
| --------------------------------- | ----------- |------------------|
| NOTIFICATION_CONTENT_BASIC_TEXT   | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification.         |
| NOTIFICATION_CONTENT_LONG_TEXT    | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification.        |
| NOTIFICATION_CONTENT_PICTURE      | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification.         |
| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification (not supported currently).|
| NOTIFICATION_CONTENT_MULTILINE    | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.       |
E
esterzhou 已提交
3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046

## SlotLevel

**System capability**: SystemCapability.Notification.Notification

| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE                        | 0           | Notification is disabled.    |
| LEVEL_MIN                         | 1           | Notification is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
| LEVEL_LOW                         | 2           | Notification is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
| LEVEL_DEFAULT                     | 3           | Notification is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.|
| LEVEL_HIGH                        | 4           | Notification is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.|


## SlotType

**System capability**: SystemCapability.Notification.Notification

| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
| UNKNOWN_TYPE         | 0 | Unknown type.|
| SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.|
| SERVICE_INFORMATION  | 2 | Notification slot for service information.|
| CONTENT_INFORMATION  | 3 | Notification slot for content consultation.|
| OTHER_TYPES          | 0xFFFF | Notification slot for other purposes.|




## DeviceRemindType

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

| Name                | Value | Description                              |
| -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND    | 0   | The device is not in use. No notification is required.           |
| IDLE_REMIND          | 1   | The device is not in use.                |
| ACTIVE_DONOT_REMIND  | 2   | The device is in use. No notification is required.           |
| ACTIVE_REMIND        | 3   | The device is in use.                |


## SourceType

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

| Name                | Value | Description                 |
| -------------------- | --- | -------------------- |
| TYPE_NORMAL          | 0   | Normal notification.           |
| TYPE_CONTINUOUS      | 1   | Continuous notification.           |
| TYPE_TIMER           | 2   | Timed notification.           |
E
ester.zhou 已提交
4047 4048 4049 4050 4051 4052 4053 4054 4055

## NotificationCheckInfo<sup>10+</sup>

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
4056 4057 4058 4059 4060
| Name | Type                                 | Mandatory| Description                  |
| ----- | ------------------------------------- | --- | ---------------------- |
| bundleName  | string                          | Yes  | Bundle name.|
| notificationId | number                       | Yes  | Notification ID.    |
| contentType   | [ContentType](#contenttype)   | Yes  | Notification type.  |
E
ester.zhou 已提交
4061 4062 4063 4064 4065 4066 4067 4068 4069

## NotificationCheckResult<sup>10+</sup>

**System capability**: SystemCapability.Notification.Notification

**System API**: This is a system API and cannot be called by third-party applications.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
4070 4071 4072 4073
| Name   | Type                                 | Mandatory| Description                  |
| ------- | ------------------------------------ | ---- | ---------------------- |
| code    | number                               | Yes  | Result code.<br>**0**: display.<br>**1**: no display.|
| message | string                               | Yes  | Result.   |