1# @ohos.notification (Notification) 2 3The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status. 4 5> **NOTE** 6> 7> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.notificationManager](js-apis-notificationManager.md). 8> 9> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. 10> 11> Notification subscription and unsubscription APIs are available only to system applications. 12 13## Modules to Import 14 15```ts 16import Notification from '@ohos.notification'; 17``` 18 19## Notification.publish 20 21publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void 22 23Publishes a notification. This API uses an asynchronous callback to return the result. 24 25**System capability**: SystemCapability.Notification.Notification 26 27**Parameters** 28 29| Name | Type | Mandatory| Description | 30| -------- | ------------------------------------------- | ---- | ------------------------------------------- | 31| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| 32| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 33 34**Example** 35 36```ts 37import NotificationManager from '@ohos.notificationManager'; 38import Base from '@ohos.base'; 39 40// publish callback 41let publishCallback = (err: Base.BusinessError) => { 42 if (err) { 43 console.error(`publish failed, code is ${err}`); 44 } else { 45 console.info("publish success"); 46 } 47} 48// NotificationRequest object 49let notificationRequest: NotificationManager.NotificationRequest = { 50 id: 1, 51 content: { 52 contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, 53 normal: { 54 title: "test_title", 55 text: "test_text", 56 additionalText: "test_additionalText" 57 } 58 } 59}; 60Notification.publish(notificationRequest, publishCallback); 61``` 62 63## Notification.publish 64 65publish(request: NotificationRequest): Promise\<void\> 66 67Publishes a notification. This API uses a promise to return the result. 68 69**System capability**: SystemCapability.Notification.Notification 70 71**Parameters** 72 73| Name | Type | Mandatory| Description | 74| -------- | ------------------------------------------- | ---- | ------------------------------------------- | 75| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| 76 77**Return value** 78 79| Type | Description | 80| ------- |------------| 81| Promise\<void\> | Promise that returns no value.| 82 83**Example** 84 85```ts 86import NotificationManager from '@ohos.notificationManager'; 87import Base from '@ohos.base'; 88 89// NotificationRequest object 90let notificationRequest: NotificationManager.NotificationRequest = { 91 id: 1, 92 content: { 93 contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, 94 normal: { 95 title: "test_title", 96 text: "test_text", 97 additionalText: "test_additionalText" 98 } 99 } 100}; 101Notification.publish(notificationRequest).then(() => { 102 console.info("publish success"); 103}).catch((err: Base.BusinessError) => { 104 console.error(`publish failed, code is ${err}`); 105}); 106``` 107 108## Notification.publish<sup>8+</sup> 109 110publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void 111 112Publishes a notification to a specified user. This API uses an asynchronous callback to return the result. 113 114**System capability**: SystemCapability.Notification.Notification 115 116**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 117 118**System API**: This is a system API and cannot be called by third-party applications. 119 120**Parameters** 121 122| Name | Type | Mandatory| Description | 123| -------- | ----------------------------------------- | ---- | ------------------------------------------- | 124| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| 125| userId | number | Yes | User ID. | 126| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 127 128**Example** 129 130```ts 131import NotificationManager from '@ohos.notificationManager'; 132import Base from '@ohos.base'; 133 134// publish callback 135let publishCallback = (err: Base.BusinessError) => { 136 if (err) { 137 console.error(`publish failed, code is ${err.code}`); 138 } else { 139 console.info("publish success"); 140 } 141} 142// User ID 143let userId: number = 1; 144// NotificationRequest object 145let notificationRequest: NotificationManager.NotificationRequest = { 146 id: 1, 147 content: { 148 contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, 149 normal: { 150 title: "test_title", 151 text: "test_text", 152 additionalText: "test_additionalText" 153 } 154 } 155}; 156Notification.publish(notificationRequest, userId, publishCallback); 157``` 158 159## Notification.publish<sup>8+</sup> 160 161publish(request: NotificationRequest, userId: number): Promise\<void\> 162 163Publishes a notification to a specified user. This API uses a promise to return the result. 164 165**System capability**: SystemCapability.Notification.Notification 166 167**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 168 169**System API**: This is a system API and cannot be called by third-party applications. 170 171**Parameters** 172 173| Name | Type | Mandatory| Description | 174| -------- | ----------------------------------------- | ---- | ------------------------------------------- | 175| request | [NotificationRequest](#notificationrequest) | Yes | Content and related configuration of the notification to publish.| 176| userId | number | Yes | User ID. | 177 178**Return value** 179 180| Type | Description | 181| ------- |------------| 182| Promise\<void\> | Promise that returns no value.| 183 184**Example** 185 186```ts 187import NotificationManager from '@ohos.notificationManager'; 188import Base from '@ohos.base'; 189 190let notificationRequest: NotificationManager.NotificationRequest = { 191 id: 1, 192 content: { 193 contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, 194 normal: { 195 title: "test_title", 196 text: "test_text", 197 additionalText: "test_additionalText" 198 } 199 } 200}; 201 202let userId: number = 1; 203 204Notification.publish(notificationRequest, userId).then(() => { 205 console.info("publish success"); 206}).catch((err: Base.BusinessError) => { 207 console.error(`publish failed, code is ${err}`); 208}); 209``` 210 211 212## Notification.cancel 213 214cancel(id: number, label: string, callback: AsyncCallback\<void\>): void 215 216Cancels a notification with the specified ID and label. This API uses an asynchronous callback to return the result. 217 218**System capability**: SystemCapability.Notification.Notification 219 220**Parameters** 221 222| Name | Type | Mandatory| Description | 223| -------- | --------------------- | ---- | -------------------- | 224| id | number | Yes | Notification ID. | 225| label | string | Yes | Notification label. | 226| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 227 228**Example** 229 230```ts 231import Base from '@ohos.base'; 232 233// cancel callback 234let cancelCallback = (err: Base.BusinessError) => { 235 if (err) { 236 console.info("cancel failed " + JSON.stringify(err)); 237 } else { 238 console.info("cancel success"); 239 } 240} 241Notification.cancel(0, "label", cancelCallback); 242``` 243 244 245 246## Notification.cancel 247 248cancel(id: number, label?: string): Promise\<void\> 249 250Cancels a notification with the specified ID and optional label. This API uses a promise to return the result. 251 252**System capability**: SystemCapability.Notification.Notification 253 254**Parameters** 255 256| Name | Type | Mandatory| Description | 257| ----- | ------ | ---- | -------- | 258| id | number | Yes | Notification ID. | 259| label | string | No | Notification label. This parameter is left empty by default.| 260 261**Return value** 262 263| Type | Description | 264| ------- |------------| 265| Promise\<void\> | Promise that returns no value.| 266 267**Example** 268 269```ts 270import Base from '@ohos.base'; 271 272Notification.cancel(0).then(() => { 273 console.info("cancel success"); 274}).catch((err: Base.BusinessError) => { 275 console.error(`cancel failed, code is ${err}`); 276}); 277``` 278 279 280 281## Notification.cancel 282 283cancel(id: number, callback: AsyncCallback\<void\>): void 284 285Cancels a notification with the specified ID. This API uses an asynchronous callback to return the result. 286 287**System capability**: SystemCapability.Notification.Notification 288 289**Parameters** 290 291| Name | Type | Mandatory| Description | 292| -------- | --------------------- | ---- | -------------------- | 293| id | number | Yes | Notification ID. | 294| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 295 296**Example** 297 298```ts 299import Base from '@ohos.base'; 300 301// cancel callback 302let cancelCallback = (err: Base.BusinessError) => { 303 if (err) { 304 console.info("cancel failed " + JSON.stringify(err)); 305 } else { 306 console.info("cancel success"); 307 } 308} 309Notification.cancel(0, cancelCallback); 310``` 311 312 313 314## Notification.cancelAll 315 316cancelAll(callback: AsyncCallback\<void\>): void 317 318Cancels all notifications. This API uses an asynchronous callback to return the result. 319 320**System capability**: SystemCapability.Notification.Notification 321 322**Parameters** 323 324| Name | Type | Mandatory| Description | 325| -------- | --------------------- | ---- | -------------------- | 326| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 327 328**Example** 329 330```ts 331import Base from '@ohos.base'; 332 333// cancel callback 334let cancelAllCallback = (err: Base.BusinessError) => { 335 if (err) { 336 console.info("cancelAll failed " + JSON.stringify(err)); 337 } else { 338 console.info("cancelAll success"); 339 } 340} 341Notification.cancelAll(cancelAllCallback); 342``` 343 344## Notification.cancelAll 345 346cancelAll(): Promise\<void\> 347 348Cancels all notifications. This API uses a promise to return the result. 349 350**System capability**: SystemCapability.Notification.Notification 351 352**Return value** 353 354| Type | Description | 355| ------- |------------| 356| Promise\<void\> | Promise that returns no value.| 357 358**Example** 359 360```ts 361import Base from '@ohos.base'; 362 363Notification.cancelAll().then(() => { 364 console.info("cancelAll success"); 365}).catch((err: Base.BusinessError) => { 366 console.error(`cancelAll failed, code is ${err}`); 367}); 368``` 369 370## Notification.addSlot 371 372addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void 373 374Adds a notification slot. This API uses an asynchronous callback to return the result. 375 376**System capability**: SystemCapability.Notification.Notification 377 378**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 379 380**System API**: This is a system API and cannot be called by third-party applications. 381 382**Parameters** 383 384| Name | Type | Mandatory| Description | 385| -------- | --------------------- | ---- | -------------------- | 386| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot to add.| 387| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 388 389**Example** 390 391```ts 392import NotificationManager from '@ohos.notificationManager'; 393import Base from '@ohos.base'; 394 395// addSlot callback 396let addSlotCallBack = (err: Base.BusinessError) => { 397 if (err) { 398 console.info("addSlot failed " + JSON.stringify(err)); 399 } else { 400 console.info("addSlot success"); 401 } 402} 403// NotificationSlot object 404let notificationSlot: NotificationManager.NotificationSlot = { 405 type: Notification.SlotType.SOCIAL_COMMUNICATION 406}; 407Notification.addSlot(notificationSlot, addSlotCallBack); 408``` 409 410## Notification.addSlot 411 412addSlot(slot: NotificationSlot): Promise\<void\> 413 414Adds a notification slot. This API uses a promise to return the result. 415 416**System capability**: SystemCapability.Notification.Notification 417 418**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 419 420**System API**: This is a system API and cannot be called by third-party applications. 421 422**Parameters** 423 424| Name| Type | Mandatory| Description | 425| ---- | ---------------- | ---- | -------------------- | 426| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot to add.| 427 428**Return value** 429 430| Type | Description | 431| ------- |------------| 432| Promise\<void\> | Promise that returns no value.| 433 434**Example** 435 436```ts 437import NotificationManager from '@ohos.notificationManager'; 438import Base from '@ohos.base'; 439 440// NotificationSlot object 441let notificationSlot: NotificationManager.NotificationSlot = { 442 type: Notification.SlotType.SOCIAL_COMMUNICATION 443}; 444Notification.addSlot(notificationSlot).then(() => { 445 console.info("addSlot success"); 446}).catch((err: Base.BusinessError) => { 447 console.error(`addSlot failed, code is ${err}`); 448}); 449``` 450 451## Notification.addSlot 452 453addSlot(type: SlotType, callback: AsyncCallback\<void\>): void 454 455Adds a notification slot of a specified type. This API uses an asynchronous callback to return the result. 456 457**System capability**: SystemCapability.Notification.Notification 458 459**Parameters** 460 461| Name | Type | Mandatory| Description | 462| -------- | --------------------- | ---- | ---------------------- | 463| type | [SlotType](#slottype) | Yes | Type of the notification slot to add.| 464| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 465 466**Example** 467 468```ts 469import Base from '@ohos.base'; 470 471// addSlot callback 472let addSlotCallBack = (err: Base.BusinessError) => { 473 if (err) { 474 console.info("addSlot failed " + JSON.stringify(err)); 475 } else { 476 console.info("addSlot success"); 477 } 478} 479Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack); 480``` 481 482## Notification.addSlot 483 484addSlot(type: SlotType): Promise\<void\> 485 486Adds a notification slot of a specified type. This API uses a promise to return the result. 487 488**System capability**: SystemCapability.Notification.Notification 489 490**Parameters** 491 492| Name| Type | Mandatory| Description | 493| ---- | -------- | ---- | ---------------------- | 494| type | [SlotType](#slottype) | Yes | Type of the notification slot to add.| 495 496**Return value** 497 498| Type | Description | 499| ------- |------------| 500| Promise\<void\> | Promise that returns no value.| 501 502**Example** 503 504```ts 505import Base from '@ohos.base'; 506 507Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { 508 console.info("addSlot success"); 509}).catch((err: Base.BusinessError) => { 510 console.error(`addSlot failed, code is ${err}`); 511}); 512``` 513 514## Notification.addSlots 515 516addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void 517 518Adds an array of notification slots. This API uses an asynchronous callback to return the result. 519 520**System capability**: SystemCapability.Notification.Notification 521 522**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 523 524**System API**: This is a system API and cannot be called by third-party applications. 525 526**Parameters** 527 528| Name | Type | Mandatory| Description | 529| -------- | ------------------------- | ---- | ------------------------ | 530| slots | Array\<[NotificationSlot](#notificationslot)\> | Yes | Notification slots to add.| 531| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 532 533**Example** 534 535```ts 536import NotificationManager from '@ohos.notificationManager'; 537import Base from '@ohos.base'; 538 539// addSlots callback 540let addSlotsCallBack = (err: Base.BusinessError) => { 541 if (err) { 542 console.info("addSlots failed " + JSON.stringify(err)); 543 } else { 544 console.info("addSlots success"); 545 } 546} 547// NotificationSlot object 548let notificationSlot: NotificationManager.NotificationSlot = { 549 type: Notification.SlotType.SOCIAL_COMMUNICATION 550}; 551// NotificationSlotArray object 552let notificationSlotArray: NotificationManager.NotificationSlot[] = new Array(); 553notificationSlotArray[0] = notificationSlot; 554 555Notification.addSlots(notificationSlotArray, addSlotsCallBack); 556``` 557 558## Notification.addSlots 559 560addSlots(slots: Array\<NotificationSlot\>): Promise\<void\> 561 562Adds an array of notification slots. This API uses a promise to return the result. 563 564**System capability**: SystemCapability.Notification.Notification 565 566**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 567 568**System API**: This is a system API and cannot be called by third-party applications. 569 570**Parameters** 571 572| Name | Type | Mandatory| Description | 573| ----- | ------------------------- | ---- | ------------------------ | 574| slots | Array\<[NotificationSlot](#notificationslot)\> | Yes | Notification slots to add.| 575 576**Return value** 577 578| Type | Description | 579| ------- |------------| 580| Promise\<void\> | Promise that returns no value.| 581 582**Example** 583 584```ts 585import NotificationManager from '@ohos.notificationManager'; 586import Base from '@ohos.base'; 587 588// NotificationSlot object 589let notificationSlot: NotificationManager.NotificationSlot = { 590 type: Notification.SlotType.SOCIAL_COMMUNICATION 591}; 592// NotificationSlotArray object 593let notificationSlotArray: NotificationManager.NotificationSlot[] = new Array(); 594notificationSlotArray[0] = notificationSlot; 595 596Notification.addSlots(notificationSlotArray).then(() => { 597 console.info("addSlots success"); 598}).catch((err: Base.BusinessError) => { 599 console.error(`addSlot failed, code is ${err}`); 600}); 601``` 602 603## Notification.getSlot 604 605getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void 606 607Obtains a notification slot of a specified type. This API uses a promise to return the result. 608 609**System capability**: SystemCapability.Notification.Notification 610 611**Parameters** 612 613| Name | Type | Mandatory| Description | 614| -------- | --------------------------------- | ---- | ----------------------------------------------------------- | 615| slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| 616| callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | Yes | Callback used to return the result. | 617 618**Example** 619 620```ts 621import Base from '@ohos.base'; 622 623// getSlot callback 624let getSlotCallback = (err: Base.BusinessError) => { 625 if (err) { 626 console.info("getSlot failed " + JSON.stringify(err)); 627 } else { 628 console.info("getSlot success"); 629 } 630} 631let slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION; 632Notification.getSlot(slotType, getSlotCallback); 633``` 634 635## Notification.getSlot 636 637getSlot(slotType: SlotType): Promise\<NotificationSlot\> 638 639Obtains a notification slot of a specified type. This API uses a promise to return the result. 640 641**System capability**: SystemCapability.Notification.Notification 642 643**Parameters** 644 645| Name | Type | Mandatory| Description | 646| -------- | -------- | ---- | ----------------------------------------------------------- | 647| slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| 648 649**Return value** 650 651| Type | Description | 652| ----------------------------------------------------------- | ------------------------------------------------------------ | 653| Promise\<NotificationSlot\> | Promise used to return the result.| 654 655**Example** 656 657```ts 658import Base from '@ohos.base'; 659 660let slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION; 661Notification.getSlot(slotType).then((data) => { 662 console.info("getSlot success, data: " + JSON.stringify(data)); 663}).catch((err: Base.BusinessError) => { 664 console.error(`getSlot failed, code is ${err}`); 665}); 666``` 667 668## Notification.getSlots 669 670getSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void 671 672Obtains all notification slots. This API uses an asynchronous callback to return the result. 673 674**System capability**: SystemCapability.Notification.Notification 675 676**Parameters** 677 678| Name | Type | Mandatory| Description | 679| -------- | --------------------------------- | ---- | -------------------- | 680| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.| 681 682**Example** 683 684```ts 685import Base from '@ohos.base'; 686 687// getSlots callback 688function getSlotsCallback(err: Base.BusinessError) { 689 if (err) { 690 console.info("getSlots failed " + JSON.stringify(err)); 691 } else { 692 console.info("getSlots success"); 693 } 694} 695Notification.getSlots(getSlotsCallback); 696``` 697 698## Notification.getSlots 699 700getSlots(): Promise\<Array\<NotificationSlot\>> 701 702Obtains all notification slots of this application. This API uses a promise to return the result. 703 704**System capability**: SystemCapability.Notification.Notification 705 706**Return value** 707 708| Type | Description | 709| ----------------------------------------------------------- | ------------------------------------------------------------ | 710| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.| 711 712**Example** 713 714```ts 715import Base from '@ohos.base'; 716 717Notification.getSlots().then((data) => { 718 console.info("getSlots success, data: " + JSON.stringify(data)); 719}).catch((err: Base.BusinessError) => { 720 console.error(`getSlots failed, code is ${err}`); 721}); 722``` 723 724## Notification.removeSlot 725 726removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void 727 728Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. 729 730**System capability**: SystemCapability.Notification.Notification 731 732**Parameters** 733 734| Name | Type | Mandatory| Description | 735| -------- | --------------------- | ---- | ----------------------------------------------------------- | 736| slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| 737| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | 738 739**Example** 740 741```ts 742import Base from '@ohos.base'; 743 744// removeSlot callback 745let removeSlotCallback = (err: Base.BusinessError) => { 746 if (err) { 747 console.info("removeSlot failed " + JSON.stringify(err)); 748 } else { 749 console.info("removeSlot success"); 750 } 751} 752let slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION; 753Notification.removeSlot(slotType, removeSlotCallback); 754``` 755 756## Notification.removeSlot 757 758removeSlot(slotType: SlotType): Promise\<void\> 759 760Removes a notification slot of a specified type. This API uses a promise to return the result. 761 762**System capability**: SystemCapability.Notification.Notification 763 764**Parameters** 765 766| Name | Type | Mandatory| Description | 767| -------- | -------- | ---- | ----------------------------------------------------------- | 768| slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| 769 770**Return value** 771 772| Type | Description | 773| ------- |------------| 774| Promise\<void\> | Promise that returns no value.| 775 776**Example** 777 778```ts 779import Base from '@ohos.base'; 780 781let slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION; 782Notification.removeSlot(slotType).then(() => { 783 console.info("removeSlot success"); 784}).catch((err: Base.BusinessError) => { 785 console.error(`removeSlot failed, code is ${err}`); 786}); 787``` 788 789## Notification.removeAllSlots 790 791removeAllSlots(callback: AsyncCallback\<void\>): void 792 793Removes all notification slots. This API uses an asynchronous callback to return the result. 794 795**System capability**: SystemCapability.Notification.Notification 796 797**Parameters** 798 799| Name | Type | Mandatory| Description | 800| -------- | --------------------- | ---- | -------------------- | 801| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 802 803**Example** 804 805```ts 806import Base from '@ohos.base'; 807 808let removeAllCallBack = (err: Base.BusinessError) => { 809 if (err) { 810 console.info("removeAllSlots failed " + JSON.stringify(err)); 811 } else { 812 console.info("removeAllSlots success"); 813 } 814} 815Notification.removeAllSlots(removeAllCallBack); 816``` 817 818## Notification.removeAllSlots 819 820removeAllSlots(): Promise\<void\> 821 822Removes all notification slots. This API uses a promise to return the result. 823 824**System capability**: SystemCapability.Notification.Notification 825 826**Return value** 827 828| Type | Description | 829| ------- |------------| 830| Promise\<void\> | Promise that returns no value.| 831 832**Example** 833 834```ts 835import Base from '@ohos.base'; 836 837Notification.removeAllSlots().then(() => { 838 console.info("removeAllSlots success"); 839}).catch((err: Base.BusinessError) => { 840 console.error(`removeAllSlots failed, code is ${err}`); 841}); 842``` 843 844## Notification.subscribe 845 846subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\<void\>): void 847 848Subscribes to a notification with the subscription information specified. This API uses an asynchronous callback to return the result. 849 850**System capability**: SystemCapability.Notification.Notification 851 852**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 853 854**System API**: This is a system API and cannot be called by third-party applications. 855 856**Parameters** 857 858| Name | Type | Mandatory| Description | 859| ---------- | ------------------------- | ---- | ---------------- | 860| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber. | 861| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes | Notification subscription information.| 862| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 863 864**Example** 865 866```ts 867import Base from '@ohos.base'; 868import NotificationSubscribe from '@ohos.notificationSubscribe'; 869 870// subscribe callback 871let subscribeCallback = (err: Base.BusinessError) => { 872 if (err) { 873 console.info("subscribe failed " + JSON.stringify(err)); 874 } else { 875 console.info("subscribe success"); 876 } 877} 878let onConsumeCallback = (data: NotificationSubscribe.SubscribeCallbackData) => { 879 console.info("Consume callback: " + JSON.stringify(data)); 880} 881let subscriber: NotificationSubscribe.NotificationSubscriber = { 882 onConsume: onConsumeCallback 883}; 884let info: NotificationSubscribe.NotificationSubscribeInfo = { 885 bundleNames: ["bundleName1", "bundleName2"] 886}; 887Notification.subscribe(subscriber, info, subscribeCallback); 888``` 889 890## Notification.subscribe 891 892subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void 893 894Subscribes to notifications of all applications under this user. This API uses an asynchronous callback to return the result. 895 896**System capability**: SystemCapability.Notification.Notification 897 898**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 899 900**System API**: This is a system API and cannot be called by third-party applications. 901 902**Parameters** 903 904| Name | Type | Mandatory| Description | 905| ---------- | ---------------------- | ---- | ---------------- | 906| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber. | 907| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 908 909**Example** 910 911```ts 912import Base from '@ohos.base'; 913import NotificationSubscribe from '@ohos.notificationSubscribe'; 914 915let subscribeCallback = (err: Base.BusinessError) => { 916 if (err) { 917 console.info("subscribe failed " + JSON.stringify(err)); 918 } else { 919 console.info("subscribe success"); 920 } 921} 922function onConsumeCallback(data: NotificationSubscribe.SubscribeCallbackData) { 923 console.info("Consume callback: " + JSON.stringify(data)); 924} 925let subscriber: NotificationSubscribe.NotificationSubscriber = { 926 onConsume: onConsumeCallback 927}; 928Notification.subscribe(subscriber, subscribeCallback); 929``` 930 931## Notification.subscribe 932 933subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise\<void\> 934 935Subscribes to a notification with the subscription information specified. This API uses a promise to return the result. 936 937**System capability**: SystemCapability.Notification.Notification 938 939**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 940 941**System API**: This is a system API and cannot be called by third-party applications. 942 943**Parameters** 944 945| Name | Type | Mandatory| Description | 946| ---------- | ------------------------- | ---- | ------------ | 947| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber.| 948| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No | Notification subscription information. This parameter is left empty by default. | 949 950**Return value** 951 952| Type | Description | 953| ------- |------------| 954| Promise\<void\> | Promise that returns no value.| 955 956**Example** 957 958```ts 959import Base from '@ohos.base'; 960import NotificationSubscribe from '@ohos.notificationSubscribe'; 961 962function onConsumeCallback(data: NotificationSubscribe.SubscribeCallbackData) { 963 console.info("Consume callback: " + JSON.stringify(data)); 964} 965let subscriber: NotificationSubscribe.NotificationSubscriber = { 966 onConsume: onConsumeCallback 967}; 968Notification.subscribe(subscriber).then(() => { 969 console.info("subscribe success"); 970}).catch((err: Base.BusinessError) => { 971 console.error(`subscribe failed, code is ${err}`); 972}); 973``` 974 975## Notification.unsubscribe 976 977unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void 978 979Unsubscribes from a notification. This API uses an asynchronous callback to return the result. 980 981**System capability**: SystemCapability.Notification.Notification 982 983**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 984 985**System API**: This is a system API and cannot be called by third-party applications. 986 987**Parameters** 988 989| Name | Type | Mandatory| Description | 990| ---------- | ---------------------- | ---- | -------------------- | 991| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber. | 992| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 993 994**Example** 995 996```ts 997import Base from '@ohos.base'; 998import NotificationSubscribe from '@ohos.notificationSubscribe'; 999 1000let unsubscribeCallback = (err: Base.BusinessError) => { 1001 if (err) { 1002 console.info("unsubscribe failed " + JSON.stringify(err)); 1003 } else { 1004 console.info("unsubscribe success"); 1005 } 1006} 1007let onDisconnectCallback = () => { 1008 console.info("subscribe disconnect"); 1009} 1010let subscriber: NotificationSubscribe.NotificationSubscriber = { 1011 onDisconnect: onDisconnectCallback 1012}; 1013Notification.unsubscribe(subscriber, unsubscribeCallback); 1014``` 1015 1016## Notification.unsubscribe 1017 1018unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> 1019 1020Unsubscribes from a notification. This API uses a promise to return the result. 1021 1022**System capability**: SystemCapability.Notification.Notification 1023 1024**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1025 1026**System API**: This is a system API and cannot be called by third-party applications. 1027 1028**Parameters** 1029 1030| Name | Type | Mandatory| Description | 1031| ---------- | ---------------------- | ---- | ------------ | 1032| subscriber | [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md#notificationsubscriber) | Yes | Notification subscriber.| 1033 1034**Return value** 1035 1036| Type | Description | 1037| ------- |------------| 1038| Promise\<void\> | Promise that returns no value.| 1039 1040**Example** 1041 1042```ts 1043import Base from '@ohos.base'; 1044import NotificationSubscribe from '@ohos.notificationSubscribe'; 1045 1046function onDisconnectCallback() { 1047 console.info("subscribe disconnect"); 1048} 1049let subscriber: NotificationSubscribe.NotificationSubscriber = { 1050 onDisconnect: onDisconnectCallback 1051}; 1052Notification.unsubscribe(subscriber).then(() => { 1053 console.info("unsubscribe success"); 1054}).catch((err: Base.BusinessError) => { 1055 console.error(`unsubscribe failed, code is ${err}`); 1056}); 1057``` 1058 1059## Notification.enableNotification 1060 1061enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void 1062 1063Sets whether to enable notification for a specified application. This API uses an asynchronous callback to return the result. 1064 1065**System capability**: SystemCapability.Notification.Notification 1066 1067**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1068 1069**System API**: This is a system API and cannot be called by third-party applications. 1070 1071**Parameters** 1072 1073| Name | Type | Mandatory| Description | 1074| -------- | --------------------- | ---- | -------------------- | 1075| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1076| enable | boolean | Yes | Whether to enable notification. | 1077| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1078 1079**Example** 1080 1081```ts 1082import Base from '@ohos.base'; 1083 1084let enableNotificationCallback = (err: Base.BusinessError) => { 1085 if (err) { 1086 console.info("enableNotification failed " + JSON.stringify(err)); 1087 } else { 1088 console.info("enableNotification success"); 1089 } 1090} 1091let bundle: Notification.BundleOption = { 1092 bundle: "bundleName1", 1093}; 1094Notification.enableNotification(bundle, false, enableNotificationCallback); 1095``` 1096 1097## Notification.enableNotification 1098 1099enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\> 1100 1101Sets whether to enable notification for a specified application. This API uses a promise to return the result. 1102 1103**System capability**: SystemCapability.Notification.Notification 1104 1105**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1106 1107**System API**: This is a system API and cannot be called by third-party applications. 1108 1109**Parameters** 1110 1111| Name | Type | Mandatory| Description | 1112| ------ | ------------ | ---- | ---------- | 1113| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1114| enable | boolean | Yes | Whether to enable notification. | 1115 1116**Return value** 1117 1118| Type | Description | 1119| ------- |------------| 1120| Promise\<void\> | Promise that returns no value.| 1121 1122**Example** 1123 1124```ts 1125import Base from '@ohos.base'; 1126 1127let bundle: Notification.BundleOption = { 1128 bundle: "bundleName1", 1129}; 1130Notification.enableNotification(bundle, false).then(() => { 1131 console.info("enableNotification success"); 1132}).catch((err: Base.BusinessError) => { 1133 console.error(`enableNotification failed, code is ${err}`); 1134}); 1135 1136``` 1137 1138## Notification.isNotificationEnabled 1139 1140isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void 1141 1142Checks whether notification is enabled for a specified application. This API uses a promise to return the result. 1143 1144**System capability**: SystemCapability.Notification.Notification 1145 1146**System API**: This is a system API and cannot be called by third-party applications. 1147 1148**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1149 1150**Parameters** 1151 1152| Name | Type | Mandatory| Description | 1153| -------- | --------------------- | ---- | ------------------------ | 1154| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1155| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1156 1157**Example** 1158 1159```ts 1160import Base from '@ohos.base'; 1161 1162let isNotificationEnabledCallback = (err: Base.BusinessError, data: boolean) => { 1163 if (err) { 1164 console.info("isNotificationEnabled failed " + JSON.stringify(err)); 1165 } else { 1166 console.info("isNotificationEnabled success"); 1167 } 1168} 1169let bundle: Notification.BundleOption = { 1170 bundle: "bundleName1", 1171}; 1172Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); 1173``` 1174 1175## Notification.isNotificationEnabled 1176 1177isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> 1178 1179Checks whether notification is enabled for a specified application. This API uses a promise to return the result. 1180 1181**System capability**: SystemCapability.Notification.Notification 1182 1183**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1184 1185**System API**: This is a system API and cannot be called by third-party applications. 1186 1187**Parameters** 1188 1189| Name | Type | Mandatory| Description | 1190| ------ | ------------ | ---- | ---------- | 1191| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1192 1193**Return value** 1194 1195| Type | Description | 1196| ------------------ | --------------------------------------------------- | 1197| Promise\<boolean\> | Promise used to return the result.| 1198 1199**Example** 1200 1201```ts 1202import Base from '@ohos.base'; 1203 1204let bundle: Notification.BundleOption = { 1205 bundle: "bundleName1", 1206}; 1207Notification.isNotificationEnabled(bundle).then((data) => { 1208 console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); 1209}).catch((err: Base.BusinessError) => { 1210 console.error(`isNotificationEnabled failed, code is ${err}`); 1211}); 1212``` 1213 1214## Notification.isNotificationEnabled 1215 1216isNotificationEnabled(callback: AsyncCallback\<boolean\>): void 1217 1218Checks whether notification is enabled for this application. This API uses an asynchronous callback to return the result. 1219 1220**System capability**: SystemCapability.Notification.Notification 1221 1222**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1223 1224**System API**: This is a system API and cannot be called by third-party applications. 1225 1226**Parameters** 1227 1228| Name | Type | Mandatory| Description | 1229| -------- | --------------------- | ---- | ------------------------ | 1230| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1231 1232**Example** 1233 1234```ts 1235import Base from '@ohos.base'; 1236 1237let isNotificationEnabledCallback = (err: Base.BusinessError, data: boolean) => { 1238 if (err) { 1239 console.info("isNotificationEnabled failed " + JSON.stringify(err)); 1240 } else { 1241 console.info("isNotificationEnabled success"); 1242 } 1243} 1244 1245Notification.isNotificationEnabled(isNotificationEnabledCallback); 1246``` 1247 1248## Notification.isNotificationEnabled 1249 1250isNotificationEnabled(): Promise\<boolean\> 1251 1252Checks whether notification is enabled for this application. This API uses a promise to return the result. 1253 1254**System capability**: SystemCapability.Notification.Notification 1255 1256**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1257 1258**System API**: This is a system API and cannot be called by third-party applications. 1259 1260**Parameters** 1261 1262| Name | Type | Mandatory| Description | 1263| ------ | ------------ | ---- | ---------- | 1264| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1265 1266**Return value** 1267 1268| Type | Description | 1269| ----------------------------------------------------------- | ------------------------------------------------------------ | 1270| Promise\<boolean\> | Promise used to return the result.| 1271 1272**Example** 1273 1274```ts 1275import Base from '@ohos.base'; 1276 1277Notification.isNotificationEnabled().then((data: boolean) => { 1278 console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); 1279}).catch((err: Base.BusinessError) => { 1280 console.error(`isNotificationEnabled failed, code is ${err}`); 1281}); 1282``` 1283 1284## Notification.displayBadge 1285 1286displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void 1287 1288Sets whether to enable the notification badge for a specified application. This API uses an asynchronous callback to return the result. 1289 1290**System capability**: SystemCapability.Notification.Notification 1291 1292**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1293 1294**System API**: This is a system API and cannot be called by third-party applications. 1295 1296**Parameters** 1297 1298| Name | Type | Mandatory| Description | 1299| -------- | --------------------- | ---- | -------------------- | 1300| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1301| enable | boolean | Yes | Whether to enable notification. | 1302| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1303 1304**Example** 1305 1306```ts 1307import Base from '@ohos.base'; 1308 1309let displayBadgeCallback = (err: Base.BusinessError) => { 1310 if (err) { 1311 console.info("displayBadge failed " + JSON.stringify(err)); 1312 } else { 1313 console.info("displayBadge success"); 1314 } 1315} 1316let bundle: Notification.BundleOption = { 1317 bundle: "bundleName1", 1318}; 1319Notification.displayBadge(bundle, false, displayBadgeCallback); 1320``` 1321 1322## Notification.displayBadge 1323 1324displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> 1325 1326Sets whether to enable the notification badge for a specified application. This API uses a promise to return the result. 1327 1328**System capability**: SystemCapability.Notification.Notification 1329 1330**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1331 1332**System API**: This is a system API and cannot be called by third-party applications. 1333 1334**Parameters** 1335 1336| Name | Type | Mandatory| Description | 1337| ------ | ------------ | ---- | ---------- | 1338| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1339| enable | boolean | Yes | Whether to enable notification. | 1340 1341**Return value** 1342 1343| Type | Description | 1344| ------- |------------| 1345| Promise\<void\> | Promise that returns no value.| 1346 1347**Example** 1348 1349```ts 1350import Base from '@ohos.base'; 1351 1352let bundle: Notification.BundleOption = { 1353 bundle: "bundleName1", 1354}; 1355Notification.displayBadge(bundle, false).then(() => { 1356 console.info("displayBadge success"); 1357}).catch((err: Base.BusinessError) => { 1358 console.error(`displayBadge failed, code is ${err}`); 1359}); 1360``` 1361 1362## Notification.isBadgeDisplayed 1363 1364isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void 1365 1366Checks whether the notification badge is enabled for a specified application. This API uses an asynchronous callback to return the result. 1367 1368**System capability**: SystemCapability.Notification.Notification 1369 1370**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1371 1372**System API**: This is a system API and cannot be called by third-party applications. 1373 1374**Parameters** 1375 1376| Name | Type | Mandatory| Description | 1377| -------- | --------------------- | ---- | ------------------------ | 1378| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1379| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1380 1381**Example** 1382 1383```ts 1384import Base from '@ohos.base'; 1385 1386let isBadgeDisplayedCallback = (err: Base.BusinessError, data: boolean) => { 1387 if (err) { 1388 console.info("isBadgeDisplayed failed " + JSON.stringify(err)); 1389 } else { 1390 console.info("isBadgeDisplayed success"); 1391 } 1392} 1393let bundle: Notification.BundleOption = { 1394 bundle: "bundleName1", 1395}; 1396Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); 1397``` 1398 1399## Notification.isBadgeDisplayed 1400 1401isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> 1402 1403Checks whether the notification badge is enabled for a specified application. This API uses a promise to return the result. 1404 1405**System capability**: SystemCapability.Notification.Notification 1406 1407**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1408 1409**System API**: This is a system API and cannot be called by third-party applications. 1410 1411**Parameters** 1412 1413| Name | Type | Mandatory| Description | 1414| ------ | ------------ | ---- | ---------- | 1415| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1416 1417**Return value** 1418 1419| Type | Description | 1420| ----------------------------------------------------------- | ------------------------------------------------------------ | 1421| Promise\<boolean\> | Promise used to return the result.| 1422 1423**Example** 1424 1425```ts 1426import Base from '@ohos.base'; 1427 1428let bundle: Notification.BundleOption = { 1429 bundle: "bundleName1", 1430}; 1431Notification.isBadgeDisplayed(bundle).then((data) => { 1432 console.info("isBadgeDisplayed success, data: " + JSON.stringify(data)); 1433}).catch((err: Base.BusinessError) => { 1434 console.error(`isBadgeDisplayed failed, code is ${err}`); 1435}); 1436``` 1437 1438## Notification.setSlotByBundle 1439 1440setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void 1441 1442Sets the notification slot for a specified application. This API uses an asynchronous callback to return the result. 1443 1444**System capability**: SystemCapability.Notification.Notification 1445 1446**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1447 1448**System API**: This is a system API and cannot be called by third-party applications. 1449 1450**Parameters** 1451 1452| Name | Type | Mandatory| Description | 1453| -------- | --------------------- | ---- | -------------------- | 1454| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1455| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot. | 1456| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1457 1458**Example** 1459 1460```ts 1461import Base from '@ohos.base'; 1462import NotificationManager from '@ohos.notificationManager'; 1463 1464let setSlotByBundleCallback = (err: Base.BusinessError) => { 1465 if (err) { 1466 console.info("setSlotByBundle failed " + JSON.stringify(err)); 1467 } else { 1468 console.info("setSlotByBundle success"); 1469 } 1470} 1471let bundle: Notification.BundleOption = { 1472 bundle: "bundleName1", 1473}; 1474let notificationSlot: NotificationManager.NotificationSlot = { 1475 type: Notification.SlotType.SOCIAL_COMMUNICATION 1476}; 1477Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); 1478``` 1479 1480## Notification.setSlotByBundle 1481 1482setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> 1483 1484Sets the notification slot for a specified application. This API uses a promise to return the result. 1485 1486**System capability**: SystemCapability.Notification.Notification 1487 1488**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1489 1490**System API**: This is a system API and cannot be called by third-party applications. 1491 1492**Parameters** 1493 1494| Name | Type | Mandatory| Description | 1495| ------ | ------------ | ---- | ---------- | 1496| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1497| slot | [NotificationSlot](#notificationslot) | Yes | Notification slot.| 1498 1499**Return value** 1500 1501| Type | Description | 1502| ------- |------------| 1503| Promise\<void\> | Promise that returns no value.| 1504 1505**Example** 1506 1507```ts 1508import Base from '@ohos.base'; 1509import NotificationManager from '@ohos.notificationManager'; 1510 1511let bundle: Notification.BundleOption = { 1512 bundle: "bundleName1", 1513}; 1514let notificationSlot: NotificationManager.NotificationSlot = { 1515 type: Notification.SlotType.SOCIAL_COMMUNICATION 1516}; 1517Notification.setSlotByBundle(bundle, notificationSlot).then(() => { 1518 console.info("setSlotByBundle success"); 1519}).catch((err: Base.BusinessError) => { 1520 console.error(`setSlotByBundle failed, code is ${err}`); 1521}); 1522``` 1523 1524## Notification.getSlotsByBundle 1525 1526getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback\<Array\<NotificationSlot>>): void 1527 1528Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result. 1529 1530**System capability**: SystemCapability.Notification.Notification 1531 1532**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1533 1534**System API**: This is a system API and cannot be called by third-party applications. 1535 1536**Parameters** 1537 1538| Name | Type | Mandatory| Description | 1539| -------- | ---------------------------------------- | ---- | -------------------- | 1540| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1541| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes | Callback used to return the result.| 1542 1543**Example** 1544 1545```ts 1546import Base from '@ohos.base'; 1547import NotificationManager from '@ohos.notificationManager'; 1548 1549let getSlotsByBundleCallback = (err: Base.BusinessError, data: NotificationManager.NotificationSlot[]) => { 1550 if (err) { 1551 console.info("getSlotsByBundle failed " + JSON.stringify(err)); 1552 } else { 1553 console.info("getSlotsByBundle success"); 1554 } 1555} 1556let bundle: Notification.BundleOption = { 1557 bundle: "bundleName1", 1558}; 1559Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); 1560``` 1561 1562## Notification.getSlotsByBundle 1563 1564getSlotsByBundle(bundle: BundleOption): Promise\<Array\<NotificationSlot>> 1565 1566Obtains the notification slots of a specified application. This API uses a promise to return the result. 1567 1568**System capability**: SystemCapability.Notification.Notification 1569 1570**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1571 1572**System API**: This is a system API and cannot be called by third-party applications. 1573 1574**Parameters** 1575 1576| Name | Type | Mandatory| Description | 1577| ------ | ------------ | ---- | ---------- | 1578| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1579 1580**Return value** 1581 1582| Type | Description | 1583| ----------------------------------------------------------- | ------------------------------------------------------------ | 1584| Promise\<Array\<[NotificationSlot](#notificationslot)>> | Promise used to return the result.| 1585 1586**Example** 1587 1588```ts 1589import Base from '@ohos.base'; 1590import NotificationManager from '@ohos.notificationManager'; 1591 1592let bundle: Notification.BundleOption = { 1593 bundle: "bundleName1", 1594}; 1595Notification.getSlotsByBundle(bundle).then((data: NotificationManager.NotificationSlot[]) => { 1596 console.info("getSlotsByBundle success, data: " + JSON.stringify(data)); 1597}).catch((err: Base.BusinessError) => { 1598 console.error(`getSlotsByBundle failed, code is ${err}`); 1599}); 1600``` 1601 1602## Notification.getSlotNumByBundle 1603 1604getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void 1605 1606Obtains the number of notification slots of a specified application. This API uses an asynchronous callback to return the result. 1607 1608**System capability**: SystemCapability.Notification.Notification 1609 1610**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1611 1612**System API**: This is a system API and cannot be called by third-party applications. 1613 1614**Parameters** 1615 1616| Name | Type | Mandatory| Description | 1617| -------- | ------------------------- | ---- | ---------------------- | 1618| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1619| callback | AsyncCallback\<number\> | Yes | Callback used to return the result.| 1620 1621**Example** 1622 1623```ts 1624import Base from '@ohos.base'; 1625import NotificationManager from '@ohos.notificationManager'; 1626 1627let getSlotNumByBundleCallback = (err: Base.BusinessError, data: number) => { 1628 if (err) { 1629 console.info("getSlotNumByBundle failed " + JSON.stringify(err)); 1630 } else { 1631 console.info("getSlotNumByBundle success"); 1632 } 1633} 1634let bundle: Notification.BundleOption = { 1635 bundle: "bundleName1", 1636}; 1637Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); 1638``` 1639 1640## Notification.getSlotNumByBundle 1641 1642getSlotNumByBundle(bundle: BundleOption): Promise\<number\> 1643 1644Obtains the number of notification slots of a specified application. This API uses a promise to return the result. 1645 1646**System capability**: SystemCapability.Notification.Notification 1647 1648**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1649 1650**System API**: This is a system API and cannot be called by third-party applications. 1651 1652**Parameters** 1653 1654| Name | Type | Mandatory| Description | 1655| ------ | ------------ | ---- | ---------- | 1656| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1657 1658**Return value** 1659 1660| Type | Description | 1661| ----------------------------------------------------------- | ------------------------------------------------------------ | 1662| Promise\<number\> | Promise used to return the result.| 1663 1664**Example** 1665 1666```ts 1667import Base from '@ohos.base'; 1668import NotificationManager from '@ohos.notificationManager'; 1669 1670let bundle: Notification.BundleOption = { 1671 bundle: "bundleName1", 1672}; 1673Notification.getSlotNumByBundle(bundle).then((data: number) => { 1674 console.info("getSlotNumByBundle success, data: " + JSON.stringify(data)); 1675}).catch((err: Base.BusinessError) => { 1676 console.error(`getSlotNumByBundle failed, code is ${err}`); 1677}); 1678``` 1679 1680## Notification.remove 1681 1682remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void 1683 1684Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result. 1685 1686**System capability**: SystemCapability.Notification.Notification 1687 1688**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1689 1690**System API**: This is a system API and cannot be called by third-party applications. 1691 1692**Parameters** 1693 1694| Name | Type | Mandatory| Description | 1695| --------------- | ----------------------------------| ---- | -------------------- | 1696| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1697| notificationKey | [NotificationKey](#notificationkeydeprecated) | Yes | Notification key. | 1698| reason | [RemoveReason](#removereason-deprecated) | Yes | Reason for deleting a notification. | 1699| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1700 1701**Example** 1702 1703```ts 1704import Base from '@ohos.base'; 1705 1706let removeCallback = (err: Base.BusinessError) => { 1707 if (err) { 1708 console.info("remove failed " + JSON.stringify(err)); 1709 } else { 1710 console.info("remove success"); 1711 } 1712} 1713let bundle: Notification.BundleOption = { 1714 bundle: "bundleName1", 1715}; 1716let notificationKey: Notification.NotificationKey = { 1717 id: 0, 1718 label: "label", 1719}; 1720let reason: Notification.RemoveReason = Notification.RemoveReason.CLICK_REASON_REMOVE; 1721Notification.remove(bundle, notificationKey, reason, removeCallback); 1722``` 1723 1724## Notification.remove 1725 1726remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason): Promise\<void\> 1727 1728Removes a notification for a specified bundle. This API uses a promise to return the result. 1729 1730**System capability**: SystemCapability.Notification.Notification 1731 1732**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1733 1734**System API**: This is a system API and cannot be called by third-party applications. 1735 1736**Parameters** 1737 1738| Name | Type | Mandatory| Description | 1739| --------------- | --------------- | ---- | ---------- | 1740| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application.| 1741| notificationKey | [NotificationKey](#notificationkeydeprecated) | Yes | Notification key. | 1742| reason | [RemoveReason](#removereason-deprecated) | Yes | Reason for deleting the notification. | 1743 1744**Return value** 1745 1746| Type | Description | 1747| ------- |------------| 1748| Promise\<void\> | Promise that returns no value.| 1749 1750**Example** 1751 1752```ts 1753import Base from '@ohos.base'; 1754 1755let bundle: Notification.BundleOption = { 1756 bundle: "bundleName1", 1757}; 1758let notificationKey: Notification.NotificationKey = { 1759 id: 0, 1760 label: "label", 1761}; 1762let reason: Notification.RemoveReason = Notification.RemoveReason.CLICK_REASON_REMOVE; 1763Notification.remove(bundle, notificationKey, reason).then(() => { 1764 console.info("remove success"); 1765}).catch((err: Base.BusinessError) => { 1766 console.error(`remove failed, code is ${err}`); 1767}); 1768``` 1769 1770## Notification.remove 1771 1772remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void 1773 1774Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result. 1775 1776**System capability**: SystemCapability.Notification.Notification 1777 1778**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1779 1780**System API**: This is a system API and cannot be called by third-party applications. 1781 1782**Parameters** 1783 1784| Name | Type | Mandatory| Description | 1785| -------- | --------------------- | ---- | -------------------- | 1786| hashCode | string | Yes | Unique notification ID. It is the **hashCode** in the [NotificationRequest](#notificationrequest) object of [SubscribeCallbackData](#subscribecallbackdata) of the [onConsume](js-apis-inner-notification-notificationSubscriber.md#onconsume) callback.| 1787| reason | [RemoveReason](#removereason-deprecated) | Yes | Reason for deleting a notification. | 1788| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1789 1790**Example** 1791 1792```ts 1793import Base from '@ohos.base'; 1794 1795let hashCode: string = 'hashCode'; 1796 1797let removeCallback = (err: Base.BusinessError) => { 1798 if (err) { 1799 console.info("remove failed " + JSON.stringify(err)); 1800 } else { 1801 console.info("remove success"); 1802 } 1803} 1804let reason: Notification.RemoveReason = Notification.RemoveReason.CANCEL_REASON_REMOVE; 1805Notification.remove(hashCode, reason, removeCallback); 1806``` 1807 1808## Notification.remove 1809 1810remove(hashCode: string, reason: RemoveReason): Promise\<void\> 1811 1812Removes a notification for a specified bundle. This API uses a promise to return the result. 1813 1814**System capability**: SystemCapability.Notification.Notification 1815 1816**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1817 1818**System API**: This is a system API and cannot be called by third-party applications. 1819 1820**Parameters** 1821 1822| Name | Type | Mandatory| Description | 1823| -------- | ---------- | ---- | ---------- | 1824| hashCode | string | Yes | Unique notification ID.| 1825| reason | [RemoveReason](#removereason-deprecated) | Yes | Reason for deleting the notification. | 1826 1827**Return value** 1828 1829| Type | Description | 1830| ------- |------------| 1831| Promise\<void\> | Promise that returns no value.| 1832 1833**Example** 1834 1835```ts 1836import Base from '@ohos.base'; 1837 1838let hashCode: string = 'hashCode'; 1839let reason: Notification.RemoveReason = Notification.RemoveReason.CLICK_REASON_REMOVE; 1840Notification.remove(hashCode, reason).then(() => { 1841 console.info("remove success"); 1842}).catch((err: Base.BusinessError) => { 1843 console.error(`remove failed, code is ${err}`); 1844}); 1845``` 1846 1847## Notification.removeAll 1848 1849removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void 1850 1851Removes all notifications for a specified application. This API uses an asynchronous callback to return the result. 1852 1853**System capability**: SystemCapability.Notification.Notification 1854 1855**System API**: This is a system API and cannot be called by third-party applications. 1856 1857**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1858 1859**Parameters** 1860 1861| Name | Type | Mandatory| Description | 1862| -------- | --------------------- | ---- | ---------------------------- | 1863| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 1864| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1865 1866**Example** 1867 1868```ts 1869import Base from '@ohos.base'; 1870 1871let removeAllCallback = (err: Base.BusinessError) => { 1872 if (err) { 1873 console.info("removeAll failed " + JSON.stringify(err)); 1874 } else { 1875 console.info("removeAll success"); 1876 } 1877} 1878let bundle: Notification.BundleOption = { 1879 bundle: "bundleName1", 1880}; 1881Notification.removeAll(bundle, removeAllCallback); 1882``` 1883 1884## Notification.removeAll 1885 1886removeAll(callback: AsyncCallback\<void\>): void 1887 1888Removes all notifications. This API uses an asynchronous callback to return the result. 1889 1890**System capability**: SystemCapability.Notification.Notification 1891 1892**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1893 1894**System API**: This is a system API and cannot be called by third-party applications. 1895 1896**Parameters** 1897 1898| Name | Type | Mandatory| Description | 1899| -------- | --------------------- | ---- | -------------------- | 1900| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1901 1902**Example** 1903 1904```ts 1905import Base from '@ohos.base'; 1906 1907let removeAllCallback = (err: Base.BusinessError) => { 1908 if (err) { 1909 console.info("removeAll failed " + JSON.stringify(err)); 1910 } else { 1911 console.info("removeAll success"); 1912 } 1913} 1914 1915Notification.removeAll(removeAllCallback); 1916``` 1917 1918## Notification.removeAll 1919 1920removeAll(bundle?: BundleOption): Promise\<void\> 1921 1922Removes all notifications for a specified application. This API uses a promise to return the result. 1923 1924**System capability**: SystemCapability.Notification.Notification 1925 1926**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1927 1928**System API**: This is a system API and cannot be called by third-party applications. 1929 1930**Parameters** 1931 1932| Name | Type | Mandatory| Description | 1933| ------ | ------------ | ---- | ---------- | 1934| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | No | Bundle information of the application. By default, this parameter is left empty, indicating that all notifications will be removed.| 1935 1936**Return value** 1937 1938| Type | Description | 1939| ------- |------------| 1940| Promise\<void\> | Promise that returns no value.| 1941 1942**Example** 1943 1944```ts 1945import Base from '@ohos.base'; 1946 1947// If no application is specified, notifications of all applications are deleted. 1948Notification.removeAll().then(() => { 1949 console.info("removeAll success"); 1950}).catch((err: Base.BusinessError) => { 1951 ar 1952}); 1953``` 1954 1955## Notification.removeAll<sup>8+</sup> 1956 1957removeAll(userId: number, callback: AsyncCallback\<void>): void 1958 1959Removes all notifications for a specified user. This API uses an asynchronous callback to return the result. 1960 1961**System capability**: SystemCapability.Notification.Notification 1962 1963**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 1964 1965**System API**: This is a system API and cannot be called by third-party applications. 1966 1967**Parameters** 1968 1969| Name | Type | Mandatory| Description | 1970| ------ | ------------ | ---- | ---------- | 1971| userId | number | Yes | User ID.| 1972| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 1973 1974**Example** 1975 1976```ts 1977import Base from '@ohos.base'; 1978 1979function removeAllCallback(err: Base.BusinessError) { 1980 if (err) { 1981 console.info("removeAll failed " + JSON.stringify(err)); 1982 } else { 1983 console.info("removeAll success"); 1984 } 1985} 1986 1987let userId: number = 1; 1988Notification.removeAll(userId, removeAllCallback); 1989``` 1990 1991## Notification.removeAll<sup>8+</sup> 1992 1993removeAll(userId: number): Promise\<void> 1994 1995Removes all notifications for a specified user. This API uses a promise to return the result. 1996 1997**System capability**: SystemCapability.Notification.Notification 1998 1999**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2000 2001**System API**: This is a system API and cannot be called by third-party applications. 2002 2003**Parameters** 2004 2005| Name | Type | Mandatory| Description | 2006| ------ | ------------ | ---- | ---------- | 2007| userId | number | Yes | User ID.| 2008 2009**Example** 2010 2011```ts 2012import Base from '@ohos.base'; 2013 2014let userId: number = 1; 2015Notification.removeAll(userId).then(() => { 2016 console.info("removeAll success"); 2017}).catch((err: Base.BusinessError) => { 2018 ar 2019}); 2020``` 2021 2022 2023## Notification.getAllActiveNotifications 2024 2025getAllActiveNotifications(callback: AsyncCallback\<Array\<NotificationRequest>>): void 2026 2027Obtains all active notifications. This API uses an asynchronous callback to return the result. 2028 2029**System capability**: SystemCapability.Notification.Notification 2030 2031**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2032 2033**System API**: This is a system API and cannot be called by third-party applications. 2034 2035**Parameters** 2036 2037| Name | Type | Mandatory| Description | 2038| -------- | ------------------------------------------------------------ | ---- | -------------------- | 2039| callback | AsyncCallback\<Array\<[NotificationRequest](#notificationrequest)>> | Yes | Callback used to return the result.| 2040 2041**Example** 2042 2043```ts 2044import Base from '@ohos.base'; 2045import NotificationManager from '@ohos.notificationManager'; 2046 2047function getAllActiveNotificationsCallback(err: Base.BusinessError, data: NotificationManager.NotificationRequest[]) { 2048 if (err) { 2049 console.info("getAllActiveNotifications failed " + JSON.stringify(err)); 2050 } else { 2051 console.info("getAllActiveNotifications success"); 2052 } 2053} 2054 2055Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); 2056``` 2057 2058## Notification.getAllActiveNotifications 2059 2060getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)>> 2061 2062Obtains all active notifications. This API uses a promise to return the result. 2063 2064**System capability**: SystemCapability.Notification.Notification 2065 2066**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2067 2068**System API**: This is a system API and cannot be called by third-party applications. 2069 2070**Return value** 2071 2072| Type | Description | 2073| ----------------------------------------------------------- | ------------------------------------------------------------ | 2074| Promise\<Array\<[NotificationRequest](#notificationrequest)>> | Promise used to return the result.| 2075 2076**Example** 2077 2078```ts 2079import Base from '@ohos.base'; 2080import NotificationManager from '@ohos.notificationManager'; 2081 2082Notification.getAllActiveNotifications().then((data: NotificationManager.NotificationRequest[]) => { 2083 console.info("getAllActiveNotifications success, data: " + JSON.stringify(data)); 2084}).catch((err: Base.BusinessError) => { 2085 console.error(`getAllActiveNotifications failed, code is ${err}`); 2086}); 2087``` 2088 2089## Notification.getActiveNotificationCount 2090 2091getActiveNotificationCount(callback: AsyncCallback\<number\>): void 2092 2093Obtains the number of active notifications of this application. This API uses an asynchronous callback to return the result. 2094 2095**System capability**: SystemCapability.Notification.Notification 2096 2097**Parameters** 2098 2099| Name | Type | Mandatory| Description | 2100| -------- | ---------------------- | ---- | ---------------------- | 2101| callback | AsyncCallback\<number\> | Yes | Callback used to return the result.| 2102 2103**Example** 2104 2105```ts 2106import Base from '@ohos.base'; 2107 2108let getActiveNotificationCountCallback = (err: Base.BusinessError, data: number) => { 2109 if (err) { 2110 console.info("getActiveNotificationCount failed " + JSON.stringify(err)); 2111 } else { 2112 console.info("getActiveNotificationCount success"); 2113 } 2114} 2115 2116Notification.getActiveNotificationCount(getActiveNotificationCountCallback); 2117``` 2118 2119## Notification.getActiveNotificationCount 2120 2121getActiveNotificationCount(): Promise\<number\> 2122 2123Obtains the number of active notifications of this application. This API uses a promise to return the result. 2124 2125**System capability**: SystemCapability.Notification.Notification 2126 2127**Return value** 2128 2129| Type | Description | 2130| ----------------- | ------------------------------------------- | 2131| Promise\<number\> | Promise used to return the result.| 2132 2133**Example** 2134 2135```ts 2136import Base from '@ohos.base'; 2137 2138Notification.getActiveNotificationCount().then((data: number) => { 2139 console.info("getActiveNotificationCount success, data: " + JSON.stringify(data)); 2140}).catch((err: Base.BusinessError) => { 2141 console.error(`getAllActiveNotifications failed, code is ${err}`); 2142}); 2143``` 2144 2145## Notification.getActiveNotifications 2146 2147getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void 2148 2149Obtains active notifications of this application. This API uses an asynchronous callback to return the result. 2150 2151**System capability**: SystemCapability.Notification.Notification 2152 2153**Parameters** 2154 2155| Name | Type | Mandatory| Description | 2156| -------- | ------------------------------------------------------------ | ---- | ------------------------------ | 2157| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes | Callback used to return the result.| 2158 2159**Example** 2160 2161```ts 2162import Base from '@ohos.base'; 2163import NotificationManager from '@ohos.notificationManager'; 2164 2165let getActiveNotificationsCallback = (err: Base.BusinessError, data: NotificationManager.NotificationRequest[]) => { 2166 if (err) { 2167 console.info("getActiveNotifications failed " + JSON.stringify(err)); 2168 } else { 2169 console.info("getActiveNotifications success"); 2170 } 2171} 2172 2173Notification.getActiveNotifications(getActiveNotificationsCallback); 2174``` 2175 2176## Notification.getActiveNotifications 2177 2178getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> 2179 2180Obtains active notifications of this application. This API uses a promise to return the result. 2181 2182**System capability**: SystemCapability.Notification.Notification 2183 2184**Return value** 2185 2186| Type | Description | 2187| ------------------------------------------------------------ | --------------------------------------- | 2188| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.| 2189 2190**Example** 2191 2192```ts 2193import Base from '@ohos.base'; 2194import NotificationManager from '@ohos.notificationManager'; 2195 2196Notification.getActiveNotifications().then((data: NotificationManager.NotificationRequest[]) => { 2197 console.info("removeGroupByBundle success, data: " + JSON.stringify(data)); 2198}).catch((err: Base.BusinessError) => { 2199 console.error(`removeGroupByBundle failed, code is ${err}`); 2200}); 2201``` 2202 2203## Notification.cancelGroup<sup>8+</sup> 2204 2205cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void 2206 2207Cancels notifications under a notification group of this application. This API uses an asynchronous callback to return the result. 2208 2209**System capability**: SystemCapability.Notification.Notification 2210 2211**Parameters** 2212 2213| Name | Type | Mandatory| Description | 2214| --------- | --------------------- | ---- | ---------------------------- | 2215| groupName | string | Yes | Name of the notification group, which is specified through [NotificationRequest](#notificationrequest) when the notification is published.| 2216| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2217 2218**Example** 2219 2220```ts 2221import Base from '@ohos.base'; 2222 2223let cancelGroupCallback = (err: Base.BusinessError) => { 2224 if (err) { 2225 console.info("cancelGroup failed " + JSON.stringify(err)); 2226 } else { 2227 console.info("cancelGroup success"); 2228 } 2229} 2230 2231let groupName: string = "GroupName"; 2232 2233Notification.cancelGroup(groupName, cancelGroupCallback); 2234``` 2235 2236## Notification.cancelGroup<sup>8+</sup> 2237 2238cancelGroup(groupName: string): Promise\<void\> 2239 2240Cancels notifications under a notification group of this application. This API uses a promise to return the result. 2241 2242**System capability**: SystemCapability.Notification.Notification 2243 2244**Parameters** 2245 2246| Name | Type | Mandatory| Description | 2247| --------- | ------ | ---- | -------------- | 2248| groupName | string | Yes | Name of the notification group.| 2249 2250**Return value** 2251 2252| Type | Description | 2253| ------- |------------| 2254| Promise\<void\> | Promise that returns no value.| 2255 2256**Example** 2257 2258```ts 2259import Base from '@ohos.base'; 2260 2261let groupName: string = "GroupName"; 2262Notification.cancelGroup(groupName).then(() => { 2263 console.info("cancelGroup success"); 2264}).catch((err: Base.BusinessError) => { 2265 console.error(`cancelGroup failed, code is ${err}`); 2266}); 2267``` 2268 2269## Notification.removeGroupByBundle<sup>8+</sup> 2270 2271removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void 2272 2273Removes notifications under a notification group of a specified application. This API uses an asynchronous callback to return the result. 2274 2275**System capability**: SystemCapability.Notification.Notification 2276 2277**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2278 2279**System API**: This is a system API and cannot be called by third-party applications. 2280 2281**Parameters** 2282 2283| Name | Type | Mandatory| Description | 2284| --------- | --------------------- | ---- | ---------------------------- | 2285| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 2286| groupName | string | Yes | Name of the notification group. | 2287| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2288 2289**Example** 2290 2291```ts 2292import Base from '@ohos.base'; 2293 2294let removeGroupByBundleCallback = (err: Base.BusinessError) => { 2295 if (err) { 2296 console.info("removeGroupByBundle failed " + JSON.stringify(err)); 2297 } else { 2298 console.info("removeGroupByBundle success"); 2299 } 2300} 2301 2302let bundleOption: Notification.BundleOption = {bundle: "Bundle"}; 2303let groupName: string = "GroupName"; 2304 2305Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); 2306``` 2307 2308## Notification.removeGroupByBundle<sup>8+</sup> 2309 2310removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> 2311 2312Removes notifications under a notification group of a specified application. This API uses a promise to return the result. 2313 2314**System capability**: SystemCapability.Notification.Notification 2315 2316**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2317 2318**System API**: This is a system API and cannot be called by third-party applications. 2319 2320**Parameters** 2321 2322| Name | Type | Mandatory| Description | 2323| --------- | ------------ | ---- | -------------- | 2324| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 2325| groupName | string | Yes | Name of the notification group.| 2326 2327**Return value** 2328 2329| Type | Description | 2330| ------- |------------| 2331| Promise\<void\> | Promise that returns no value.| 2332 2333**Example** 2334 2335```ts 2336import Base from '@ohos.base'; 2337 2338let bundleOption: Notification.BundleOption = {bundle: "Bundle"}; 2339let groupName: string = "GroupName"; 2340Notification.removeGroupByBundle(bundleOption, groupName).then(() => { 2341 console.info("removeGroupByBundle success"); 2342}).catch((err: Base.BusinessError) => { 2343 console.error(`removeGroupByBundle failed, code is ${err}`); 2344}); 2345``` 2346 2347## Notification.setDoNotDisturbDate<sup>8+</sup> 2348 2349setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void 2350 2351Sets the DND time. This API uses an asynchronous callback to return the result. 2352 2353**System capability**: SystemCapability.Notification.Notification 2354 2355**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2356 2357**System API**: This is a system API and cannot be called by third-party applications. 2358 2359**Parameters** 2360 2361| Name | Type | Mandatory| Description | 2362| -------- | --------------------- | ---- | ---------------------- | 2363| date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set. | 2364| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2365 2366**Example** 2367 2368```ts 2369import Base from '@ohos.base'; 2370 2371let setDoNotDisturbDateCallback = (err: Base.BusinessError) => { 2372 if (err) { 2373 console.info("setDoNotDisturbDate failed " + JSON.stringify(err)); 2374 } else { 2375 console.info("setDoNotDisturbDate success"); 2376 } 2377} 2378 2379let doNotDisturbDate: Notification.DoNotDisturbDate = { 2380 type: Notification.DoNotDisturbType.TYPE_ONCE, 2381 begin: new Date(), 2382 end: new Date(2021, 11, 15, 18, 0) 2383}; 2384 2385Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); 2386``` 2387 2388## Notification.setDoNotDisturbDate<sup>8+</sup> 2389 2390setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> 2391 2392Sets the DND time. This API uses a promise to return the result. 2393 2394**System capability**: SystemCapability.Notification.Notification 2395 2396**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2397 2398**System API**: This is a system API and cannot be called by third-party applications. 2399 2400**Parameters** 2401 2402| Name| Type | Mandatory| Description | 2403| ---- | ---------------- | ---- | -------------- | 2404| date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set.| 2405 2406**Return value** 2407 2408| Type | Description | 2409| ------- |------------| 2410| Promise\<void\> | Promise that returns no value.| 2411 2412**Example** 2413 2414```ts 2415import Base from '@ohos.base'; 2416 2417let doNotDisturbDate: Notification.DoNotDisturbDate = { 2418 type: Notification.DoNotDisturbType.TYPE_ONCE, 2419 begin: new Date(), 2420 end: new Date(2021, 11, 15, 18, 0) 2421}; 2422Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { 2423 console.info("setDoNotDisturbDate success"); 2424}).catch((err: Base.BusinessError) => { 2425 console.error(`setDoNotDisturbDate failed, code is ${err}`); 2426}); 2427``` 2428 2429 2430## Notification.setDoNotDisturbDate<sup>8+</sup> 2431 2432setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void 2433 2434Sets the DND time for a specified user. This API uses an asynchronous callback to return the result. 2435 2436**System capability**: SystemCapability.Notification.Notification 2437 2438**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2439 2440**System API**: This is a system API and cannot be called by third-party applications. 2441 2442**Parameters** 2443 2444| Name | Type | Mandatory| Description | 2445| -------- | --------------------- | ---- | ---------------------- | 2446| date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set. | 2447| userId | number | Yes | ID of the user for whom you want to set the DND time.| 2448| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2449 2450**Example** 2451 2452```ts 2453import Base from '@ohos.base'; 2454 2455let setDoNotDisturbDateCallback = (err: Base.BusinessError) => { 2456 if (err) { 2457 console.info("setDoNotDisturbDate failed " + JSON.stringify(err)); 2458 } else { 2459 console.info("setDoNotDisturbDate success"); 2460 } 2461} 2462 2463let doNotDisturbDate: Notification.DoNotDisturbDate = { 2464 type: Notification.DoNotDisturbType.TYPE_ONCE, 2465 begin: new Date(), 2466 end: new Date(2021, 11, 15, 18, 0) 2467}; 2468 2469let userId: number = 1; 2470Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); 2471``` 2472 2473## Notification.setDoNotDisturbDate<sup>8+</sup> 2474 2475setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> 2476 2477Sets the DND time for a specified user. This API uses a promise to return the result. 2478 2479**System capability**: SystemCapability.Notification.Notification 2480 2481**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2482 2483**System API**: This is a system API and cannot be called by third-party applications. 2484 2485**Parameters** 2486 2487| Name | Type | Mandatory| Description | 2488| ------ | ---------------- | ---- | -------------- | 2489| date | [DoNotDisturbDate](#donotdisturbdate8-deprecated) | Yes | DND time to set.| 2490| userId | number | Yes | ID of the user for whom you want to set the DND time.| 2491 2492**Return value** 2493 2494| Type | Description | 2495| ------- |------------| 2496| Promise\<void\> | Promise that returns no value.| 2497 2498**Example** 2499 2500```ts 2501import Base from '@ohos.base'; 2502 2503let doNotDisturbDate: Notification.DoNotDisturbDate = { 2504 type: Notification.DoNotDisturbType.TYPE_ONCE, 2505 begin: new Date(), 2506 end: new Date(2021, 11, 15, 18, 0) 2507}; 2508 2509let userId: number = 1; 2510 2511Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { 2512 console.info("setDoNotDisturbDate success"); 2513}).catch((err: Base.BusinessError) => { 2514 console.error(`setDoNotDisturbDate failed, code is ${err}`); 2515}); 2516``` 2517 2518 2519## Notification.getDoNotDisturbDate<sup>8+</sup> 2520 2521getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void 2522 2523Obtains the DND time. This API uses an asynchronous callback to return the result. 2524 2525**System capability**: SystemCapability.Notification.Notification 2526 2527**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2528 2529**System API**: This is a system API and cannot be called by third-party applications. 2530 2531**Parameters** 2532 2533| Name | Type | Mandatory| Description | 2534| -------- | --------------------------------- | ---- | ---------------------- | 2535| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Yes | Callback used to return the result.| 2536 2537**Example** 2538 2539```ts 2540import Base from '@ohos.base'; 2541 2542let getDoNotDisturbDateCallback = (err: Base.BusinessError, data: Notification.DoNotDisturbDate) => { 2543 if (err) { 2544 console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); 2545 } else { 2546 console.info("getDoNotDisturbDate success"); 2547 } 2548} 2549 2550Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); 2551``` 2552 2553## Notification.getDoNotDisturbDate<sup>8+</sup> 2554 2555getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> 2556 2557Obtains the DND time. This API uses a promise to return the result. 2558 2559**System capability**: SystemCapability.Notification.Notification 2560 2561**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2562 2563**System API**: This is a system API and cannot be called by third-party applications. 2564 2565**Return value** 2566 2567| Type | Description | 2568| ------------------------------------------------- | ----------------------------------------- | 2569| Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.| 2570 2571**Example** 2572 2573```ts 2574import Base from '@ohos.base'; 2575 2576Notification.getDoNotDisturbDate().then((data: Notification.DoNotDisturbDate) => { 2577 console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); 2578}).catch((err: Base.BusinessError) => { 2579 console.error(`getDoNotDisturbDate failed, code is ${err}`); 2580}); 2581``` 2582 2583 2584## Notification.getDoNotDisturbDate<sup>8+</sup> 2585 2586getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void 2587 2588Obtains the DND time of a specified user. This API uses an asynchronous callback to return the result. 2589 2590**System capability**: SystemCapability.Notification.Notification 2591 2592**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2593 2594**System API**: This is a system API and cannot be called by third-party applications. 2595 2596**Parameters** 2597 2598| Name | Type | Mandatory| Description | 2599| -------- | --------------------------------- | ---- | ---------------------- | 2600| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Yes | Callback used to return the result.| 2601| userId | number | Yes | User ID.| 2602 2603**Example** 2604 2605```ts 2606import Base from '@ohos.base'; 2607 2608let getDoNotDisturbDateCallback = (err: Base.BusinessError, data: Notification.DoNotDisturbDate) => { 2609 if (err) { 2610 console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); 2611 } else { 2612 console.info("getDoNotDisturbDate success"); 2613 } 2614} 2615 2616let userId: number = 1; 2617 2618Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); 2619``` 2620 2621## Notification.getDoNotDisturbDate<sup>8+</sup> 2622 2623getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> 2624 2625Obtains the DND time of a specified user. This API uses a promise to return the result. 2626 2627**System capability**: SystemCapability.Notification.Notification 2628 2629**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2630 2631**System API**: This is a system API and cannot be called by third-party applications. 2632 2633**Parameters** 2634 2635| Name | Type | Mandatory| Description | 2636| -------- | --------------------------------- | ---- | ---------------------- | 2637| userId | number | Yes | User ID.| 2638 2639**Return value** 2640 2641| Type | Description | 2642| ------------------------------------------------- | ----------------------------------------- | 2643| Promise\<[DoNotDisturbDate](#donotdisturbdate8-deprecated)\> | Promise used to return the result.| 2644 2645**Example** 2646 2647```ts 2648import Base from '@ohos.base'; 2649 2650let userId: number = 1; 2651 2652Notification.getDoNotDisturbDate(userId).then((data: Notification.DoNotDisturbDate) => { 2653 console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); 2654}).catch((err: Base.BusinessError) => { 2655 console.error(`getDoNotDisturbDate failed, code is ${err}`); 2656}); 2657``` 2658 2659 2660## Notification.supportDoNotDisturbMode<sup>8+</sup> 2661 2662supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void 2663 2664Checks whether DND mode is supported. This API uses an asynchronous callback to return the result. 2665 2666**System capability**: SystemCapability.Notification.Notification 2667 2668**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2669 2670**System API**: This is a system API and cannot be called by third-party applications. 2671 2672**Parameters** 2673 2674| Name | Type | Mandatory| Description | 2675| -------- | ------------------------ | ---- | -------------------------------- | 2676| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| 2677 2678**Example** 2679 2680```ts 2681import Base from '@ohos.base'; 2682 2683let supportDoNotDisturbModeCallback = (err: Base.BusinessError, data: boolean) => { 2684 if (err) { 2685 console.info("supportDoNotDisturbMode failed " + JSON.stringify(err)); 2686 } else { 2687 console.info("supportDoNotDisturbMode success"); 2688 } 2689} 2690 2691Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); 2692``` 2693 2694## Notification.supportDoNotDisturbMode<sup>8+</sup> 2695 2696supportDoNotDisturbMode(): Promise\<boolean\> 2697 2698Checks whether DND mode is supported. This API uses a promise to return the result. 2699 2700**System capability**: SystemCapability.Notification.Notification 2701 2702**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2703 2704**System API**: This is a system API and cannot be called by third-party applications. 2705 2706**Return value** 2707 2708| Type | Description | 2709| ----------------------------------------------------------- | ------------------------------------------------------------ | 2710| Promise\<boolean\> | Promise used to return the result.| 2711 2712**Example** 2713 2714```ts 2715import Base from '@ohos.base'; 2716 2717Notification.supportDoNotDisturbMode().then((data: boolean) => { 2718 console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data)); 2719}).catch((err: Base.BusinessError) => { 2720 console.error(`supportDoNotDisturbMode failed, code is ${err}`); 2721}); 2722``` 2723 2724## Notification.isSupportTemplate<sup>8+</sup> 2725 2726isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void 2727 2728Checks whether a specified template exists. This API uses an asynchronous callback to return the result. 2729 2730**System capability**: SystemCapability.Notification.Notification 2731 2732**Parameters** 2733 2734| Name | Type | Mandatory| Description | 2735| ------------ | ------------------------ | ---- | -------------------------- | 2736| templateName | string | Yes | Template name. | 2737| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| 2738 2739**Example** 2740 2741```ts 2742import Base from '@ohos.base'; 2743 2744let templateName: string = 'process'; 2745function isSupportTemplateCallback(err: Base.BusinessError, data: boolean) { 2746 if (err) { 2747 console.info("isSupportTemplate failed " + JSON.stringify(err)); 2748 } else { 2749 console.info("isSupportTemplate success"); 2750 } 2751} 2752 2753Notification.isSupportTemplate(templateName, isSupportTemplateCallback); 2754``` 2755 2756## Notification.isSupportTemplate<sup>8+</sup> 2757 2758isSupportTemplate(templateName: string): Promise\<boolean\> 2759 2760Checks whether a specified template exists. This API uses a promise to return the result. 2761 2762**System capability**: SystemCapability.Notification.Notification 2763 2764**Parameters** 2765 2766| Name | Type | Mandatory| Description | 2767| ------------ | ------ | ---- | -------- | 2768| templateName | string | Yes | Template name.| 2769 2770**Return value** 2771 2772| Type | Description | 2773| ------------------ | --------------- | 2774| Promise\<boolean\> | Promise used to return the result.| 2775 2776**Example** 2777 2778```ts 2779import Base from '@ohos.base'; 2780 2781let templateName: string = 'process'; 2782Notification.isSupportTemplate(templateName).then((data: boolean) => { 2783 console.info("isSupportTemplate success, data: " + JSON.stringify(data)); 2784}).catch((err: Base.BusinessError) => { 2785 console.error(`isSupportTemplate failed, code is ${err}`); 2786}); 2787``` 2788 2789## Notification.requestEnableNotification<sup>8+</sup> 2790 2791requestEnableNotification(callback: AsyncCallback\<void\>): void 2792 2793Requests notification to be enabled for this application. This API uses an asynchronous callback to return the result. 2794 2795**System capability**: SystemCapability.Notification.Notification 2796 2797**Parameters** 2798 2799| Name | Type | Mandatory| Description | 2800| -------- | ------------------------ | ---- | -------------------------- | 2801| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2802 2803**Example** 2804 2805```ts 2806import Base from '@ohos.base'; 2807 2808let requestEnableNotificationCallback = (err: Base.BusinessError) => { 2809 if (err) { 2810 console.info("requestEnableNotification failed " + JSON.stringify(err)); 2811 } else { 2812 console.info("requestEnableNotification success"); 2813 } 2814}; 2815 2816Notification.requestEnableNotification(requestEnableNotificationCallback); 2817``` 2818 2819## Notification.requestEnableNotification<sup>8+</sup> 2820 2821requestEnableNotification(): Promise\<void\> 2822 2823Requests notification to be enabled for this application. This API uses a promise to return the result. 2824 2825**System capability**: SystemCapability.Notification.Notification 2826 2827**Return value** 2828 2829| Type | Description | 2830| ------- |------------| 2831| Promise\<void\> | Promise that returns no value.| 2832 2833**Example** 2834 2835```ts 2836import Base from '@ohos.base'; 2837 2838Notification.requestEnableNotification().then(() => { 2839 console.info("requestEnableNotification success"); 2840}).catch((err: Base.BusinessError) => { 2841 console.error(`requestEnableNotification failed, code is ${err}`); 2842}); 2843``` 2844 2845 2846## Notification.enableDistributed<sup>8+</sup> 2847 2848enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void 2849 2850Sets whether this device supports distributed notifications. This API uses an asynchronous callback to return the result. 2851 2852**System capability**: SystemCapability.Notification.Notification 2853 2854**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2855 2856**System API**: This is a system API and cannot be called by third-party applications. 2857 2858**Parameters** 2859 2860| Name | Type | Mandatory| Description | 2861| -------- | ------------------------ | ---- | -------------------------- | 2862| enable | boolean | Yes | Whether the device supports distributed notifications.| 2863| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2864 2865**Example** 2866 2867```ts 2868import Base from '@ohos.base'; 2869 2870let enabledNotificationCallback = (err: Base.BusinessError) => { 2871 if (err) { 2872 console.info("enableDistributed failed " + JSON.stringify(err)); 2873 } else { 2874 console.info("enableDistributed success"); 2875 } 2876}; 2877 2878let enable: boolean = true; 2879 2880Notification.enableDistributed(enable, enabledNotificationCallback); 2881``` 2882 2883## Notification.enableDistributed<sup>8+</sup> 2884 2885enableDistributed(enable: boolean): Promise\<void> 2886 2887Sets whether this device supports distributed notifications. This API uses a promise to return the result. 2888 2889**System capability**: SystemCapability.Notification.Notification 2890 2891**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2892 2893**System API**: This is a system API and cannot be called by third-party applications. 2894 2895**Parameters** 2896 2897| Name | Type | Mandatory| Description | 2898| -------- | ------------------------ | ---- | -------------------------- | 2899| enable | boolean | Yes | Whether the device supports distributed notifications.| 2900 2901**Example** 2902 2903```ts 2904import Base from '@ohos.base'; 2905 2906let enable: boolean = true; 2907Notification.enableDistributed(enable).then(() => { 2908 console.info("enableDistributed success"); 2909}).catch((err: Base.BusinessError) => { 2910 console.error(`enableDistributed failed, code is ${err}`); 2911}); 2912``` 2913 2914 2915## Notification.isDistributedEnabled<sup>8+</sup> 2916 2917isDistributedEnabled(callback: AsyncCallback\<boolean>): void 2918 2919Checks whether this device supports distributed notifications. This API uses an asynchronous callback to return the result. 2920 2921**System capability**: SystemCapability.Notification.Notification 2922 2923**Parameters** 2924 2925| Name | Type | Mandatory| Description | 2926| -------- | ------------------------ | ---- | -------------------------- | 2927| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| 2928 2929**Example** 2930 2931```ts 2932import Base from '@ohos.base'; 2933 2934let isDistributedEnabledCallback = (err: Base.BusinessError, data: boolean) => { 2935 if (err) { 2936 console.info("isDistributedEnabled failed " + JSON.stringify(err)); 2937 } else { 2938 console.info("isDistributedEnabled success " + JSON.stringify(data)); 2939 } 2940}; 2941 2942Notification.isDistributedEnabled(isDistributedEnabledCallback); 2943``` 2944 2945## Notification.isDistributedEnabled<sup>8+</sup> 2946 2947isDistributedEnabled(): Promise\<boolean> 2948 2949Checks whether this device supports distributed notifications. This API uses a promise to return the result. 2950 2951**System capability**: SystemCapability.Notification.Notification 2952 2953**Return value** 2954 2955| Type | Description | 2956| ------------------ | --------------------------------------------- | 2957| Promise\<boolean\> | Promise used to return the result.| 2958 2959**Example** 2960 2961```ts 2962import Base from '@ohos.base'; 2963 2964Notification.isDistributedEnabled().then((data: boolean) => { 2965 console.info("isDistributedEnabled success, data: " + JSON.stringify(data)); 2966}).catch((err: Base.BusinessError) => { 2967 console.error(`isDistributedEnabled failed, code is ${err}`); 2968}); 2969``` 2970 2971 2972## Notification.enableDistributedByBundle<sup>8+</sup> 2973 2974enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void 2975 2976Sets whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result. 2977 2978**System capability**: SystemCapability.Notification.Notification 2979 2980**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 2981 2982**System API**: This is a system API and cannot be called by third-party applications. 2983 2984**Parameters** 2985 2986| Name | Type | Mandatory| Description | 2987| -------- | ------------------------ | ---- | -------------------------- | 2988| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Bundle information of the application. | 2989| enable | boolean | Yes | Whether the device supports distributed notifications. | 2990| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| 2991 2992**Example** 2993 2994```ts 2995import Base from '@ohos.base'; 2996 2997let enableDistributedByBundleCallback = (err: Base.BusinessError) => { 2998 if (err) { 2999 console.info("enableDistributedByBundle failed " + JSON.stringify(err)); 3000 } else { 3001 console.info("enableDistributedByBundle success"); 3002 } 3003}; 3004 3005let bundle: Notification.BundleOption = { 3006 bundle: "bundleName1", 3007}; 3008 3009let enable: boolean = true; 3010 3011Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback); 3012``` 3013 3014## Notification.enableDistributedByBundle<sup>8+</sup> 3015 3016enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void> 3017 3018Sets whether a specified application supports distributed notifications. This API uses a promise to return the result. 3019 3020**System capability**: SystemCapability.Notification.Notification 3021 3022**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 3023 3024**System API**: This is a system API and cannot be called by third-party applications. 3025 3026**Parameters** 3027 3028| Name | Type | Mandatory| Description | 3029| -------- | ------------------------ | ---- | -------------------------- | 3030| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Application bundle. | 3031| enable | boolean | Yes | Whether the device supports distributed notifications. | 3032 3033**Example** 3034 3035```ts 3036import Base from '@ohos.base'; 3037 3038let enable: boolean = true; 3039 3040let bundle: Notification.BundleOption = { 3041 bundle: "bundleName1", 3042}; 3043 3044Notification.enableDistributedByBundle(bundle, enable).then(() => { 3045 console.info("enableDistributedByBundle success"); 3046}).catch((err: Base.BusinessError) => { 3047 console.error(`enableDistributedByBundle failed, code is ${err}`); 3048}); 3049 3050``` 3051 3052## Notification.isDistributedEnabledByBundle<sup>8+</sup> 3053 3054isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void 3055 3056Obtains whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result. 3057 3058**System capability**: SystemCapability.Notification.Notification 3059 3060**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 3061 3062**System API**: This is a system API and cannot be called by third-party applications. 3063 3064**Parameters** 3065 3066| Name | Type | Mandatory| Description | 3067| -------- | ------------------------ | ---- | -------------------------- | 3068| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Application bundle. | 3069| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| 3070 3071**Example** 3072 3073```ts 3074import Base from '@ohos.base'; 3075 3076let isDistributedEnabledByBundleCallback = (err: Base.BusinessError, data: boolean) => { 3077 if (err) { 3078 console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err)); 3079 } else { 3080 console.info("isDistributedEnabledByBundle success" + JSON.stringify(data)); 3081 } 3082}; 3083 3084let bundle: Notification.BundleOption = { 3085 bundle: "bundleName1", 3086}; 3087 3088Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); 3089``` 3090 3091## Notification.isDistributedEnabledByBundle<sup>8+</sup> 3092 3093isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> 3094 3095Checks whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result. 3096 3097**System capability**: SystemCapability.Notification.Notification 3098 3099**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 3100 3101**System API**: This is a system API and cannot be called by third-party applications. 3102 3103**Parameters** 3104 3105| Name | Type | Mandatory| Description | 3106| -------- | ------------------------ | ---- | -------------------------- | 3107| bundle | [BundleOption](./js-apis-inner-notification-notificationCommonDef.md#bundleoption) | Yes | Application bundle. | 3108 3109**Return value** 3110 3111| Type | Description | 3112| ------------------ | ------------------------------------------------- | 3113| Promise\<boolean\> | Promise used to return the result.| 3114 3115**Example** 3116 3117```ts 3118import Base from '@ohos.base'; 3119 3120let bundle: Notification.BundleOption = { 3121 bundle: "bundleName1", 3122}; 3123 3124Notification.isDistributedEnabledByBundle(bundle).then((data: boolean) => { 3125 console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data)); 3126}).catch((err: Base.BusinessError) => { 3127 console.error(`isDistributedEnabledByBundle failed, code is ${err}`); 3128}); 3129``` 3130 3131 3132## Notification.getDeviceRemindType<sup>8+</sup> 3133 3134getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void 3135 3136Obtains the notification reminder type. This API uses an asynchronous callback to return the result. 3137 3138**System capability**: SystemCapability.Notification.Notification 3139 3140**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 3141 3142**System API**: This is a system API and cannot be called by third-party applications. 3143 3144**Parameters** 3145 3146| Name | Type | Mandatory| Description | 3147| -------- | --------------------------------- | ---- | -------------------------- | 3148| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8-deprecated)\> | Yes | Callback used to return the result.| 3149 3150**Example** 3151 3152```ts 3153import Base from '@ohos.base'; 3154 3155let getDeviceRemindTypeCallback = (err: Base.BusinessError, data: Notification.DeviceRemindType) => { 3156 if (err) { 3157 console.info("getDeviceRemindType failed " + JSON.stringify(err)); 3158 } else { 3159 console.info("getDeviceRemindType success"); 3160 } 3161}; 3162 3163Notification.getDeviceRemindType(getDeviceRemindTypeCallback); 3164``` 3165 3166## Notification.getDeviceRemindType<sup>8+</sup> 3167 3168getDeviceRemindType(): Promise\<DeviceRemindType\> 3169 3170Obtains the notification reminder type. This API uses a promise to return the result. 3171 3172**System capability**: SystemCapability.Notification.Notification 3173 3174**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER 3175 3176**System API**: This is a system API and cannot be called by third-party applications. 3177 3178**Return value** 3179 3180| Type | Description | 3181| ------------------ | --------------- | 3182| Promise\<[DeviceRemindType](#deviceremindtype8-deprecated)\> | Promise used to return the result.| 3183 3184**Example** 3185 3186```ts 3187import Base from '@ohos.base'; 3188 3189Notification.getDeviceRemindType().then((data: Notification.DeviceRemindType) => { 3190 console.info("getDeviceRemindType success, data: " + JSON.stringify(data)); 3191}).catch((err: Base.BusinessError) => { 3192 console.error(`getDeviceRemindType failed, code is ${err}`); 3193}); 3194``` 3195 3196## SubscribeCallbackData 3197 3198**System capability**: SystemCapability.Notification.Notification 3199 3200**System API**: This is a system API and cannot be called by third-party applications. 3201 3202| Name | Type | Readable| Writable| Description | 3203| --------------- | ------------------------------------------------- | ---- | --- | -------- | 3204| request | [NotificationRequest](#notificationrequest) | Yes | No | Notification content.| 3205| sortingMap | [NotificationSortingMap](#notificationsortingmap) | Yes | No | Notification sorting information.| 3206| reason | number | Yes | No | Reason for deletion.| 3207| sound | string | Yes | No | Sound used for notification.| 3208| vibrationValues | Array\<number\> | Yes | No | Vibration used for notification.| 3209 3210 3211## EnabledNotificationCallbackData<sup>8+</sup> 3212 3213**System capability**: SystemCapability.Notification.Notification 3214 3215**System API**: This is a system API and cannot be called by third-party applications. 3216 3217| Name | Type | Readable| Writable| Description | 3218| ------ | ------- | ---- | --- | ---------------- | 3219| bundle | string | Yes | No | Bundle name of the application. | 3220| uid | number | Yes | No | UID of the application. | 3221| enable | boolean | Yes | No | Notification enabled status of the application.| 3222 3223 3224## DoNotDisturbDate<sup>8+</sup> <sup>deprecated</sup> 3225 3226**System capability**: SystemCapability.Notification.Notification 3227 3228> **NOTE** 3229> 3230> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate) instead. 3231 3232**System API**: This is a system API and cannot be called by third-party applications. 3233 3234| Name | Type | Readable| Writable| Description | 3235| ----- | -------------------------------------- | ---- | ---- | ---------------------- | 3236| type | [DoNotDisturbType](#donotdisturbtype8-deprecated) | Yes | Yes | DND time type.| 3237| begin | Date | Yes | Yes | DND start time.| 3238| end | Date | Yes | Yes | DND end time.| 3239 3240## DoNotDisturbType<sup>8+</sup> <sup>deprecated</sup> 3241 3242**System capability**: SystemCapability.Notification.Notification 3243 3244> **NOTE** 3245> 3246> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DoNotDisturbType](js-apis-notificationManager.md#donotdisturbtype) instead. 3247 3248**System API**: This is a system API and cannot be called by third-party applications. 3249 3250| Name | Value | Description | 3251| ------------ | ---------------- | ------------------------------------------ | 3252| TYPE_NONE | 0 | Non-DND. | 3253| TYPE_ONCE | 1 | One-shot DND at the specified time segment (only considering the hour and minute).| 3254| TYPE_DAILY | 2 | Daily DND at the specified time segment (only considering the hour and minute).| 3255| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute). | 3256 3257 3258## ContentType 3259 3260**System capability**: SystemCapability.Notification.Notification 3261 3262| Name | Value | Description | 3263| --------------------------------- | ----------- | ------------------ | 3264| NOTIFICATION_CONTENT_BASIC_TEXT | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification. | 3265| NOTIFICATION_CONTENT_LONG_TEXT | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification. | 3266| NOTIFICATION_CONTENT_PICTURE | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification. | 3267| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification. | 3268| NOTIFICATION_CONTENT_MULTILINE | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.| 3269 3270## SlotLevel 3271 3272**System capability**: SystemCapability.Notification.Notification 3273 3274| Name | Value | Description | 3275| --------------------------------- | ----------- | ------------------ | 3276| LEVEL_NONE | 0 | The notification function is disabled. | 3277| LEVEL_MIN | 1 | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.| 3278| LEVEL_LOW | 2 | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.| 3279| LEVEL_DEFAULT | 3 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.| 3280| LEVEL_HIGH | 4 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.| 3281 3282 3283## BundleOption<sup>deprecated</sup> 3284 3285**System capability**: SystemCapability.Notification.Notification 3286 3287> **NOTE** 3288> 3289> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [notificationManager.BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) instead. 3290 3291| Name | Type | Mandatory| Description | 3292| ------ | ------ | --- | ------ | 3293| bundle | string | Yes | Bundle information of the application.| 3294| uid | number | No | User ID. The default value is **0**.| 3295 3296## NotificationKey<sup>deprecated</sup> 3297 3298**System capability**: SystemCapability.Notification.Notification 3299 3300> **NOTE** 3301> 3302> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [notificationManager.NotificationKey](js-apis-notificationSubscribe.md#notificationkey) instead. 3303 3304| Name | Type | Readable| Writable| Description | 3305| ----- | ------ | ---- | --- | -------- | 3306| id | number | Yes | Yes | Notification ID. | 3307| label | string | Yes | Yes | Notification label.| 3308 3309 3310## SlotType 3311 3312**System capability**: SystemCapability.Notification.Notification 3313 3314| Name | Value | Description | 3315| -------------------- | -------- | ---------- | 3316| UNKNOWN_TYPE | 0 | Unknown type.| 3317| SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.| 3318| SERVICE_INFORMATION | 2 | Notification slot for service information.| 3319| CONTENT_INFORMATION | 3 | Notification slot for content consultation.| 3320| OTHER_TYPES | 0xFFFF | Notification slot for other purposes.| 3321 3322 3323## NotificationActionButton 3324 3325Describes the button displayed in the notification. 3326 3327**System capability**: SystemCapability.Notification.Notification 3328 3329| Name | Type | Readable| Writable| Description | 3330| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | 3331| title | string | Yes | Yes | Button title. | 3332| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.| 3333| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. | 3334| userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | Yes | Yes | User input object. | 3335 3336 3337## NotificationBasicContent 3338 3339Describes the normal text notification. 3340 3341**System capability**: SystemCapability.Notification.Notification 3342 3343| Name | Type | Readable| Writable| Description | 3344| -------------- | ------ | ---- | ---- | ---------------------------------- | 3345| title | string | Yes | Yes | Notification title. | 3346| text | string | Yes | Yes | Notification content. | 3347| additionalText | string | Yes | Yes | Additional information of the notification.| 3348 3349 3350## NotificationLongTextContent 3351 3352Describes the long text notification. 3353 3354**System capability**: SystemCapability.Notification.Notification 3355 3356| Name | Type | Readable| Writable| Description | 3357| -------------- | ------ | ---- | --- | -------------------------------- | 3358| title | string | Yes | Yes | Notification title. | 3359| text | string | Yes | Yes | Notification content. | 3360| additionalText | string | Yes | Yes | Additional information of the notification.| 3361| longText | string | Yes | Yes | Long text of the notification. | 3362| briefText | string | Yes | Yes | Brief text of the notification.| 3363| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | 3364 3365 3366## NotificationMultiLineContent 3367 3368Describes the multi-line text notification. 3369 3370**System capability**: SystemCapability.Notification.Notification 3371 3372| Name | Type | Readable| Writable| Description | 3373| -------------- | --------------- | --- | --- | -------------------------------- | 3374| title | string | Yes | Yes | Notification title. | 3375| text | string | Yes | Yes | Notification content. | 3376| additionalText | string | Yes | Yes | Additional information of the notification.| 3377| briefText | string | Yes | Yes | Brief text of the notification.| 3378| longTitle | string | Yes | Yes | Title of the notification in the expanded state. | 3379| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. | 3380 3381 3382## NotificationPictureContent 3383 3384Describes the picture-attached notification. 3385 3386**System capability**: SystemCapability.Notification.Notification 3387 3388| Name | Type | Readable| Writable| Description | 3389| -------------- | -------------- | ---- | --- | -------------------------------- | 3390| title | string | Yes | Yes | Notification title. | 3391| text | string | Yes | Yes | Notification content. | 3392| additionalText | string | Yes | Yes | Additional information of the notification.| 3393| briefText | string | Yes | Yes | Brief text of the notification.| 3394| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. | 3395| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. | 3396 3397 3398## NotificationContent 3399 3400Describes the notification content. 3401 3402**System capability**: SystemCapability.Notification.Notification 3403 3404| Name | Type | Readable| Writable| Description | 3405| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ | 3406| contentType | [ContentType](#contenttype) | Yes | Yes | Notification content type. | 3407| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. | 3408| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.| 3409| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. | 3410| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. | 3411 3412 3413## NotificationFlagStatus<sup>8+</sup> 3414 3415Describes the notification flag status. 3416 3417**System capability**: SystemCapability.Notification.Notification 3418 3419**System API**: This is a system API and cannot be called by third-party applications. 3420 3421| Name | Value | Description | 3422| -------------- | --- | --------------------------------- | 3423| TYPE_NONE | 0 | The default flag is used. | 3424| TYPE_OPEN | 1 | The notification flag is enabled. | 3425| TYPE_CLOSE | 2 | The notification flag is disabled. | 3426 3427 3428## NotificationFlags<sup>8+</sup> 3429 3430Enumerates notification flags. 3431 3432**System capability**: SystemCapability.Notification.Notification 3433 3434| Name | Type | Readable| Writable| Description | 3435| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | 3436| soundEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes | No | Whether to enable the sound alert for the notification. | 3437| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes | No | Whether to enable vibration for the notification. | 3438 3439 3440## NotificationRequest 3441 3442Describes the notification request. 3443 3444**System capability**: SystemCapability.Notification.Notification 3445 3446| Name | Type | Readable| Writable| Description | 3447| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | 3448| content | [NotificationContent](#notificationcontent) | Yes | Yes | Notification content. | 3449| id | number | Yes | Yes | Notification ID. | 3450| slotType | [SlotType](#slottype) | Yes | Yes | Slot type. | 3451| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. | 3452| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. | 3453| deliveryTime | number | Yes | Yes | Time when the notification is sent. | 3454| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. | 3455| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. | 3456| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked. | 3457| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. | 3458| color | number | Yes | Yes | Background color of the notification. Not supported currently.| 3459| colorEnabled | boolean | Yes | Yes | Whether the notification background color is enabled. Not supported currently.| 3460| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.| 3461| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. | 3462| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. | 3463| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. | 3464| label | string | Yes | Yes | Notification label. | 3465| badgeIconStyle | number | Yes | Yes | Notification badge type. | 3466| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. | 3467| actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | Yes | Yes | Buttons in the notification. Up to two buttons are allowed. | 3468| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.| 3469| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.| 3470| creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. | 3471| creatorUid | number | Yes | No | UID used for creating the notification. | 3472| creatorPid | number | Yes | No | PID used for creating the notification. | 3473| creatorUserId<sup>8+</sup>| number | Yes | No | ID of the user who creates the notification. | 3474| hashCode | string | Yes | No | Unique ID of the notification. | 3475| classification | string | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. | 3476| groupName<sup>8+</sup>| string | Yes | Yes | Notification group name. | 3477| template<sup>8+</sup> | [NotificationTemplate](#notificationtemplate8) | Yes | Yes | Notification template. | 3478| isRemoveAllowed<sup>8+</sup> | boolean | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. | 3479| source<sup>8+</sup> | number | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. | 3480| distributedOption<sup>8+</sup> | [DistributedOptions](#distributedoptions8) | Yes | Yes | Distributed notification options. | 3481| deviceId<sup>8+</sup> | string | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. | 3482| notificationFlags<sup>8+</sup> | [NotificationFlags](#notificationflags8) | Yes | No | Notification flags. | 3483| removalWantAgent<sup>9+</sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. | 3484| badgeNumber<sup>9+</sup> | number | Yes | Yes | Number of notifications displayed on the application icon. | 3485 3486## DistributedOptions<sup>8+</sup> 3487 3488Describes distributed notifications options. 3489 3490**System capability**: SystemCapability.Notification.Notification 3491 3492| Name | Type | Readable| Writable| Description | 3493| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | 3494| isDistributed | boolean | Yes | Yes | Whether the notification is a distributed notification. | 3495| supportDisplayDevices | Array\<string> | Yes | Yes | List of the devices to which the notification can be synchronized. | 3496| supportOperateDevices | Array\<string> | Yes | Yes | List of the devices on which the notification can be opened. | 3497| remindType | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. | 3498 3499 3500## NotificationSlot 3501 3502Describes the notification slot. 3503 3504**System capability**: SystemCapability.Notification.Notification 3505 3506| Name | Type | Readable| Writable| Description | 3507| -------------------- | --------------------- | ---- | --- |------------------------| 3508| type | [SlotType](#slottype) | Yes | Yes | Slot type. | 3509| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.| 3510| desc | string | Yes | Yes | Notification slot description. | 3511| badgeFlag | boolean | Yes | Yes | Whether to display the badge. | 3512| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. | 3513| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. | 3514| vibrationEnabled | boolean | Yes | Yes | Whether vibration is enabled for the notification. | 3515| sound | string | Yes | Yes | Notification alert tone. | 3516| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. | 3517| lightColor | number | Yes | Yes | Indicator color of the notification. | 3518| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. | 3519| enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. | 3520 3521 3522## NotificationSorting 3523 3524Provides sorting information of active notifications. 3525 3526**System capability**: SystemCapability.Notification.Notification 3527 3528**System API**: This is a system API and cannot be called by third-party applications. 3529 3530| Name | Type | Readable| Writable| Description | 3531| -------- | ------------------------------------- | ---- | --- | ------------ | 3532| slot | [NotificationSlot](#notificationslot) | Yes | No | Notification slot content.| 3533| hashCode | string | Yes | No | Unique ID of the notification.| 3534| ranking | number | Yes | No | Notification sequence number.| 3535 3536 3537## NotificationSortingMap 3538 3539Provides sorting information of active notifications in all subscribed notifications. 3540 3541**System capability**: SystemCapability.Notification.Notification 3542 3543**System API**: This is a system API and cannot be called by third-party applications. 3544 3545| Name | Type | Readable| Writable| Description | 3546| -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- | 3547| sortings | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | No | Array of notification sorting information.| 3548| sortedHashCode | Array\<string\> | Yes | No | Array of unique notification IDs.| 3549 3550 3551## NotificationSubscribeInfo 3552 3553Provides the information about the publisher for notification subscription. 3554 3555**System capability**: SystemCapability.Notification.Notification 3556 3557**System API**: This is a system API and cannot be called by third-party applications. 3558 3559| Name | Type | Readable| Writable| Description | 3560|---------------------------------------------------| --------------- | --- | ---- |----------------------------------------------------------------------------------------------| 3561| bundleNames | Array\<string\> | Yes | Yes | Bundle names of the applications whose notifications are to be subscribed to. | 3562| userId | number | Yes | Yes | User whose notifications are to be subscribed to.| 3563 3564 3565## NotificationTemplate<sup>8+</sup> 3566 3567Describes the notification template. 3568 3569**System capability**: SystemCapability.Notification.Notification 3570 3571| Name| Type | Readable| Writable| Description | 3572| ---- | ---------------------- | ---- | ---- | ---------- | 3573| name | string | Yes | Yes | Template name.| 3574| data | {[key:string]: Object} | Yes | Yes | Template data.| 3575 3576 3577## NotificationUserInput<sup>8+</sup> 3578 3579Provides the notification user input. 3580 3581**System capability**: SystemCapability.Notification.Notification 3582 3583| Name | Type | Readable| Writable| Description | 3584| -------- | ------ | --- | ---- | ----------------------------- | 3585| inputKey | string | Yes | Yes | Key to identify the user input.| 3586 3587 3588## DeviceRemindType<sup>8+</sup> <sup>deprecated</sup> 3589 3590**System capability**: SystemCapability.Notification.Notification 3591 3592**System API**: This is a system API and cannot be called by third-party applications. 3593 3594> **NOTE** 3595> 3596> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.DeviceRemindType](js-apis-notificationManager.md#deviceremindtype) instead. 3597 3598| Name | Value | Description | 3599| -------------------- | --- | --------------------------------- | 3600| IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. | 3601| IDLE_REMIND | 1 | The device is not in use. | 3602| ACTIVE_DONOT_REMIND | 2 | The device is in use. No notification is required. | 3603| ACTIVE_REMIND | 3 | The device is in use. | 3604 3605 3606## SourceType<sup>8+</sup> <sup>deprecated</sup> 3607 3608**System capability**: SystemCapability.Notification.Notification 3609 3610**System API**: This is a system API and cannot be called by third-party applications. 3611 3612> **NOTE** 3613> 3614> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [notificationManager.SourceType](js-apis-notificationManager.md#sourcetype) instead. 3615 3616| Name | Value | Description | 3617| -------------------- | --- | -------------------- | 3618| TYPE_NORMAL | 0 | Normal notification. | 3619| TYPE_CONTINUOUS | 1 | Continuous notification. | 3620| TYPE_TIMER | 2 | Timed notification. | 3621 3622## RemoveReason <sup>deprecated</sup> 3623 3624**System capability**: SystemCapability.Notification.Notification 3625 3626**System API**: This is a system API and cannot be called by third-party applications. 3627 3628> **NOTE** 3629> 3630> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [notificationManager.RemoveReason](js-apis-notificationSubscribe.md#removereason) instead. 3631 3632| Name | Value | Description | 3633| -------------------- | --- | -------------------- | 3634| CLICK_REASON_REMOVE | 1 | The notification is removed after a click on it. | 3635| CANCEL_REASON_REMOVE | 2 | The notification is removed by the user. | 3636