js-apis-notificationManager.md 149.4 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';
E
esterzhou 已提交
13 14
```

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

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 已提交
27
| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
28 29 30 31
| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                       |

**Error codes**

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

E
esterzhou 已提交
34 35
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
E
ester.zhou 已提交
36
| 401      | The parameter check failed.               |
E
esterzhou 已提交
37 38 39 40 41 42
| 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 49 50
// publish callback
function publishCallback(err) {
    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
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
E
ester.zhou 已提交
91 92
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
93 94 95 96 97 98
| 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 已提交
99
| 1600012  | No memory space.                          |
E
esterzhou 已提交
100 101 102

**Example**

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

```

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

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 已提交
138
| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
139 140 141 142 143
| userId   | number                                      | Yes  | User ID.                          |
| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |

**Error codes**

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

E
esterzhou 已提交
146 147
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
E
ester.zhou 已提交
148 149
| 202      | Not system application to call the interface.   |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
150 151 152 153 154 155 156
| 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 已提交
157
| 1600012  | No memory space.                          |
E
esterzhou 已提交
158 159 160

**Example**

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

E
ester.zhou 已提交
187
## notificationManager.publish
E
esterzhou 已提交
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202

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 已提交
203
| request  | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
204 205 206 207
| userId   | number                                      | Yes  | User ID.                          |

**Error codes**

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

E
esterzhou 已提交
210 211
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
E
ester.zhou 已提交
212 213
| 201      | Permission denied.                        |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
214 215 216 217 218 219 220
| 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 已提交
221
| 1600012  | No memory space.                          |
E
esterzhou 已提交
222 223 224

**Example**

E
ester.zhou 已提交
225
```ts
E
ester.zhou 已提交
226
let notificationRequest: notificationManager.NotificationRequest = {
E
esterzhou 已提交
227 228
    notificationId: 1,
    content: {
E
ester.zhou 已提交
229
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
230 231 232 233 234 235
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
236
};
E
esterzhou 已提交
237

E
ester.zhou 已提交
238
let userId = 1;
E
esterzhou 已提交
239

E
ester.zhou 已提交
240
notificationManager.publish(notificationRequest, userId).then(() => {
E
esterzhou 已提交
241 242 243 244 245
	console.info("publish success");
});
```


E
ester.zhou 已提交
246
## notificationManager.cancel
E
esterzhou 已提交
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263

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 已提交
264 265
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
266 267
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
268
| 401      | The parameter check failed.         |
E
esterzhou 已提交
269 270 271 272 273 274 275
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |

**Example**

E
ester.zhou 已提交
276
```ts
E
esterzhou 已提交
277 278 279
// cancel callback
function cancelCallback(err) {
    if (err) {
E
ester.zhou 已提交
280
        console.error(`cancel failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
281 282 283 284
    } else {
        console.info("cancel success");
    }
}
E
ester.zhou 已提交
285
notificationManager.cancel(0, "label", cancelCallback);
E
esterzhou 已提交
286 287
```

E
ester.zhou 已提交
288
## notificationManager.cancel
E
esterzhou 已提交
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304

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 已提交
305 306
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
307 308
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
309
| 401      | The parameter check failed.         |
E
esterzhou 已提交
310 311 312 313 314 315 316
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |

**Example**

E
ester.zhou 已提交
317 318
```ts
notificationManager.cancel(0).then(() => {
E
esterzhou 已提交
319 320 321 322
	console.info("cancel success");
});
```

E
ester.zhou 已提交
323
## notificationManager.cancel
E
esterzhou 已提交
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339

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 已提交
340 341
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
342 343
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
344
| 401      | The parameter check failed.         |
E
esterzhou 已提交
345 346 347 348 349 350 351
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600007  | The notification is not exist.      |

**Example**

E
ester.zhou 已提交
352
```ts
E
esterzhou 已提交
353 354 355
// cancel callback
function cancelCallback(err) {
    if (err) {
E
ester.zhou 已提交
356
        console.error(`cancel failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
357 358 359 360
    } else {
        console.info("cancel success");
    }
}
E
ester.zhou 已提交
361
notificationManager.cancel(0, cancelCallback);
E
esterzhou 已提交
362 363
```

E
ester.zhou 已提交
364
## notificationManager.cancelAll
E
esterzhou 已提交
365 366 367 368 369 370 371 372 373

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 已提交
374 375
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
376 377
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
378
| 401      | The parameter check failed.         |
E
esterzhou 已提交
379 380 381 382 383 384 385 386 387 388 389 390
| 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 已提交
391
```ts
E
esterzhou 已提交
392 393 394
// cancel callback
function cancelAllCallback(err) {
    if (err) {
E
ester.zhou 已提交
395
        console.error(`cancelAll failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
396 397 398 399
    } else {
        console.info("cancelAll success");
    }
}
E
ester.zhou 已提交
400
notificationManager.cancelAll(cancelAllCallback);
E
esterzhou 已提交
401 402
```

E
ester.zhou 已提交
403
## notificationManager.cancelAll
E
esterzhou 已提交
404 405 406 407 408 409 410 411 412

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 已提交
413 414
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
415 416
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
417
| 401      | The parameter check failed.         |
E
esterzhou 已提交
418 419 420 421 422 423
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
424 425
```ts
notificationManager.cancelAll().then(() => {
E
esterzhou 已提交
426 427 428 429
	console.info("cancelAll success");
});
```

E
ester.zhou 已提交
430
## notificationManager.addSlot
E
esterzhou 已提交
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445

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 已提交
446
| slot     | [NotificationSlot](js-apis-inner-notification-notificationSlot.md)       | Yes  | Notification slot to add.|
E
esterzhou 已提交
447 448 449 450
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
453 454
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
455 456 457
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
458 459 460
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
461
| 1600012  | No memory space.                          |
E
esterzhou 已提交
462 463 464

**Example**

E
ester.zhou 已提交
465
```ts
E
esterzhou 已提交
466 467 468
// addSlot callback
function addSlotCallBack(err) {
    if (err) {
E
ester.zhou 已提交
469
        console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
470 471 472 473 474
    } else {
        console.info("addSlot success");
    }
}
// NotificationSlot object
E
ester.zhou 已提交
475 476 477 478
let notificationSlot = {
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
notificationManager.addSlot(notificationSlot, addSlotCallBack);
E
esterzhou 已提交
479 480
```

E
ester.zhou 已提交
481
## notificationManager.addSlot
E
esterzhou 已提交
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496

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 已提交
497
| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes  | Notification slot to add.|
E
esterzhou 已提交
498 499 500

**Error codes**

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

E
esterzhou 已提交
503 504
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
505 506 507
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
508 509 510
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
511
| 1600012  | No memory space.                          |
E
esterzhou 已提交
512 513 514

**Example**

E
ester.zhou 已提交
515
```ts
E
esterzhou 已提交
516
// NotificationSlot object
E
ester.zhou 已提交
517 518 519 520
let notificationSlot = {
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
notificationManager.addSlot(notificationSlot).then(() => {
E
esterzhou 已提交
521 522 523 524
	console.info("addSlot success");
});
```

E
ester.zhou 已提交
525
## notificationManager.addSlot
E
esterzhou 已提交
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541

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 已提交
542 543
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
544 545
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
546
| 401      | The parameter check failed.         |
E
esterzhou 已提交
547 548 549
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
550
| 1600012  | No memory space.                    |
E
esterzhou 已提交
551 552 553

**Example**

E
ester.zhou 已提交
554
```ts
E
esterzhou 已提交
555 556 557
// addSlot callback
function addSlotCallBack(err) {
    if (err) {
E
ester.zhou 已提交
558
        console.error(`addSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
559 560 561 562
    } else {
        console.info("addSlot success");
    }
}
E
ester.zhou 已提交
563
notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
E
esterzhou 已提交
564 565
```

E
ester.zhou 已提交
566
## notificationManager.addSlot
E
esterzhou 已提交
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581

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 已提交
582 583
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
584 585
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
586
| 401      | The parameter check failed.         |
E
esterzhou 已提交
587 588 589
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
590
| 1600012  | No memory space.                    |
E
esterzhou 已提交
591 592 593

**Example**

E
ester.zhou 已提交
594 595
```ts
notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {
E
esterzhou 已提交
596 597 598 599
	console.info("addSlot success");
});
```

E
ester.zhou 已提交
600
## notificationManager.addSlots
E
esterzhou 已提交
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615

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 已提交
616
| slots    | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes  | Notification slots to add.|
E
esterzhou 已提交
617 618 619 620
| callback | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |

**Error codes**

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

E
esterzhou 已提交
623 624
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
625 626 627
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
628 629 630
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
631
| 1600012  | No memory space.                          |
E
esterzhou 已提交
632 633 634

**Example**

E
ester.zhou 已提交
635
```ts
E
esterzhou 已提交
636 637 638
// addSlots callback
function addSlotsCallBack(err) {
    if (err) {
E
ester.zhou 已提交
639
        console.error(`addSlots failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
640 641 642 643 644
    } else {
        console.info("addSlots success");
    }
}
// NotificationSlot object
E
ester.zhou 已提交
645 646 647
let notificationSlot = {
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
E
esterzhou 已提交
648
// NotificationSlotArray object
E
ester.zhou 已提交
649
let notificationSlotArray = new Array();
E
esterzhou 已提交
650 651
notificationSlotArray[0] = notificationSlot;

E
ester.zhou 已提交
652
notificationManager.addSlots(notificationSlotArray, addSlotsCallBack);
E
esterzhou 已提交
653 654
```

E
ester.zhou 已提交
655
## notificationManager.addSlots
E
esterzhou 已提交
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670

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 已提交
671
| slots | Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes  | Notification slots to add.|
E
esterzhou 已提交
672 673 674

**Error codes**

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

E
esterzhou 已提交
677 678
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
679 680 681
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
682 683 684
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
685
| 1600012  | No memory space.                          |
E
esterzhou 已提交
686 687 688

**Example**

E
ester.zhou 已提交
689
```ts
E
esterzhou 已提交
690
// NotificationSlot object
E
ester.zhou 已提交
691 692 693
let notificationSlot = {
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
E
esterzhou 已提交
694
// NotificationSlotArray object
E
ester.zhou 已提交
695
let notificationSlotArray = new Array();
E
esterzhou 已提交
696 697
notificationSlotArray[0] = notificationSlot;

E
ester.zhou 已提交
698
notificationManager.addSlots(notificationSlotArray).then(() => {
E
esterzhou 已提交
699 700 701 702
	console.info("addSlots success");
});
```

E
ester.zhou 已提交
703
## notificationManager.getSlot
E
esterzhou 已提交
704 705 706 707 708 709 710 711 712 713 714 715

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 已提交
716
| callback | AsyncCallback\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\> | Yes  | Callback used to return the result.                                       |
E
esterzhou 已提交
717 718 719

**Error codes**

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

E
esterzhou 已提交
722 723
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
724
| 401      | The parameter check failed.         |
E
esterzhou 已提交
725 726 727 728 729 730
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
731
```ts
E
esterzhou 已提交
732 733 734
// getSlot callback
function getSlotCallback(err,data) {
    if (err) {
E
ester.zhou 已提交
735
        console.error(`getSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
736 737 738 739
    } else {
        console.info("getSlot success");
    }
}
E
ester.zhou 已提交
740 741
let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
notificationManager.getSlot(slotType, getSlotCallback);
E
esterzhou 已提交
742 743
```

E
ester.zhou 已提交
744
## notificationManager.getSlot
E
esterzhou 已提交
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765

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 已提交
766 767
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
768 769
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
770
| 401      | The parameter check failed.         |
E
esterzhou 已提交
771 772 773 774 775 776
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
777 778 779
```ts
let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
notificationManager.getSlot(slotType).then((data) => {
E
esterzhou 已提交
780 781 782 783
	console.info("getSlot success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
784
## notificationManager.getSlots
E
esterzhou 已提交
785 786 787 788 789 790 791 792 793

getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void

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 已提交
794 795
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
796 797
| Name    | Type                             | Mandatory| Description                |
| -------- | --------------------------------- | ---- | -------------------- |
E
ester.zhou 已提交
798
| callback | AsyncCallback\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | Yes  | Callback used to return all notification slots of the current application.|
E
esterzhou 已提交
799 800 801 802 803

**Error codes**

| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
804
| 401      | The parameter check failed.         |
E
esterzhou 已提交
805 806 807 808 809 810
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
811
```ts
E
esterzhou 已提交
812 813 814
// getSlots callback
function getSlotsCallback(err,data) {
    if (err) {
E
ester.zhou 已提交
815
        console.error(`getSlots failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
816 817 818 819
    } else {
        console.info("getSlots success");
    }
}
E
ester.zhou 已提交
820
notificationManager.getSlots(getSlotsCallback);
E
esterzhou 已提交
821 822
```

E
ester.zhou 已提交
823
## notificationManager.getSlots
E
esterzhou 已提交
824 825 826 827 828 829 830 831 832 833 834

getSlots(): Promise\<Array\<NotificationSlot\>>

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 已提交
835
| Promise\<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>\> | Promise used to return all notification slots of the current application.|
E
esterzhou 已提交
836 837 838

**Error codes**

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

E
esterzhou 已提交
841 842
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
843
| 401      | The parameter check failed.         |
E
esterzhou 已提交
844 845 846 847 848 849
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
850 851
```ts
notificationManager.getSlots().then((data) => {
E
esterzhou 已提交
852 853 854 855
	console.info("getSlots success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
856
## notificationManager.removeSlot
E
esterzhou 已提交
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872

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 已提交
873 874
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
875 876
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
877
| 401      | The parameter check failed.         |
E
esterzhou 已提交
878 879 880 881 882 883
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
884
```ts
E
esterzhou 已提交
885 886 887
// removeSlot callback
function removeSlotCallback(err) {
    if (err) {
E
ester.zhou 已提交
888
        console.error(`removeSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
889 890 891 892
    } else {
        console.info("removeSlot success");
    }
}
E
ester.zhou 已提交
893 894
let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
notificationManager.removeSlot(slotType,removeSlotCallback);
E
esterzhou 已提交
895 896
```

E
ester.zhou 已提交
897
## notificationManager.removeSlot
E
esterzhou 已提交
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912

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 已提交
913 914
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
915 916
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
917
| 401      | The parameter check failed.         |
E
esterzhou 已提交
918 919 920 921 922 923
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
924 925 926
```ts
let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
notificationManager.removeSlot(slotType).then(() => {
E
esterzhou 已提交
927 928 929 930
	console.info("removeSlot success");
});
```

E
ester.zhou 已提交
931
## notificationManager.removeAllSlots
E
esterzhou 已提交
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946

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 已提交
947 948
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
949 950
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
951
| 401      | The parameter check failed.         |
E
esterzhou 已提交
952 953 954 955 956 957
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
958
```ts
E
esterzhou 已提交
959 960
function removeAllCallBack(err) {
    if (err) {
E
ester.zhou 已提交
961
        console.error(`removeAllSlots failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
962 963 964 965
    } else {
        console.info("removeAllSlots success");
    }
}
E
ester.zhou 已提交
966
notificationManager.removeAllSlots(removeAllCallBack);
E
esterzhou 已提交
967 968
```

E
ester.zhou 已提交
969
## notificationManager.removeAllSlots
E
esterzhou 已提交
970 971 972 973 974 975 976 977 978

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 已提交
979 980
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
981 982
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
983
| 401      | The parameter check failed.         |
E
esterzhou 已提交
984 985 986 987 988 989
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
990 991
```ts
notificationManager.removeAllSlots().then(() => {
E
esterzhou 已提交
992 993 994 995
	console.info("removeAllSlots success");
});
```

E
ester.zhou 已提交
996
## notificationManager.setNotificationEnable
E
esterzhou 已提交
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011

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 已提交
1012
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)   | Yes  | Bundle of the application.       |
E
esterzhou 已提交
1013 1014 1015 1016 1017
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
1020 1021
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1022 1023 1024
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1025 1026 1027 1028 1029 1030 1031
| 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 已提交
1032
```ts
E
esterzhou 已提交
1033 1034
function setNotificationEnablenCallback(err) {
    if (err) {
E
ester.zhou 已提交
1035
        console.error(`setNotificationEnablenCallback failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1036 1037 1038 1039
    } else {
        console.info("setNotificationEnablenCallback success");
    }
}
E
ester.zhou 已提交
1040
let bundle = {
E
esterzhou 已提交
1041
    bundle: "bundleName1",
E
ester.zhou 已提交
1042 1043
};
notificationManager.setNotificationEnable(bundle, false, setNotificationEnablenCallback);
E
esterzhou 已提交
1044 1045
```

E
ester.zhou 已提交
1046
## notificationManager.setNotificationEnable
E
esterzhou 已提交
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061

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 已提交
1062
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1063 1064 1065 1066
| enable | boolean      | Yes  | Whether to enable notification.  |

**Error codes**

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

E
esterzhou 已提交
1069 1070
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1071 1072 1073
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1074 1075 1076 1077 1078 1079 1080
| 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 已提交
1081 1082
```ts
let bundle = {
E
esterzhou 已提交
1083
    bundle: "bundleName1",
E
ester.zhou 已提交
1084 1085
};
notificationManager.setNotificationEnable(bundle, false).then(() => {
E
esterzhou 已提交
1086 1087 1088 1089
	console.info("setNotificationEnable success");
});
```

E
ester.zhou 已提交
1090
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105

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 已提交
1106
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle of the application.           |
E
esterzhou 已提交
1107 1108 1109 1110
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
1113 1114
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1115 1116 1117
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1118 1119 1120 1121 1122 1123 1124
| 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 已提交
1125
```ts
E
esterzhou 已提交
1126 1127
function isNotificationEnabledCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
1128
        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1129 1130 1131 1132
    } else {
        console.info("isNotificationEnabled success");
    }
}
E
ester.zhou 已提交
1133
let bundle = {
E
esterzhou 已提交
1134
    bundle: "bundleName1",
E
ester.zhou 已提交
1135 1136
};
notificationManager.isNotificationEnabled(bundle, isNotificationEnabledCallback);
E
esterzhou 已提交
1137 1138
```

E
ester.zhou 已提交
1139
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154

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 已提交
1155
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1156 1157 1158 1159 1160 1161 1162 1163 1164

**Return value**

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

**Error codes**

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

E
esterzhou 已提交
1167 1168
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1169 1170 1171
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1172 1173 1174 1175 1176 1177 1178
| 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 已提交
1179 1180
```ts
let bundle = {
E
esterzhou 已提交
1181
    bundle: "bundleName1",
E
ester.zhou 已提交
1182 1183
};
notificationManager.isNotificationEnabled(bundle).then((data) => {
E
esterzhou 已提交
1184 1185 1186 1187
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1188
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207

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                    |
| -------- | --------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
1210 1211
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
1212 1213 1214
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1215 1216 1217 1218 1219 1220
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1221
```ts
E
esterzhou 已提交
1222 1223
function isNotificationEnabledCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
1224
        console.error(`isNotificationEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1225 1226 1227 1228 1229
    } else {
        console.info("isNotificationEnabled success");
    }
}

E
ester.zhou 已提交
1230
notificationManager.isNotificationEnabled(isNotificationEnabledCallback);
E
esterzhou 已提交
1231 1232
```

E
ester.zhou 已提交
1233
## notificationManager.isNotificationEnabled
E
esterzhou 已提交
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248

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.

**Parameters**

| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
ester.zhou 已提交
1249
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1250 1251 1252 1253 1254 1255 1256 1257 1258

**Return value**

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

**Error codes**

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

E
esterzhou 已提交
1261 1262
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1263 1264 1265
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1266 1267 1268 1269 1270 1271 1272
| 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 已提交
1273 1274
```ts
notificationManager.isNotificationEnabled().then((data) => {
E
esterzhou 已提交
1275 1276 1277 1278
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1279
## notificationManager.displayBadge
E
esterzhou 已提交
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294

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 已提交
1295
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle of the application.          |
E
esterzhou 已提交
1296 1297 1298 1299 1300
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
1303 1304
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1305 1306 1307
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1308 1309 1310 1311 1312 1313 1314
| 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 已提交
1315
```ts
E
esterzhou 已提交
1316 1317
function displayBadgeCallback(err) {
    if (err) {
E
ester.zhou 已提交
1318
        console.error(`displayBadge failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1319 1320 1321 1322
    } else {
        console.info("displayBadge success");
    }
}
E
ester.zhou 已提交
1323
let bundle = {
E
esterzhou 已提交
1324
    bundle: "bundleName1",
E
ester.zhou 已提交
1325 1326
};
notificationManager.displayBadge(bundle, false, displayBadgeCallback);
E
esterzhou 已提交
1327 1328
```

E
ester.zhou 已提交
1329
## notificationManager.displayBadge
E
esterzhou 已提交
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344

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 已提交
1345
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1346 1347 1348 1349
| enable | boolean      | Yes  | Whether to enable notification.  |

**Error codes**

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

E
esterzhou 已提交
1352 1353
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1354 1355 1356
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1357 1358 1359 1360 1361 1362 1363
| 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 已提交
1364 1365
```ts
let bundle = {
E
esterzhou 已提交
1366
    bundle: "bundleName1",
E
ester.zhou 已提交
1367 1368
};
notificationManager.displayBadge(bundle, false).then(() => {
E
esterzhou 已提交
1369 1370 1371 1372
	console.info("displayBadge success");
});
```

E
ester.zhou 已提交
1373
## notificationManager.isBadgeDisplayed
E
esterzhou 已提交
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388

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 已提交
1389
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)          | Yes  | Bundle of the application.              |
E
esterzhou 已提交
1390 1391 1392 1393
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
1396 1397
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1398 1399 1400
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1401 1402 1403 1404 1405 1406 1407
| 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 已提交
1408
```ts
E
esterzhou 已提交
1409 1410
function isBadgeDisplayedCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
1411
        console.error(`isBadgeDisplayed failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1412 1413 1414 1415
    } else {
        console.info("isBadgeDisplayed success");
    }
}
E
ester.zhou 已提交
1416
let bundle = {
E
esterzhou 已提交
1417
    bundle: "bundleName1",
E
ester.zhou 已提交
1418 1419
};
notificationManager.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
E
esterzhou 已提交
1420 1421
```

E
ester.zhou 已提交
1422
## notificationManager.isBadgeDisplayed
E
esterzhou 已提交
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437

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 已提交
1438
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1439 1440 1441 1442 1443 1444 1445 1446 1447

**Return value**

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

**Error codes**

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

E
esterzhou 已提交
1450 1451
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1452 1453 1454
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1455 1456 1457 1458 1459 1460 1461
| 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 已提交
1462 1463
```ts
let bundle = {
E
esterzhou 已提交
1464
    bundle: "bundleName1",
E
ester.zhou 已提交
1465 1466
};
notificationManager.isBadgeDisplayed(bundle).then((data) => {
E
esterzhou 已提交
1467 1468 1469 1470
	console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
## 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                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
1489
| 401      | The parameter check failed.               |
E
ester.zhou 已提交
1490 1491 1492
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
1493
| 1600012  | No memory space.                          |
E
ester.zhou 已提交
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524

**Example**

```ts
let badgeNumber = 10
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                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
1525
| 401      | The parameter check failed.               |
E
ester.zhou 已提交
1526 1527 1528
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
1529
| 1600012  | No memory space.                          |
E
ester.zhou 已提交
1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545

**Example**

```ts
function setBadgeNumberCallback(err) {
    if (err) {
        console.info(`displayBadge failed code is ${err.code}, message is ${err.message}`);
    } else {
        console.info("displayBadge success");
    }
}

let badgeNumber = 10
notificationManager.setBadgeNumber(badgeNumber, setBadgeNumberCallback);
```

E
ester.zhou 已提交
1546
## notificationManager.setSlotByBundle
E
esterzhou 已提交
1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561

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 已提交
1562 1563
| 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 已提交
1564 1565 1566 1567
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
1570 1571
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1572 1573 1574
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1575 1576 1577 1578 1579 1580 1581
| 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 已提交
1582
```ts
E
esterzhou 已提交
1583 1584
function setSlotByBundleCallback(err) {
    if (err) {
E
ester.zhou 已提交
1585
        console.error(`setSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1586 1587 1588 1589
    } else {
        console.info("setSlotByBundle success");
    }
}
E
ester.zhou 已提交
1590
let bundle = {
E
esterzhou 已提交
1591
    bundle: "bundleName1",
E
ester.zhou 已提交
1592 1593 1594 1595 1596
};
let notificationSlot = {
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
notificationManager.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
E
esterzhou 已提交
1597 1598
```

E
ester.zhou 已提交
1599
## notificationManager.setSlotByBundle
E
esterzhou 已提交
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614

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 已提交
1615 1616
| 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 已提交
1617 1618 1619

**Error codes**

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

E
esterzhou 已提交
1622 1623
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1624 1625 1626
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1627 1628 1629 1630 1631 1632 1633
| 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 已提交
1634 1635
```ts
let bundle = {
E
esterzhou 已提交
1636
    bundle: "bundleName1",
E
ester.zhou 已提交
1637 1638 1639 1640 1641
};
let notificationSlot = {
    type: notificationManager.SlotType.SOCIAL_COMMUNICATION
};
notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => {
E
esterzhou 已提交
1642 1643 1644 1645
	console.info("setSlotByBundle success");
});
```

E
ester.zhou 已提交
1646
## notificationManager.getSlotsByBundle
E
esterzhou 已提交
1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661

getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void

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 已提交
1662 1663
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)                             | Yes  | Bundle of the application.          |
| callback | AsyncCallback<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
1664 1665 1666

**Error codes**

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

E
esterzhou 已提交
1669 1670
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1671 1672 1673
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1674 1675 1676 1677 1678 1679 1680
| 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 已提交
1681
```ts
E
esterzhou 已提交
1682 1683
function getSlotsByBundleCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
1684
        console.error(`getSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1685 1686 1687 1688
    } else {
        console.info("getSlotsByBundle success");
    }
}
E
ester.zhou 已提交
1689
let bundle = {
E
esterzhou 已提交
1690
    bundle: "bundleName1",
E
ester.zhou 已提交
1691 1692
};
notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback);
E
esterzhou 已提交
1693 1694
```

E
ester.zhou 已提交
1695
## notificationManager.getSlotsByBundle
E
esterzhou 已提交
1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710

getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>

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 已提交
1711
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1712 1713 1714 1715 1716

**Return value**

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

**Error codes**

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

E
esterzhou 已提交
1723 1724
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1725 1726 1727
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1728 1729 1730 1731 1732 1733 1734
| 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 已提交
1735 1736
```ts
let bundle = {
E
esterzhou 已提交
1737
    bundle: "bundleName1",
E
ester.zhou 已提交
1738 1739
};
notificationManager.getSlotsByBundle(bundle).then((data) => {
E
esterzhou 已提交
1740 1741 1742 1743
	console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1744
## notificationManager.getSlotNumByBundle
E
esterzhou 已提交
1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759

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 已提交
1760
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)              | Yes  | Bundle of the application.            |
E
esterzhou 已提交
1761 1762 1763 1764
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
1767 1768
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1769 1770 1771
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1772 1773 1774 1775 1776 1777 1778
| 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 已提交
1779
```ts
E
esterzhou 已提交
1780 1781
function getSlotNumByBundleCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
1782
        console.error(`getSlotByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1783 1784 1785 1786
    } else {
        console.info("getSlotNumByBundle success");
    }
}
E
ester.zhou 已提交
1787
let bundle = {
E
esterzhou 已提交
1788
    bundle: "bundleName1",
E
ester.zhou 已提交
1789 1790
};
notificationManager.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
E
esterzhou 已提交
1791 1792
```

E
ester.zhou 已提交
1793
## notificationManager.getSlotNumByBundle
E
esterzhou 已提交
1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808

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 已提交
1809
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle of the application.|
E
esterzhou 已提交
1810 1811 1812 1813 1814 1815 1816 1817 1818

**Return value**

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

**Error codes**

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

E
esterzhou 已提交
1821 1822
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
1823 1824 1825
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1826 1827 1828 1829 1830 1831 1832
| 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 已提交
1833 1834
```ts
let bundle = {
E
esterzhou 已提交
1835
    bundle: "bundleName1",
E
ester.zhou 已提交
1836 1837
};
notificationManager.getSlotNumByBundle(bundle).then((data) => {
E
esterzhou 已提交
1838 1839 1840 1841 1842
	console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
1843
## notificationManager.getAllActiveNotifications
E
esterzhou 已提交
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858

getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void

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 已提交
1859
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
1860 1861 1862 1863 1864

**Error codes**

| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
1865 1866 1867
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1868 1869 1870 1871 1872 1873
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1874
```ts
E
esterzhou 已提交
1875 1876
function getAllActiveNotificationsCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
1877
        console.error(`getAllActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1878 1879 1880 1881 1882
    } else {
        console.info("getAllActiveNotifications success");
    }
}

E
ester.zhou 已提交
1883
notificationManager.getAllActiveNotifications(getAllActiveNotificationsCallback);
E
esterzhou 已提交
1884 1885
```

E
ester.zhou 已提交
1886
## notificationManager.getAllActiveNotifications
E
esterzhou 已提交
1887

E
ester.zhou 已提交
1888
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\>
E
esterzhou 已提交
1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901

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 已提交
1902
| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | Promise used to return the result.|
E
esterzhou 已提交
1903 1904 1905

**Error codes**

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

E
esterzhou 已提交
1908 1909
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
1910 1911 1912
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
1913 1914 1915 1916 1917 1918
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1919 1920
```ts
notificationManager.getAllActiveNotifications().then((data) => {
E
esterzhou 已提交
1921 1922 1923 1924
	console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1925
## notificationManager.getActiveNotificationCount
E
esterzhou 已提交
1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940

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 已提交
1941 1942
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1943 1944
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
1945
| 401      | The parameter check failed.         |
E
esterzhou 已提交
1946 1947 1948 1949 1950 1951
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1952
```ts
E
esterzhou 已提交
1953 1954
function getActiveNotificationCountCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
1955
        console.error(`getActiveNotificationCount failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
1956 1957 1958 1959 1960
    } else {
        console.info("getActiveNotificationCount success");
    }
}

E
ester.zhou 已提交
1961
notificationManager.getActiveNotificationCount(getActiveNotificationCountCallback);
E
esterzhou 已提交
1962 1963
```

E
ester.zhou 已提交
1964
## notificationManager.getActiveNotificationCount
E
esterzhou 已提交
1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979

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 已提交
1980 1981
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
1982 1983
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
1984
| 401      | The parameter check failed.         |
E
esterzhou 已提交
1985 1986 1987 1988 1989 1990
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
1991 1992
```ts
notificationManager.getActiveNotificationCount().then((data) => {
E
esterzhou 已提交
1993 1994 1995 1996
	console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
1997
## notificationManager.getActiveNotifications
E
esterzhou 已提交
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008

getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void

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 已提交
2009
| callback | AsyncCallback<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>> | Yes  | Callback used to return the result.|
E
esterzhou 已提交
2010 2011 2012

**Error codes**

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

E
esterzhou 已提交
2015 2016
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2017
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2018 2019 2020 2021 2022 2023
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2024
```ts
E
esterzhou 已提交
2025 2026
function getActiveNotificationsCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
2027
        console.error(`getActiveNotifications failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2028 2029 2030 2031 2032
    } else {
        console.info("getActiveNotifications success");
    }
}

E
ester.zhou 已提交
2033
notificationManager.getActiveNotifications(getActiveNotificationsCallback);
E
esterzhou 已提交
2034 2035
```

E
ester.zhou 已提交
2036
## notificationManager.getActiveNotifications
E
esterzhou 已提交
2037

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

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 已提交
2048
| Promise\<Array\<[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)\>\> | Promise used to return the result.|
E
esterzhou 已提交
2049 2050 2051

**Error codes**

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

E
esterzhou 已提交
2054 2055
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2056
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2057 2058 2059 2060 2061 2062
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

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

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

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 已提交
2081
| 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 已提交
2082 2083 2084 2085
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
2088 2089
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2090
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2091 2092 2093 2094 2095 2096
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

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

E
ester.zhou 已提交
2106
let groupName = "GroupName";
E
esterzhou 已提交
2107

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

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

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 已提交
2127 2128
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2129 2130
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2131
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2132 2133 2134 2135 2136 2137
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2138 2139 2140
```ts
let groupName = "GroupName";
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
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
2171 2172 2173
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2174 2175 2176 2177 2178 2179 2180
| 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 已提交
2181
```ts
E
esterzhou 已提交
2182 2183
function removeGroupByBundleCallback(err) {
    if (err) {
E
ester.zhou 已提交
2184
        console.error(`removeGroupByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2185 2186 2187 2188 2189
    } else {
        console.info("removeGroupByBundle success");
    }
}

E
ester.zhou 已提交
2190 2191
let bundleOption = {bundle: "Bundle"};
let groupName = "GroupName";
E
esterzhou 已提交
2192

E
ester.zhou 已提交
2193
notificationManager.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
E
esterzhou 已提交
2194 2195
```

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

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 已提交
2212
| bundle    | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.    |
E
esterzhou 已提交
2213 2214 2215 2216
| groupName | string       | Yes  | Name of the notification group.|

**Error codes**

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

E
esterzhou 已提交
2219 2220
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
2221 2222 2223
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2224 2225 2226 2227 2228 2229 2230
| 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 已提交
2231 2232 2233 2234
```ts
let bundleOption = {bundle: "Bundle"};
let groupName = "GroupName";
notificationManager.removeGroupByBundle(bundleOption, groupName).then(() => {
E
esterzhou 已提交
2235 2236 2237 2238
	console.info("removeGroupByBundle success");
});
```

E
ester.zhou 已提交
2239
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259

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 已提交
2260 2261
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2262 2263
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2264 2265 2266
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2267 2268 2269
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2270
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2271 2272 2273

**Example**

E
ester.zhou 已提交
2274
```ts
E
esterzhou 已提交
2275 2276
function setDoNotDisturbDateCallback(err) {
    if (err) {
E
ester.zhou 已提交
2277
        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2278 2279 2280 2281 2282
    } else {
        console.info("setDoNotDisturbDate success");
    }
}

E
ester.zhou 已提交
2283 2284
let doNotDisturbDate = {
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2285 2286
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2287
};
E
esterzhou 已提交
2288

E
ester.zhou 已提交
2289
notificationManager.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
E
esterzhou 已提交
2290 2291
```

E
ester.zhou 已提交
2292
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311

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 已提交
2312 2313
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2314 2315
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2316 2317 2318
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2319 2320 2321
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2322
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2323 2324 2325

**Example**

E
ester.zhou 已提交
2326 2327 2328
```ts
let doNotDisturbDate = {
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2329 2330
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2331 2332
};
notificationManager.setDoNotDisturbDate(doNotDisturbDate).then(() => {
E
esterzhou 已提交
2333 2334 2335 2336 2337
	console.info("setDoNotDisturbDate success");
});
```


E
ester.zhou 已提交
2338
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359

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 已提交
2360 2361
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2362 2363
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2364 2365 2366
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2367 2368 2369 2370
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2371
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2372 2373 2374

**Example**

E
ester.zhou 已提交
2375
```ts
E
esterzhou 已提交
2376 2377
function setDoNotDisturbDateCallback(err) {
    if (err) {
E
ester.zhou 已提交
2378
        console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2379 2380 2381 2382 2383
    } else {
        console.info("setDoNotDisturbDate success");
    }
}

E
ester.zhou 已提交
2384 2385
let doNotDisturbDate = {
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2386 2387
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2388
};
E
esterzhou 已提交
2389

E
ester.zhou 已提交
2390
let userId = 1;
E
esterzhou 已提交
2391

E
ester.zhou 已提交
2392
notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
E
esterzhou 已提交
2393 2394
```

E
ester.zhou 已提交
2395
## notificationManager.setDoNotDisturbDate
E
esterzhou 已提交
2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415

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 已提交
2416 2417
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2418 2419
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2420 2421 2422
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2423 2424 2425 2426
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2427
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2428 2429 2430

**Example**

E
ester.zhou 已提交
2431 2432 2433
```ts
let doNotDisturbDate = {
    type: notificationManager.DoNotDisturbType.TYPE_ONCE,
E
esterzhou 已提交
2434 2435
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2436
};
E
esterzhou 已提交
2437

E
ester.zhou 已提交
2438
let userId = 1;
E
esterzhou 已提交
2439

E
ester.zhou 已提交
2440
notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
E
esterzhou 已提交
2441 2442 2443 2444 2445
	console.info("setDoNotDisturbDate success");
});
```


E
ester.zhou 已提交
2446
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465

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 已提交
2466 2467
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2468 2469
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2470 2471 2472
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2473 2474 2475
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2476
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2477 2478 2479

**Example**

E
ester.zhou 已提交
2480
```ts
E
esterzhou 已提交
2481 2482
function getDoNotDisturbDateCallback(err,data) {
    if (err) {
E
ester.zhou 已提交
2483
        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2484 2485 2486 2487 2488
    } else {
        console.info("getDoNotDisturbDate success");
    }
}

E
ester.zhou 已提交
2489
notificationManager.getDoNotDisturbDate(getDoNotDisturbDateCallback);
E
esterzhou 已提交
2490 2491
```

E
ester.zhou 已提交
2492
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511

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 已提交
2512 2513
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2514 2515
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2516 2517 2518
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2519 2520 2521
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
E
ester.zhou 已提交
2522
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2523 2524 2525

**Example**

E
ester.zhou 已提交
2526 2527
```ts
notificationManager.getDoNotDisturbDate().then((data) => {
E
esterzhou 已提交
2528 2529 2530 2531 2532
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
2533
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553

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 已提交
2554 2555
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2556 2557
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2558 2559 2560
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2561 2562 2563 2564
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2565
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2566 2567 2568

**Example**

E
ester.zhou 已提交
2569
```ts
E
esterzhou 已提交
2570 2571
function getDoNotDisturbDateCallback(err,data) {
    if (err) {
E
ester.zhou 已提交
2572
        console.error(`getDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2573 2574 2575 2576 2577
    } else {
        console.info("getDoNotDisturbDate success");
    }
}

E
ester.zhou 已提交
2578
let userId = 1;
E
esterzhou 已提交
2579

E
ester.zhou 已提交
2580
notificationManager.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
E
esterzhou 已提交
2581 2582
```

E
ester.zhou 已提交
2583
## notificationManager.getDoNotDisturbDate
E
esterzhou 已提交
2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608

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 已提交
2609 2610
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2611 2612
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2613 2614 2615
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2616 2617 2618 2619
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |
E
ester.zhou 已提交
2620
| 1600012  | No memory space.                          |
E
esterzhou 已提交
2621 2622 2623

**Example**

E
ester.zhou 已提交
2624 2625
```ts
let userId = 1;
E
esterzhou 已提交
2626

E
ester.zhou 已提交
2627
notificationManager.getDoNotDisturbDate(userId).then((data) => {
E
esterzhou 已提交
2628 2629 2630 2631 2632
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
2633
## notificationManager.isSupportDoNotDisturbMode
E
esterzhou 已提交
2634

E
ester.zhou 已提交
2635
 isSupportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
E
esterzhou 已提交
2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654

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                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2655 2656 2657
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2658 2659 2660 2661 2662 2663
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2664
```ts
E
ester.zhou 已提交
2665
function isSupportDoNotDisturbModeCallback(err,data) {
E
esterzhou 已提交
2666
    if (err) {
E
ester.zhou 已提交
2667
        console.error(`isSupportDoNotDisturbMode failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2668
    } else {
E
ester.zhou 已提交
2669
        console.info("isSupportDoNotDisturbMode success");
E
esterzhou 已提交
2670 2671 2672
    }
}

E
ester.zhou 已提交
2673
notificationManager.isSupportDoNotDisturbMode(isSupportDoNotDisturbModeCallback);
E
esterzhou 已提交
2674 2675
```

E
ester.zhou 已提交
2676
## notificationManager.isSupportDoNotDisturbMode
E
esterzhou 已提交
2677

E
ester.zhou 已提交
2678
isSupportDoNotDisturbMode(): Promise\<boolean\>
E
esterzhou 已提交
2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695

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 已提交
2696 2697
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2698 2699
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2700 2701 2702
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2703 2704 2705 2706 2707 2708
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

E
ester.zhou 已提交
2709
```ts
E
ester.zhou 已提交
2710
notificationManager.isSupportDoNotDisturbMode().then((data) => {
E
esterzhou 已提交
2711 2712 2713 2714
	console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
2715
## notificationManager.isSupportTemplate
E
esterzhou 已提交
2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731

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 已提交
2732 2733
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2734 2735
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2736
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2737 2738 2739 2740 2741 2742 2743 2744
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600011  | Read template config failed.        |

**Example**

```javascript
E
ester.zhou 已提交
2745
let templateName = 'process';
E
esterzhou 已提交
2746 2747
function isSupportTemplateCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
2748
        console.error(`isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2749 2750 2751 2752 2753
    } else {
        console.info("isSupportTemplate success");
    }
}

E
ester.zhou 已提交
2754
notificationManager.isSupportTemplate(templateName, isSupportTemplateCallback);
E
esterzhou 已提交
2755 2756
```

E
ester.zhou 已提交
2757
## notificationManager.isSupportTemplate
E
esterzhou 已提交
2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778

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 已提交
2779 2780
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2781 2782
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2783
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2784 2785 2786 2787 2788 2789 2790 2791
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600011  | Read template config failed.        |

**Example**

```javascript
E
ester.zhou 已提交
2792
let templateName = 'process';
E
esterzhou 已提交
2793

E
ester.zhou 已提交
2794
notificationManager.isSupportTemplate(templateName).then((data) => {
E
esterzhou 已提交
2795 2796 2797 2798
    console.info("isSupportTemplate success, data: " + JSON.stringify(data));
});
```

E
ester.zhou 已提交
2799
## notificationManager.requestEnableNotification
E
esterzhou 已提交
2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814

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 已提交
2815 2816
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2817 2818
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2819
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2820 2821 2822 2823 2824 2825 2826 2827 2828
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
function requestEnableNotificationCallback(err) {
    if (err) {
E
ester.zhou 已提交
2829
        console.error(`requestEnableNotification failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2830 2831 2832 2833 2834
    } else {
        console.info("requestEnableNotification success");
    }
};

E
ester.zhou 已提交
2835
notificationManager.requestEnableNotification(requestEnableNotificationCallback);
E
esterzhou 已提交
2836 2837
```

E
ester.zhou 已提交
2838
## notificationManager.requestEnableNotification
E
esterzhou 已提交
2839 2840 2841 2842 2843 2844 2845 2846 2847

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 已提交
2848 2849
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2850 2851
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2852
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2853 2854 2855 2856 2857 2858 2859
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
E
ester.zhou 已提交
2860
notificationManager.requestEnableNotification().then(() => {
E
esterzhou 已提交
2861 2862 2863 2864 2865 2866
    console.info("requestEnableNotification success");
});
```



E
ester.zhou 已提交
2867
## notificationManager.setDistributedEnable
E
esterzhou 已提交
2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887

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 已提交
2888 2889
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2890 2891
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2892 2893 2894
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2895 2896 2897 2898 2899 2900 2901 2902
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
E
ester.zhou 已提交
2903
function setDistributedEnableCallback(err) {
E
esterzhou 已提交
2904
    if (err) {
E
ester.zhou 已提交
2905
        console.error(`setDistributedEnable failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2906 2907 2908 2909 2910
    } else {
        console.info("setDistributedEnable success");
    }
};

E
ester.zhou 已提交
2911
let enable = true;
E
esterzhou 已提交
2912

E
ester.zhou 已提交
2913
notificationManager.setDistributedEnable(enable, setDistributedEnableCallback);
E
esterzhou 已提交
2914 2915
```

E
ester.zhou 已提交
2916
## notificationManager.setDistributedEnable
E
esterzhou 已提交
2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935

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 已提交
2936 2937
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2938 2939
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2940 2941 2942
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
2943 2944 2945 2946 2947 2948 2949 2950
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
E
ester.zhou 已提交
2951
let enable = true;
E
esterzhou 已提交
2952

E
ester.zhou 已提交
2953
notificationManager.setDistributedEnable(enable).then(() => {
E
esterzhou 已提交
2954 2955 2956 2957 2958
        console.info("setDistributedEnable success");
    });
```


E
ester.zhou 已提交
2959
## notificationManager.isDistributedEnabled
E
esterzhou 已提交
2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974

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 已提交
2975 2976
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
2977 2978
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
2979
| 401      | The parameter check failed.         |
E
esterzhou 已提交
2980 2981 2982 2983 2984 2985 2986 2987 2988 2989
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
function isDistributedEnabledCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
2990
        console.error(`isDistributedEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
2991 2992 2993 2994 2995
    } else {
        console.info("isDistributedEnabled success " + JSON.stringify(data));
    }
};

E
ester.zhou 已提交
2996
notificationManager.isDistributedEnabled(isDistributedEnabledCallback);
E
esterzhou 已提交
2997 2998 2999 3000
```



E
ester.zhou 已提交
3001
## notificationManager.isDistributedEnabled
E
esterzhou 已提交
3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016

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 已提交
3017 3018
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3019 3020
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3021
| 401      | The parameter check failed.         |
E
esterzhou 已提交
3022 3023 3024 3025 3026 3027 3028 3029
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600010  | Distributed operation failed.       |

**Example**

```javascript
E
ester.zhou 已提交
3030
notificationManager.isDistributedEnabled()
E
esterzhou 已提交
3031 3032 3033 3034 3035 3036
    .then((data) => {
        console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
    });
```


E
ester.zhou 已提交
3037
## notificationManager.setDistributedEnableByBundle
E
esterzhou 已提交
3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052

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 已提交
3053
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
3054
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                      |
E
esterzhou 已提交
3055 3056 3057 3058
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
3061 3062
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3063 3064 3065
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076
| 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
function setDistributedEnableByBundleCallback(err) {
    if (err) {
E
ester.zhou 已提交
3077
        console.error(`setDistributedEnableByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3078 3079 3080 3081 3082
    } else {
        console.info("enableDistributedByBundle success");
    }
};

E
ester.zhou 已提交
3083
let bundle = {
E
esterzhou 已提交
3084
    bundle: "bundleName1",
E
ester.zhou 已提交
3085
};
E
esterzhou 已提交
3086

E
ester.zhou 已提交
3087
let enable = true
E
esterzhou 已提交
3088

E
ester.zhou 已提交
3089
notificationManager.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback);
E
esterzhou 已提交
3090 3091 3092 3093
```



E
ester.zhou 已提交
3094
## notificationManager.setDistributedEnableByBundle
E
esterzhou 已提交
3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109

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 已提交
3110
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.               |
E
ester.zhou 已提交
3111
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                 |
E
esterzhou 已提交
3112 3113 3114

**Error codes**

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

E
esterzhou 已提交
3117 3118
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3119 3120 3121
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3122 3123 3124 3125 3126 3127 3128 3129 3130
| 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
E
ester.zhou 已提交
3131
let bundle = {
E
esterzhou 已提交
3132
    bundle: "bundleName1",
E
ester.zhou 已提交
3133
};
E
esterzhou 已提交
3134

E
ester.zhou 已提交
3135
let enable = true
E
esterzhou 已提交
3136

E
ester.zhou 已提交
3137 3138 3139
notificationManager.setDistributedEnableByBundle(bundle, enable).then(() => {
    console.info("setDistributedEnableByBundle success");
});
E
esterzhou 已提交
3140 3141
```

E
ester.zhou 已提交
3142
## notificationManager.isDistributedEnabledByBundle
E
esterzhou 已提交
3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157

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 已提交
3158
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.                    |
E
esterzhou 已提交
3159 3160 3161 3162
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
3165 3166
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3167 3168 3169
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3170 3171 3172 3173 3174 3175 3176 3177 3178
| 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
E
ester.zhou 已提交
3179
function isDistributedEnabledByBundleCallback(err, data) {
E
esterzhou 已提交
3180
    if (err) {
E
ester.zhou 已提交
3181
        console.error(`isDistributedEnabledByBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3182 3183 3184 3185 3186
    } else {
        console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
    }
};

E
ester.zhou 已提交
3187
let bundle = {
E
esterzhou 已提交
3188
    bundle: "bundleName1",
E
ester.zhou 已提交
3189
};
E
esterzhou 已提交
3190

E
ester.zhou 已提交
3191
notificationManager.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
esterzhou 已提交
3192 3193
```

E
ester.zhou 已提交
3194
## notificationManager.isDistributedEnabledByBundle
E
esterzhou 已提交
3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209

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 已提交
3210
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption)             | Yes  | Bundle information of the application.               |
E
esterzhou 已提交
3211 3212 3213 3214 3215 3216 3217 3218 3219

**Return value**

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

**Error codes**

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

E
esterzhou 已提交
3222 3223
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3224 3225 3226
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3227 3228 3229 3230 3231 3232 3233 3234 3235
| 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
E
ester.zhou 已提交
3236
let bundle = {
E
esterzhou 已提交
3237
    bundle: "bundleName1",
E
ester.zhou 已提交
3238
};
E
esterzhou 已提交
3239

E
ester.zhou 已提交
3240
notificationManager.isDistributedEnabledByBundle(bundle).then((data) => {
E
esterzhou 已提交
3241 3242 3243 3244 3245
    console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
3246
## notificationManager.getDeviceRemindType
E
esterzhou 已提交
3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265

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 已提交
3266 3267
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3268 3269
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3270 3271 3272
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3273 3274 3275 3276 3277 3278 3279 3280 3281
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
function getDeviceRemindTypeCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
3282
        console.error(`getDeviceRemindType failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3283 3284 3285 3286 3287
    } else {
        console.info("getDeviceRemindType success");
    }
};

E
ester.zhou 已提交
3288
notificationManager.getDeviceRemindType(getDeviceRemindTypeCallback);
E
esterzhou 已提交
3289 3290
```

E
ester.zhou 已提交
3291
## notificationManager.getDeviceRemindType
E
esterzhou 已提交
3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310

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 已提交
3311 3312
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3313 3314
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3315 3316 3317
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3318 3319 3320 3321 3322 3323 3324
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |

**Example**

```javascript
E
ester.zhou 已提交
3325
notificationManager.getDeviceRemindType().then((data) => {
E
esterzhou 已提交
3326 3327 3328 3329 3330
    console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
});
```


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

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 已提交
3347
| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
3348 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.                                |
| callback             | AsyncCallback                               | Yes  | Callback used to return the result.                |

**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
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
E
ester.zhou 已提交
3358 3359 3360
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3361 3362 3363 3364 3365 3366 3367
| 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 已提交
3368
| 1600012  | No memory space.                          |
E
esterzhou 已提交
3369 3370 3371

**Example**

E
ester.zhou 已提交
3372
```ts
E
esterzhou 已提交
3373 3374 3375
// publishAsBundle callback
function callback(err) {
    if (err) {
E
ester.zhou 已提交
3376
        console.error(`publishAsBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3377 3378 3379 3380 3381
    } else {
        console.info("publishAsBundle success");
    }
}
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
3382
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
3383
// User ID
E
ester.zhou 已提交
3384
let userId = 100;
E
esterzhou 已提交
3385 3386 3387 3388
// NotificationRequest object
let request = {
    id: 1,
    content: {
E
ester.zhou 已提交
3389
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
3390 3391 3392 3393 3394 3395
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
3396
};
E
esterzhou 已提交
3397

E
ester.zhou 已提交
3398
notificationManager.publishAsBundle(request, representativeBundle, userId, callback);
E
esterzhou 已提交
3399 3400
```

E
ester.zhou 已提交
3401
## notificationManager.publishAsBundle
E
esterzhou 已提交
3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417

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 已提交
3418
| request              | [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
esterzhou 已提交
3419 3420 3421 3422 3423
| 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 已提交
3424 3425
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3426 3427
| ID| Error Message                                 |
| -------- | ----------------------------------------- |
E
ester.zhou 已提交
3428 3429 3430
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3431 3432 3433 3434 3435 3436 3437
| 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 已提交
3438
| 1600012  | No memory space.                          |
E
esterzhou 已提交
3439 3440 3441

**Example**

E
ester.zhou 已提交
3442
```ts
E
esterzhou 已提交
3443
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
3444
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
3445
// User ID
E
ester.zhou 已提交
3446
let userId = 100;
E
esterzhou 已提交
3447
// NotificationRequest object
E
ester.zhou 已提交
3448
let request = {
E
esterzhou 已提交
3449 3450
    id: 1,
    content: {
E
ester.zhou 已提交
3451
        contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
E
esterzhou 已提交
3452 3453 3454 3455 3456 3457
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
3458
};
E
esterzhou 已提交
3459

E
ester.zhou 已提交
3460
notificationManager.publishAsBundle(request, representativeBundle, userId).then(() => {
E
esterzhou 已提交
3461 3462 3463 3464
	console.info("publishAsBundle success");
});
```

E
ester.zhou 已提交
3465
## notificationManager.cancelAsBundle
E
esterzhou 已提交
3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489

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 已提交
3490 3491
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3492 3493
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3494 3495 3496
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3497 3498 3499 3500 3501 3502 3503 3504
| 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 已提交
3505
```ts
E
esterzhou 已提交
3506 3507 3508
// cancelAsBundle
function cancelAsBundleCallback(err) {
    if (err) {
E
ester.zhou 已提交
3509
        console.error(`cancelAsBundle failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3510 3511 3512 3513 3514
    } else {
        console.info("cancelAsBundle success");
    }
}
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
3515
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
3516
// User ID
E
ester.zhou 已提交
3517
let userId = 100;
E
esterzhou 已提交
3518

E
ester.zhou 已提交
3519
notificationManager.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
E
esterzhou 已提交
3520 3521
```

E
ester.zhou 已提交
3522
## notificationManager.cancelAsBundle
E
esterzhou 已提交
3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545

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 已提交
3546 3547
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3548 3549
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3550 3551 3552
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3553 3554 3555 3556 3557 3558 3559 3560
| 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 已提交
3561
```ts
E
esterzhou 已提交
3562
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
3563
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
3564
// User ID
E
ester.zhou 已提交
3565
let userId = 100;
E
esterzhou 已提交
3566

E
ester.zhou 已提交
3567
notificationManager.cancelAsBundle(0, representativeBundle, userId).then(() => {
E
esterzhou 已提交
3568 3569 3570 3571
	console.info("cancelAsBundle success");
});
```

E
ester.zhou 已提交
3572
## notificationManager.setNotificationEnableSlot 
E
esterzhou 已提交
3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587

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 已提交
3588
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.          |
E
esterzhou 已提交
3589
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
3590
| enable   | boolean                       | Yes  | Whether to enable notification.            |
E
esterzhou 已提交
3591 3592 3593 3594
| callback | AsyncCallback\<void\>         | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
3597 3598
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3599 3600 3601
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3602 3603 3604 3605 3606 3607 3608
| 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 已提交
3609
```ts
E
esterzhou 已提交
3610 3611 3612
// setNotificationEnableSlot
function setNotificationEnableSlotCallback(err) {
    if (err) {
E
ester.zhou 已提交
3613
        console.error(`setNotificationEnableSlot failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3614 3615 3616 3617 3618
    } else {
        console.info("setNotificationEnableSlot success");
    }
};

E
ester.zhou 已提交
3619
notificationManager.setNotificationEnableSlot(
E
esterzhou 已提交
3620
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3621
    notificationManager.SlotType.SOCIAL_COMMUNICATION,
E
esterzhou 已提交
3622 3623 3624 3625
    true,
    setNotificationEnableSlotCallback);
```

E
ester.zhou 已提交
3626
## notificationManager.setNotificationEnableSlot
E
esterzhou 已提交
3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641

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 已提交
3642
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.  |
E
esterzhou 已提交
3643
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|
E
ester.zhou 已提交
3644
| enable | boolean                       | Yes  | Whether to enable notification.    |
E
esterzhou 已提交
3645 3646 3647

**Error codes**

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

E
esterzhou 已提交
3650 3651
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3652 3653 3654
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3655 3656 3657 3658 3659 3660 3661
| 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 已提交
3662
```ts
E
esterzhou 已提交
3663
// setNotificationEnableSlot
E
ester.zhou 已提交
3664
notificationManager.setNotificationEnableSlot(
E
esterzhou 已提交
3665
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3666
    notificationManager.SlotType.SOCIAL_COMMUNICATION,
E
esterzhou 已提交
3667 3668 3669 3670 3671
    true).then(() => {
        console.info("setNotificationEnableSlot success");
    });
```

E
ester.zhou 已提交
3672
## notificationManager.isNotificationSlotEnabled
E
esterzhou 已提交
3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687

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 已提交
3688
| bundle   | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.          |
E
esterzhou 已提交
3689 3690 3691 3692 3693
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|

**Error codes**

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

E
esterzhou 已提交
3696 3697
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3698 3699 3700
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3701 3702 3703 3704 3705 3706 3707
| 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 已提交
3708
```ts
E
esterzhou 已提交
3709 3710 3711
// isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
    if (err) {
E
ester.zhou 已提交
3712
        console.error(`isNotificationSlotEnabled failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3713 3714 3715 3716 3717
    } else {
        console.info("isNotificationSlotEnabled success");
    }
};

E
ester.zhou 已提交
3718
notificationManager.isNotificationSlotEnabled(
E
esterzhou 已提交
3719
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3720
    notificationManager.SlotType.SOCIAL_COMMUNICATION,
E
esterzhou 已提交
3721 3722 3723
    getEnableSlotCallback);
```

E
ester.zhou 已提交
3724
## notificationManager.isNotificationSlotEnabled
E
esterzhou 已提交
3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739

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 已提交
3740
| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes  | Bundle information of the application.  |
E
esterzhou 已提交
3741 3742 3743 3744 3745 3746 3747 3748 3749 3750
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|

**Return value**

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

**Error codes**

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

E
esterzhou 已提交
3753 3754
| ID| Error Message                                |
| -------- | ---------------------------------------- |
E
ester.zhou 已提交
3755 3756 3757
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3758 3759 3760 3761 3762 3763 3764
| 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 已提交
3765
```ts
E
esterzhou 已提交
3766
// isNotificationSlotEnabled
E
ester.zhou 已提交
3767 3768
notificationManager.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
    notificationManager.SlotType.SOCIAL_COMMUNICATION).then((data) => {
E
esterzhou 已提交
3769 3770 3771 3772 3773
    console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
```


E
ester.zhou 已提交
3774
## notificationManager.setSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795

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 已提交
3796 3797
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3798 3799
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3800 3801 3802
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3803 3804 3805 3806 3807 3808 3809
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3810
```ts
E
esterzhou 已提交
3811 3812 3813 3814 3815
let userId = 100;
let enable = true;

function callback(err) {
    if (err) {
E
ester.zhou 已提交
3816
        console.error(`setSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3817 3818 3819 3820 3821
    } else {
        console.info("setSyncNotificationEnabledWithoutApp success");
    }
}

E
ester.zhou 已提交
3822
notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
E
esterzhou 已提交
3823 3824 3825
```


E
ester.zhou 已提交
3826
## notificationManager.setSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
3827 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

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 已提交
3853 3854
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3855 3856
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3857 3858 3859
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3860 3861 3862 3863 3864 3865 3866
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3867
```ts
E
esterzhou 已提交
3868 3869 3870
let userId = 100;
let enable = true;

E
ester.zhou 已提交
3871
notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
E
esterzhou 已提交
3872 3873
    console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => {
E
ester.zhou 已提交
3874
    console.error(`setSyncNotificationEnabledWithoutApp failed, code is ${err.code}, message is ${err.message}`);
E
esterzhou 已提交
3875 3876 3877 3878
});
```


E
ester.zhou 已提交
3879
## notificationManager.getSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899

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 已提交
3900 3901
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3902 3903
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3904 3905 3906
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3907 3908 3909 3910 3911 3912 3913
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3914
```ts
E
esterzhou 已提交
3915 3916 3917 3918 3919 3920 3921 3922 3923 3924
let userId = 100;

function getSyncNotificationEnabledWithoutAppCallback(err, data) {
    if (err) {
        console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
    } else {
        console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
    }
}

E
ester.zhou 已提交
3925
notificationManager.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
E
esterzhou 已提交
3926 3927 3928
```


E
ester.zhou 已提交
3929
## notificationManager.getSyncNotificationEnabledWithoutApp
E
esterzhou 已提交
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

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 已提交
3955 3956
For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md).

E
esterzhou 已提交
3957 3958
| ID| Error Message                           |
| -------- | ----------------------------------- |
E
ester.zhou 已提交
3959 3960 3961
| 201      | Permission denied.                        |
| 202      | Not system application to call the interface. |
| 401      | The parameter check failed.               |
E
esterzhou 已提交
3962 3963 3964 3965 3966 3967 3968
| 1600001  | Internal error.                     |
| 1600002  | Marshalling or unmarshalling error. |
| 1600003  | Failed to connect service.          |
| 1600008  | The user is not exist.              |

**Example**

E
ester.zhou 已提交
3969
```ts
E
esterzhou 已提交
3970
let userId = 100;
E
ester.zhou 已提交
3971
notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
E
esterzhou 已提交
3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 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 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069
    console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => {
    console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
});
```


## DoNotDisturbDate

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

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

| Name | Type                                 | Readable| Writable| Description                  |
| ----- | ------------------------------------- | ---- | ---- | ---------------------- |
| type  | [DoNotDisturbType](#donotdisturbtype) | Yes  | Yes  | DND time type.|
| begin | Date                                  | Yes  | Yes  | DND start time.|
| end   | Date                                  | Yes  | Yes  | DND end time.|

## 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              |
| --------------------------------- | ----------- | ------------------ |
| 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.    |
| NOTIFICATION_CONTENT_MULTILINE    | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|

## 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.           |