js-apis-notification.md 138.3 KB
Newer Older
1
# @ohos.notification
W
wusongqing 已提交
2

E
ester.zhou 已提交
3 4
The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status.

E
ester.zhou 已提交
5
> **NOTE**
E
ester.zhou 已提交
6
>
E
ester.zhou 已提交
7
> 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.
8 9
>
> Notification subscription and unsubscription APIs are available only to system applications.
W
wusongqing 已提交
10 11 12 13 14 15 16

## Modules to Import

```js
import Notification from '@ohos.notification';
```

E
ester.zhou 已提交
17
## Notification.publish
W
wusongqing 已提交
18

E
ester.zhou 已提交
19
publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
20

E
ester.zhou 已提交
21
Publishes a notification. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
22

E
ester.zhou 已提交
23
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
24

E
ester.zhou 已提交
25
**Parameters**
W
wusongqing 已提交
26

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

E
ester.zhou 已提交
32
**Example**
W
wusongqing 已提交
33 34 35 36

```js
// publish callback
function publishCallback(err) {
E
esterzhou 已提交
37 38 39 40 41
    if (err.code) {
        console.info("publish failed " + JSON.stringify(err));
    } else {
        console.info("publish success");
    }
W
wusongqing 已提交
42 43 44 45 46
}
// NotificationRequest object
var notificationRequest = {
    id: 1,
    content: {
E
ester.zhou 已提交
47
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
W
wusongqing 已提交
48 49 50 51 52 53 54 55 56 57 58 59
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest, publishCallback)
```



E
ester.zhou 已提交
60
## Notification.publish
W
wusongqing 已提交
61

E
ester.zhou 已提交
62
publish(request: NotificationRequest): Promise\<void\>
W
wusongqing 已提交
63

E
ester.zhou 已提交
64
Publishes a notification. This API uses a promise to return the result.
W
wusongqing 已提交
65

E
ester.zhou 已提交
66
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
67

E
ester.zhou 已提交
68 69 70 71
**Parameters**

| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
72
| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
ester.zhou 已提交
73

E
ester.zhou 已提交
74
**Example**
W
wusongqing 已提交
75 76 77 78 79 80

```js
// NotificationRequest object
var notificationRequest = {
    notificationId: 1,
    content: {
E
ester.zhou 已提交
81
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
W
wusongqing 已提交
82 83 84 85 86 87 88
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
E
ester.zhou 已提交
89
Notification.publish(notificationRequest).then(() => {
90
	console.info("publish success");
W
wusongqing 已提交
91 92 93 94
});

```

E
ester.zhou 已提交
95 96 97 98
## Notification.publish<sup>8+</sup>

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

99
Publishes a notification to a specified user. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
100 101 102

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

E
ester.zhou 已提交
103 104
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
105 106
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
107 108
**Parameters**

E
ester.zhou 已提交
109 110
| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
111 112
| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
| userId   | number                                      | Yes  | User ID.                          |
E
ester.zhou 已提交
113
| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |
E
ester.zhou 已提交
114 115 116 117 118 119

**Example**

```js
// publish callback
function publishCallback(err) {
E
esterzhou 已提交
120 121 122 123 124
    if (err.code) {
        console.info("publish failed " + JSON.stringify(err));
    } else {
        console.info("publish success");
    }
E
ester.zhou 已提交
125
}
126
// User ID
E
ester.zhou 已提交
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
var userId = 1
// NotificationRequest object
var notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest, userId, publishCallback);
```

## Notification.publish<sup>8+</sup>

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

147
Publishes a notification to a specified user. This API uses a promise to return the result.
E
ester.zhou 已提交
148 149 150

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

E
ester.zhou 已提交
151 152
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
153 154
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
155 156
**Parameters**

E
ester.zhou 已提交
157 158
| Name    |  Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
159 160
| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
| userId   | number                                      | Yes  | User ID.                          |
E
ester.zhou 已提交
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177

**Example**

```js
var notificationRequest = {
    notificationId: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

var userId = 1
W
wusongqing 已提交
178

E
ester.zhou 已提交
179
Notification.publish(notificationRequest, userId).then(() => {
180
	console.info("publish success");
E
ester.zhou 已提交
181 182
});
```
W
wusongqing 已提交
183 184


E
ester.zhou 已提交
185
## Notification.cancel
W
wusongqing 已提交
186

E
ester.zhou 已提交
187
cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
188

E
ester.zhou 已提交
189
Cancels a notification with the specified ID and label. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
190

E
ester.zhou 已提交
191
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
192

E
ester.zhou 已提交
193
**Parameters**
W
wusongqing 已提交
194

E
ester.zhou 已提交
195 196 197 198 199
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| id       | number                | Yes  | Notification ID.              |
| label    | string                | Yes  | Notification label.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
200

E
ester.zhou 已提交
201
**Example**
W
wusongqing 已提交
202 203 204 205

```js
// cancel callback
function cancelCallback(err) {
E
esterzhou 已提交
206 207 208 209 210
    if (err.code) {
        console.info("cancel failed " + JSON.stringify(err));
    } else {
        console.info("cancel success");
    }
W
wusongqing 已提交
211 212 213 214 215 216
}
Notification.cancel(0, "label", cancelCallback)
```



E
ester.zhou 已提交
217
## Notification.cancel
W
wusongqing 已提交
218

E
ester.zhou 已提交
219
cancel(id: number, label?: string): Promise\<void\>
W
wusongqing 已提交
220

221
Cancels a notification with the specified ID and optional label. This API uses a promise to return the result.
W
wusongqing 已提交
222

E
ester.zhou 已提交
223
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
224

E
ester.zhou 已提交
225
**Parameters**
W
wusongqing 已提交
226

E
ester.zhou 已提交
227 228 229 230
| Name | Type  | Mandatory| Description    |
| ----- | ------ | ---- | -------- |
| id    | number | Yes  | Notification ID.  |
| label | string | No  | Notification label.|
W
wusongqing 已提交
231

E
ester.zhou 已提交
232
**Example**
W
wusongqing 已提交
233 234

```js
E
ester.zhou 已提交
235
Notification.cancel(0).then(() => {
236
	console.info("cancel success");
W
wusongqing 已提交
237 238 239 240 241
});
```



E
ester.zhou 已提交
242
## Notification.cancel
W
wusongqing 已提交
243

E
ester.zhou 已提交
244
cancel(id: number, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
245

E
ester.zhou 已提交
246
Cancels a notification with the specified ID. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
247

E
ester.zhou 已提交
248
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
249

E
ester.zhou 已提交
250
**Parameters**
W
wusongqing 已提交
251

E
ester.zhou 已提交
252 253 254 255
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| id       | number                | Yes  | Notification ID.              |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
256

E
ester.zhou 已提交
257
**Example**
W
wusongqing 已提交
258 259 260 261

```js
// cancel callback
function cancelCallback(err) {
E
esterzhou 已提交
262 263 264 265 266
    if (err.code) {
        console.info("cancel failed " + JSON.stringify(err));
    } else {
        console.info("cancel success");
    }
W
wusongqing 已提交
267 268 269 270 271 272
}
Notification.cancel(0, cancelCallback)
```



E
ester.zhou 已提交
273
## Notification.cancelAll
W
wusongqing 已提交
274

E
ester.zhou 已提交
275
cancelAll(callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
276

E
ester.zhou 已提交
277
Cancels all notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
278

E
ester.zhou 已提交
279
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
280

E
ester.zhou 已提交
281
**Parameters**
W
wusongqing 已提交
282

E
ester.zhou 已提交
283 284 285
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
286

E
ester.zhou 已提交
287
**Example**
W
wusongqing 已提交
288 289 290

```js
// cancel callback
E
ester.zhou 已提交
291
function cancelAllCallback(err) {
E
esterzhou 已提交
292 293 294 295 296
    if (err.code) {
        console.info("cancelAll failed " + JSON.stringify(err));
    } else {
        console.info("cancelAll success");
    }
W
wusongqing 已提交
297
}
E
ester.zhou 已提交
298
Notification.cancelAll(cancelAllCallback)
W
wusongqing 已提交
299 300 301 302
```



E
ester.zhou 已提交
303
## Notification.cancelAll
W
wusongqing 已提交
304

E
ester.zhou 已提交
305
cancelAll(): Promise\<void\>
W
wusongqing 已提交
306

E
ester.zhou 已提交
307
Cancels all notifications. This API uses a promise to return the result.
W
wusongqing 已提交
308

E
ester.zhou 已提交
309
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
310

E
ester.zhou 已提交
311
**Example**
W
wusongqing 已提交
312 313

```js
E
ester.zhou 已提交
314
Notification.cancelAll().then(() => {
315
	console.info("cancelAll success");
W
wusongqing 已提交
316 317 318 319 320
});
```



E
ester.zhou 已提交
321
## Notification.addSlot
W
wusongqing 已提交
322

E
ester.zhou 已提交
323
addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
324

E
ester.zhou 已提交
325
Adds a notification slot. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
326

E
ester.zhou 已提交
327
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
328

E
ester.zhou 已提交
329 330
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
331 332
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
333
**Parameters**
W
wusongqing 已提交
334

E
ester.zhou 已提交
335 336 337 338
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| slot     | [NotificationSlot](#notificationslot)       | Yes  | Notification slot to add.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
339

E
ester.zhou 已提交
340
**Example**
W
wusongqing 已提交
341 342 343 344

```js
// addSlot callback
function addSlotCallBack(err) {
E
esterzhou 已提交
345 346 347 348 349
    if (err.code) {
        console.info("addSlot failed " + JSON.stringify(err));
    } else {
        console.info("addSlot success");
    }
W
wusongqing 已提交
350 351 352 353 354 355 356 357 358 359
}
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.addSlot(notificationSlot, addSlotCallBack)
```



E
ester.zhou 已提交
360
## Notification.addSlot
W
wusongqing 已提交
361

E
ester.zhou 已提交
362
addSlot(slot: NotificationSlot): Promise\<void\>
W
wusongqing 已提交
363

E
ester.zhou 已提交
364
Adds a notification slot. This API uses a promise to return the result.
W
wusongqing 已提交
365

E
ester.zhou 已提交
366
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
367

E
ester.zhou 已提交
368 369
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
370 371
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
372
**Parameters**
W
wusongqing 已提交
373

E
ester.zhou 已提交
374 375 376
| Name| Type            | Mandatory| Description                |
| ---- | ---------------- | ---- | -------------------- |
| slot | [NotificationSlot](#notificationslot) | Yes  | Notification slot to add.|
W
wusongqing 已提交
377

E
ester.zhou 已提交
378
**Example**
W
wusongqing 已提交
379 380 381 382 383 384

```js
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
385
Notification.addSlot(notificationSlot).then(() => {
386
	console.info("addSlot success");
W
wusongqing 已提交
387 388 389 390 391
});
```



E
ester.zhou 已提交
392
## Notification.addSlot
W
wusongqing 已提交
393

E
ester.zhou 已提交
394
addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
395

396
Adds a notification slot of a specified type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
397

E
ester.zhou 已提交
398
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
399

E
ester.zhou 已提交
400
**Parameters**
W
wusongqing 已提交
401

E
ester.zhou 已提交
402 403 404 405
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| type     | [SlotType](#slottype)              | Yes  | Type of the notification slot to add.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.  |
W
wusongqing 已提交
406

E
ester.zhou 已提交
407
**Example**
W
wusongqing 已提交
408 409 410 411

```js
// addSlot callback
function addSlotCallBack(err) {
E
esterzhou 已提交
412 413 414 415 416
    if (err.code) {
        console.info("addSlot failed " + JSON.stringify(err));
    } else {
        console.info("addSlot success");
    }
W
wusongqing 已提交
417 418 419 420 421 422
}
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack)
```



E
ester.zhou 已提交
423
## Notification.addSlot
W
wusongqing 已提交
424

E
ester.zhou 已提交
425
addSlot(type: SlotType): Promise\<void\>
W
wusongqing 已提交
426

427
Adds a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
428

E
ester.zhou 已提交
429
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
430

E
ester.zhou 已提交
431
**Parameters**
W
wusongqing 已提交
432

E
ester.zhou 已提交
433 434 435
| Name| Type    | Mandatory| Description                  |
| ---- | -------- | ---- | ---------------------- |
| type | [SlotType](#slottype) | Yes  | Type of the notification slot to add.|
W
wusongqing 已提交
436

E
ester.zhou 已提交
437
**Example**
W
wusongqing 已提交
438 439

```js
E
ester.zhou 已提交
440
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
441
	console.info("addSlot success");
W
wusongqing 已提交
442 443 444 445 446
});
```



E
ester.zhou 已提交
447
## Notification.addSlots
W
wusongqing 已提交
448

E
ester.zhou 已提交
449
addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
450

451
Adds an array of notification slots. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
452

E
ester.zhou 已提交
453
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
454

E
ester.zhou 已提交
455 456
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
457 458
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
459
**Parameters**
W
wusongqing 已提交
460

E
ester.zhou 已提交
461 462 463 464
| Name    | Type                     | Mandatory| Description                    |
| -------- | ------------------------- | ---- | ------------------------ |
| slots    | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
| callback | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |
W
wusongqing 已提交
465

E
ester.zhou 已提交
466
**Example**
W
wusongqing 已提交
467 468 469 470

```js
// addSlots callback
function addSlotsCallBack(err) {
E
esterzhou 已提交
471 472 473 474 475
    if (err.code) {
        console.info("addSlots failed " + JSON.stringify(err));
    } else {
        console.info("addSlots success");
    }
W
wusongqing 已提交
476 477 478 479 480 481
}
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
// NotificationSlotArray object
E
ester.zhou 已提交
482 483
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
484 485 486 487 488 489

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



E
ester.zhou 已提交
490
## Notification.addSlots
W
wusongqing 已提交
491

E
ester.zhou 已提交
492
addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
W
wusongqing 已提交
493

494
Adds an array of notification slots. This API uses a promise to return the result.
W
wusongqing 已提交
495

E
ester.zhou 已提交
496
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
497

E
ester.zhou 已提交
498 499
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
500 501
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
502
**Parameters**
W
wusongqing 已提交
503

E
ester.zhou 已提交
504 505 506
| Name | Type                     | Mandatory| Description                    |
| ----- | ------------------------- | ---- | ------------------------ |
| slots | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
W
wusongqing 已提交
507

E
ester.zhou 已提交
508
**Example**
W
wusongqing 已提交
509 510 511 512 513 514 515

```js
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
// NotificationSlotArray object
E
ester.zhou 已提交
516 517
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
518

E
ester.zhou 已提交
519
Notification.addSlots(notificationSlotArray).then(() => {
520
	console.info("addSlots success");
W
wusongqing 已提交
521 522 523 524 525
});
```



E
ester.zhou 已提交
526
## Notification.getSlot
W
wusongqing 已提交
527

E
ester.zhou 已提交
528
getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
W
wusongqing 已提交
529

530
Obtains a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
531

E
ester.zhou 已提交
532
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
533

E
ester.zhou 已提交
534
**Parameters**
W
wusongqing 已提交
535

E
ester.zhou 已提交
536 537 538 539
| Name    | Type                             | Mandatory| Description                                                       |
| -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype)                          | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | Yes  | Callback used to return the result.                                       |
W
wusongqing 已提交
540

E
ester.zhou 已提交
541
**Example**
W
wusongqing 已提交
542 543 544

```js
// getSlot callback
545
function getSlotCallback(err, data) {
E
esterzhou 已提交
546 547 548 549 550
    if (err.code) {
        console.info("getSlot failed " + JSON.stringify(err));
    } else {
        console.info("getSlot success");
    }
W
wusongqing 已提交
551 552 553 554 555 556 557
}
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback)
```



E
ester.zhou 已提交
558
## Notification.getSlot
W
wusongqing 已提交
559

E
ester.zhou 已提交
560
getSlot(slotType: SlotType): Promise\<NotificationSlot\>
W
wusongqing 已提交
561

562
Obtains a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
563

E
ester.zhou 已提交
564
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
565

E
ester.zhou 已提交
566
**Parameters**
W
wusongqing 已提交
567

E
ester.zhou 已提交
568 569 570
| Name    | Type    | Mandatory| Description                                                       |
| -------- | -------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
W
wusongqing 已提交
571

E
ester.zhou 已提交
572
**Return value**
W
wusongqing 已提交
573

E
ester.zhou 已提交
574 575 576 577 578
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
579 580 581 582

```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => {
583
	console.info("getSlot success, data: " + JSON.stringify(data));
W
wusongqing 已提交
584 585 586 587 588
});
```



E
ester.zhou 已提交
589
## Notification.getSlots
W
wusongqing 已提交
590

E
ester.zhou 已提交
591
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
W
wusongqing 已提交
592

E
ester.zhou 已提交
593
Obtains all notification slots. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
594

E
ester.zhou 已提交
595
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
596

E
ester.zhou 已提交
597
**Parameters**
W
wusongqing 已提交
598

E
ester.zhou 已提交
599 600 601
| Name    | Type                             | Mandatory| Description                |
| -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
602

E
ester.zhou 已提交
603
**Example**
W
wusongqing 已提交
604 605 606

```js
// getSlots callback
607
function getSlotsCallback(err, data) {
E
esterzhou 已提交
608 609 610 611 612
    if (err.code) {
        console.info("getSlots failed " + JSON.stringify(err));
    } else {
        console.info("getSlots success");
    }
W
wusongqing 已提交
613 614 615 616 617 618
}
Notification.getSlots(getSlotsCallback)
```



E
ester.zhou 已提交
619
## Notification.getSlots
W
wusongqing 已提交
620

E
ester.zhou 已提交
621
getSlots(): Promise\<Array\<NotificationSlot\>>
W
wusongqing 已提交
622

E
ester.zhou 已提交
623
Obtains all notification slots of this application. This API uses a promise to return the result.
W
wusongqing 已提交
624

E
ester.zhou 已提交
625
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
626

E
ester.zhou 已提交
627
**Return value**
W
wusongqing 已提交
628

E
ester.zhou 已提交
629 630 631
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.|
W
wusongqing 已提交
632

E
ester.zhou 已提交
633
**Example**
W
wusongqing 已提交
634 635 636

```js
Notification.getSlots().then((data) => {
637
	console.info("getSlots success, data: " + JSON.stringify(data));
W
wusongqing 已提交
638 639 640 641 642
});
```



E
ester.zhou 已提交
643
## Notification.removeSlot
W
wusongqing 已提交
644

E
ester.zhou 已提交
645
removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
646

647
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
648

E
ester.zhou 已提交
649
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
650

E
ester.zhou 已提交
651
**Parameters**
W
wusongqing 已提交
652

E
ester.zhou 已提交
653 654 655 656
| Name    | Type                 | Mandatory| Description                                                       |
| -------- | --------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype)              | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                                       |
W
wusongqing 已提交
657

E
ester.zhou 已提交
658
**Example**
W
wusongqing 已提交
659 660 661 662

```js
// removeSlot callback
function removeSlotCallback(err) {
E
esterzhou 已提交
663 664 665 666 667
    if (err.code) {
        console.info("removeSlot failed " + JSON.stringify(err));
    } else {
        console.info("removeSlot success");
    }
W
wusongqing 已提交
668 669 670 671 672 673 674
}
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback)
```



E
ester.zhou 已提交
675
## Notification.removeSlot
W
wusongqing 已提交
676

E
ester.zhou 已提交
677
removeSlot(slotType: SlotType): Promise\<void\>
W
wusongqing 已提交
678

679
Removes a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
680

E
ester.zhou 已提交
681
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
682

E
ester.zhou 已提交
683
**Parameters**
W
wusongqing 已提交
684

E
ester.zhou 已提交
685 686 687
| Name    | Type    | Mandatory| Description                                                       |
| -------- | -------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
W
wusongqing 已提交
688

E
ester.zhou 已提交
689
**Example**
W
wusongqing 已提交
690 691 692

```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
693
Notification.removeSlot(slotType).then(() => {
694
	console.info("removeSlot success");
W
wusongqing 已提交
695 696 697 698 699
});
```



E
ester.zhou 已提交
700
## Notification.removeAllSlots
W
wusongqing 已提交
701

E
ester.zhou 已提交
702
removeAllSlots(callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
703

E
ester.zhou 已提交
704
Removes all notification slots. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
705

E
ester.zhou 已提交
706
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
707

E
ester.zhou 已提交
708
**Parameters**
W
wusongqing 已提交
709

E
ester.zhou 已提交
710 711 712
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
713

E
ester.zhou 已提交
714
**Example**
W
wusongqing 已提交
715 716 717

```js
function removeAllCallBack(err) {
E
esterzhou 已提交
718 719 720 721 722
    if (err.code) {
        console.info("removeAllSlots failed " + JSON.stringify(err));
    } else {
        console.info("removeAllSlots success");
    }
W
wusongqing 已提交
723 724 725 726 727 728
}
Notification.removeAllSlots(removeAllCallBack)
```



E
ester.zhou 已提交
729
## Notification.removeAllSlots
W
wusongqing 已提交
730

E
ester.zhou 已提交
731
removeAllSlots(): Promise\<void\>
W
wusongqing 已提交
732

E
ester.zhou 已提交
733
Removes all notification slots. This API uses a promise to return the result.
W
wusongqing 已提交
734

E
ester.zhou 已提交
735
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
736

E
ester.zhou 已提交
737
**Example**
W
wusongqing 已提交
738 739

```js
E
ester.zhou 已提交
740
Notification.removeAllSlots().then(() => {
741
	console.info("removeAllSlots success");
W
wusongqing 已提交
742 743 744 745 746
});
```



E
ester.zhou 已提交
747
## Notification.subscribe
W
wusongqing 已提交
748

E
ester.zhou 已提交
749
subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
750

E
ester.zhou 已提交
751
Subscribes to a notification with the subscription information specified. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
752

E
ester.zhou 已提交
753
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
754

E
ester.zhou 已提交
755 756
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
757 758
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
759
**Parameters**
W
wusongqing 已提交
760

E
ester.zhou 已提交
761 762 763
| Name      | Type                     | Mandatory| Description            |
| ---------- | ------------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.    |
764
| info       | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes  | Notification subscription information.|
E
ester.zhou 已提交
765
| callback   | AsyncCallback\<void\>     | Yes  | Callback used to return the result.|
W
wusongqing 已提交
766

E
ester.zhou 已提交
767
**Example**
W
wusongqing 已提交
768 769 770 771

```js
// subscribe callback
function subscribeCallback(err) {
E
esterzhou 已提交
772 773 774 775 776
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribe success");
    }
W
wusongqing 已提交
777
}
E
ester.zhou 已提交
778
function onConsumeCallback(data) {
E
esterzhou 已提交
779
	console.info("Consume callback: " + JSON.stringify(data));
W
wusongqing 已提交
780 781 782 783 784
}
var subscriber = {
    onConsume: onConsumeCallback
}
var info = {
785
    bundleNames: ["bundleName1", "bundleName2"]
W
wusongqing 已提交
786 787 788 789 790 791
}
Notification.subscribe(subscriber, info, subscribeCallback);
```



E
ester.zhou 已提交
792
## Notification.subscribe
W
wusongqing 已提交
793

E
ester.zhou 已提交
794
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
795

796
Subscribes to notifications of all applications under this user. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
797

E
ester.zhou 已提交
798
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
799

E
ester.zhou 已提交
800 801
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
802 803
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
804
**Parameters**
W
wusongqing 已提交
805

E
ester.zhou 已提交
806 807 808 809
| Name      | Type                  | Mandatory| Description            |
| ---------- | ---------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.    |
| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
810

E
ester.zhou 已提交
811
**Example**
W
wusongqing 已提交
812 813 814

```js
function subscribeCallback(err) {
E
esterzhou 已提交
815 816 817 818 819
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribe success");
    }
W
wusongqing 已提交
820
}
E
ester.zhou 已提交
821
function onConsumeCallback(data) {
E
esterzhou 已提交
822
	console.info("Consume callback: " + JSON.stringify(data));
W
wusongqing 已提交
823 824 825 826 827 828 829 830 831
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.subscribe(subscriber, subscribeCallback);
```



E
ester.zhou 已提交
832
## Notification.subscribe
W
wusongqing 已提交
833

E
ester.zhou 已提交
834
subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise\<void\>
W
wusongqing 已提交
835

E
ester.zhou 已提交
836
Subscribes to a notification with the subscription information specified. This API uses a promise to return the result.
W
wusongqing 已提交
837

E
ester.zhou 已提交
838
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
839

E
ester.zhou 已提交
840 841
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
842 843
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
844
**Parameters**
W
wusongqing 已提交
845

E
ester.zhou 已提交
846 847 848
| Name      | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.|
849
| info       | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No  | Notification subscription information.  |
W
wusongqing 已提交
850

E
ester.zhou 已提交
851
**Example**
W
wusongqing 已提交
852 853

```js
E
ester.zhou 已提交
854
function onConsumeCallback(data) {
855
    console.info("Consume callback: " + JSON.stringify(data));
W
wusongqing 已提交
856 857 858 859
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
860
Notification.subscribe(subscriber).then(() => {
861
	console.info("subscribe success");
W
wusongqing 已提交
862 863 864 865 866
});
```



E
ester.zhou 已提交
867
## Notification.unsubscribe
W
wusongqing 已提交
868

E
ester.zhou 已提交
869
unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
870

E
ester.zhou 已提交
871
Unsubscribes from a notification. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
872

E
ester.zhou 已提交
873
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
874

E
ester.zhou 已提交
875 876
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
877 878
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
879
**Parameters**
W
wusongqing 已提交
880

E
ester.zhou 已提交
881 882 883 884
| Name      | Type                  | Mandatory| Description                |
| ---------- | ---------------------- | ---- | -------------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.        |
| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
885

E
ester.zhou 已提交
886
**Example**
W
wusongqing 已提交
887 888 889

```js
function unsubscribeCallback(err) {
E
esterzhou 已提交
890 891 892 893 894
    if (err.code) {
        console.info("unsubscribe failed " + JSON.stringify(err));
    } else {
        console.info("unsubscribe success");
    }
W
wusongqing 已提交
895
}
896
function onDisconnectCallback(data) {
E
esterzhou 已提交
897
	console.info("Cancel callback: " + JSON.stringify(data));
W
wusongqing 已提交
898 899
}
var subscriber = {
900
    onDisconnect: onDisconnectCallback
W
wusongqing 已提交
901 902 903 904 905 906
}
Notification.unsubscribe(subscriber, unsubscribeCallback);
```



E
ester.zhou 已提交
907
## Notification.unsubscribe
W
wusongqing 已提交
908

E
ester.zhou 已提交
909
unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
W
wusongqing 已提交
910

E
ester.zhou 已提交
911
Unsubscribes from a notification. This API uses a promise to return the result.
W
wusongqing 已提交
912

E
ester.zhou 已提交
913
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
914

E
ester.zhou 已提交
915 916
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
917 918
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
919
**Parameters**
W
wusongqing 已提交
920

E
ester.zhou 已提交
921 922 923
| Name      | Type                  | Mandatory| Description        |
| ---------- | ---------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
W
wusongqing 已提交
924

E
ester.zhou 已提交
925
**Example**
W
wusongqing 已提交
926 927

```js
928
function onDisconnectCallback(data) {
E
esterzhou 已提交
929
	console.info("Cancel callback: " + JSON.stringify(data));
W
wusongqing 已提交
930 931
}
var subscriber = {
932
    onDisconnect: onDisconnectCallback
W
wusongqing 已提交
933
};
E
ester.zhou 已提交
934
Notification.unsubscribe(subscriber).then(() => {
935
	console.info("unsubscribe success");
W
wusongqing 已提交
936 937 938 939 940
});
```



E
ester.zhou 已提交
941
## Notification.enableNotification
W
wusongqing 已提交
942

E
ester.zhou 已提交
943
enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
944

945
Sets whether to enable notification for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
946

E
ester.zhou 已提交
947
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
948

E
ester.zhou 已提交
949 950
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
951 952
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
953
**Parameters**
W
wusongqing 已提交
954

E
ester.zhou 已提交
955 956
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
957
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.       |
E
ester.zhou 已提交
958 959
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
960

E
ester.zhou 已提交
961
**Example**
W
wusongqing 已提交
962 963 964

```js
function enableNotificationCallback(err) {
E
esterzhou 已提交
965 966 967 968 969
    if (err.code) {
        console.info("enableNotification failed " + JSON.stringify(err));
    } else {
        console.info("enableNotification success");
    }
W
wusongqing 已提交
970 971
}
var bundle = {
E
ester.zhou 已提交
972
    bundle: "bundleName1",
W
wusongqing 已提交
973 974 975 976 977 978
}
Notification.enableNotification(bundle, false, enableNotificationCallback);
```



E
ester.zhou 已提交
979
## Notification.enableNotification
W
wusongqing 已提交
980

E
ester.zhou 已提交
981
enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\>
W
wusongqing 已提交
982

983
Sets whether to enable notification for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
984

E
ester.zhou 已提交
985
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
986

E
ester.zhou 已提交
987 988
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
989 990
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
991
**Parameters**
W
wusongqing 已提交
992

E
ester.zhou 已提交
993 994
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
995
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
E
ester.zhou 已提交
996
| enable | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
997

E
ester.zhou 已提交
998
**Example**
W
wusongqing 已提交
999 1000 1001

```js
var bundle = {
E
ester.zhou 已提交
1002
    bundle: "bundleName1",
W
wusongqing 已提交
1003
}
E
ester.zhou 已提交
1004
Notification.enableNotification(bundle, false).then(() => {
1005
	console.info("enableNotification success");
W
wusongqing 已提交
1006 1007 1008 1009 1010
});
```



E
ester.zhou 已提交
1011
## Notification.isNotificationEnabled
W
wusongqing 已提交
1012

E
ester.zhou 已提交
1013
isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
W
wusongqing 已提交
1014

1015
Checks whether notification is enabled for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1016

E
ester.zhou 已提交
1017
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1018

E
ester.zhou 已提交
1019 1020
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1021 1022
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1023
**Parameters**
W
wusongqing 已提交
1024

E
ester.zhou 已提交
1025 1026
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
1027
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.           |
E
ester.zhou 已提交
1028
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1029

E
ester.zhou 已提交
1030
**Example**
W
wusongqing 已提交
1031 1032 1033

```js
function isNotificationEnabledCallback(err, data) {
E
esterzhou 已提交
1034 1035 1036 1037 1038
    if (err.code) {
        console.info("isNotificationEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationEnabled success");
    }
W
wusongqing 已提交
1039 1040
}
var bundle = {
E
ester.zhou 已提交
1041
    bundle: "bundleName1",
W
wusongqing 已提交
1042 1043 1044 1045 1046 1047
}
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
```



E
ester.zhou 已提交
1048 1049 1050
## Notification.isNotificationEnabled

isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
W
wusongqing 已提交
1051

1052
Checks whether notification is enabled for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1053

E
ester.zhou 已提交
1054
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1055

E
ester.zhou 已提交
1056 1057
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1058 1059
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1060
**Parameters**
W
wusongqing 已提交
1061

E
ester.zhou 已提交
1062 1063
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1064
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1065

E
ester.zhou 已提交
1066
**Return value**
W
wusongqing 已提交
1067

1068 1069
| Type              | Description                                               |
| ------------------ | --------------------------------------------------- |
E
ester.zhou 已提交
1070
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1071

E
ester.zhou 已提交
1072
**Example**
W
wusongqing 已提交
1073 1074 1075

```js
var bundle = {
E
ester.zhou 已提交
1076
    bundle: "bundleName1",
W
wusongqing 已提交
1077 1078
}
Notification.isNotificationEnabled(bundle).then((data) => {
1079
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1080 1081 1082 1083 1084
});
```



E
ester.zhou 已提交
1085
## Notification.isNotificationEnabled
W
wusongqing 已提交
1086

E
ester.zhou 已提交
1087
isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
W
wusongqing 已提交
1088

E
ester.zhou 已提交
1089
Checks whether notification is enabled for this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1090

E
ester.zhou 已提交
1091
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1092

E
ester.zhou 已提交
1093 1094
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1095 1096
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1097
**Parameters**
W
wusongqing 已提交
1098

E
ester.zhou 已提交
1099 1100 1101
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1102

E
ester.zhou 已提交
1103
**Example**
W
wusongqing 已提交
1104 1105 1106

```js
function isNotificationEnabledCallback(err, data) {
E
esterzhou 已提交
1107 1108 1109 1110 1111
    if (err.code) {
        console.info("isNotificationEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationEnabled success");
    }
W
wusongqing 已提交
1112 1113 1114 1115 1116 1117 1118
}

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



E
ester.zhou 已提交
1119
## Notification.isNotificationEnabled
W
wusongqing 已提交
1120

E
ester.zhou 已提交
1121
isNotificationEnabled(): Promise\<boolean\>
W
wusongqing 已提交
1122

E
ester.zhou 已提交
1123
Checks whether notification is enabled for this application. This API uses a promise to return the result.
W
wusongqing 已提交
1124

E
ester.zhou 已提交
1125
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1126

E
ester.zhou 已提交
1127 1128
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1129 1130
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1131
**Parameters**
W
wusongqing 已提交
1132

E
ester.zhou 已提交
1133 1134
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1135
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1136

E
ester.zhou 已提交
1137 1138 1139 1140 1141
**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1142

E
ester.zhou 已提交
1143
**Example**
W
wusongqing 已提交
1144 1145 1146

```js
Notification.isNotificationEnabled().then((data) => {
1147
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1148 1149 1150 1151 1152
});
```



E
ester.zhou 已提交
1153
## Notification.displayBadge
W
wusongqing 已提交
1154

E
ester.zhou 已提交
1155
displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1156

1157
Sets whether to enable the notification badge for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1158

E
ester.zhou 已提交
1159
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1160

E
ester.zhou 已提交
1161 1162
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1163 1164
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1165
**Parameters**
W
wusongqing 已提交
1166

E
ester.zhou 已提交
1167 1168
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
1169
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1170 1171
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1172

E
ester.zhou 已提交
1173
**Example**
W
wusongqing 已提交
1174 1175 1176

```js
function displayBadgeCallback(err) {
E
esterzhou 已提交
1177 1178 1179 1180 1181
    if (err.code) {
        console.info("displayBadge failed " + JSON.stringify(err));
    } else {
        console.info("displayBadge success");
    }
W
wusongqing 已提交
1182 1183
}
var bundle = {
E
ester.zhou 已提交
1184
    bundle: "bundleName1",
W
wusongqing 已提交
1185 1186 1187 1188 1189 1190
}
Notification.displayBadge(bundle, false, displayBadgeCallback);
```



E
ester.zhou 已提交
1191
## Notification.displayBadge
W
wusongqing 已提交
1192

E
ester.zhou 已提交
1193
displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
W
wusongqing 已提交
1194

1195
Sets whether to enable the notification badge for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1196

E
ester.zhou 已提交
1197
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1198

E
ester.zhou 已提交
1199 1200
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1201 1202
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1203
**Parameters**
W
wusongqing 已提交
1204

E
ester.zhou 已提交
1205 1206
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1207
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
E
ester.zhou 已提交
1208
| enable | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1209

E
ester.zhou 已提交
1210
**Example**
W
wusongqing 已提交
1211 1212 1213

```js
var bundle = {
E
ester.zhou 已提交
1214
    bundle: "bundleName1",
W
wusongqing 已提交
1215
}
E
ester.zhou 已提交
1216
Notification.displayBadge(bundle, false).then(() => {
1217
	console.info("displayBadge success");
W
wusongqing 已提交
1218 1219 1220 1221 1222
});
```



E
ester.zhou 已提交
1223
## Notification.isBadgeDisplayed
W
wusongqing 已提交
1224

E
ester.zhou 已提交
1225
isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
W
wusongqing 已提交
1226

1227
Checks whether the notification badge is enabled for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1228

E
ester.zhou 已提交
1229
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1230

E
ester.zhou 已提交
1231 1232
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1233 1234
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1235
**Parameters**
W
wusongqing 已提交
1236

E
ester.zhou 已提交
1237 1238
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
1239
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.              |
E
ester.zhou 已提交
1240
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1241

E
ester.zhou 已提交
1242
**Example**
W
wusongqing 已提交
1243 1244 1245

```js
function isBadgeDisplayedCallback(err, data) {
E
esterzhou 已提交
1246 1247 1248 1249 1250
    if (err.code) {
        console.info("isBadgeDisplayed failed " + JSON.stringify(err));
    } else {
        console.info("isBadgeDisplayed success");
    }
W
wusongqing 已提交
1251 1252
}
var bundle = {
E
ester.zhou 已提交
1253
    bundle: "bundleName1",
W
wusongqing 已提交
1254 1255 1256 1257 1258 1259
}
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```



E
ester.zhou 已提交
1260 1261 1262
## Notification.isBadgeDisplayed

isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
W
wusongqing 已提交
1263

1264
Checks whether the notification badge is enabled for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1265

E
ester.zhou 已提交
1266
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1267

E
ester.zhou 已提交
1268 1269
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1270 1271
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1272
**Parameters**
W
wusongqing 已提交
1273

E
ester.zhou 已提交
1274 1275
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1276
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1277

E
ester.zhou 已提交
1278
**Return value**
W
wusongqing 已提交
1279

E
ester.zhou 已提交
1280 1281 1282
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1283

E
ester.zhou 已提交
1284
**Example**
W
wusongqing 已提交
1285 1286 1287

```js
var bundle = {
E
ester.zhou 已提交
1288
    bundle: "bundleName1",
W
wusongqing 已提交
1289 1290
}
Notification.isBadgeDisplayed(bundle).then((data) => {
1291
	console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1292 1293 1294 1295 1296
});
```



E
ester.zhou 已提交
1297
## Notification.setSlotByBundle
W
wusongqing 已提交
1298

E
ester.zhou 已提交
1299
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1300

1301
Sets the notification slot for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1302

E
ester.zhou 已提交
1303
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1304

E
ester.zhou 已提交
1305 1306
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1307 1308
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1309
**Parameters**
W
wusongqing 已提交
1310

E
ester.zhou 已提交
1311 1312
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
1313
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1314 1315
| slot     | [NotificationSlot](#notificationslot)      | Yes  | Notification slot.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1316

E
ester.zhou 已提交
1317
**Example**
W
wusongqing 已提交
1318 1319 1320

```js
function setSlotByBundleCallback(err) {
E
esterzhou 已提交
1321 1322 1323 1324 1325
    if (err.code) {
        console.info("setSlotByBundle failed " + JSON.stringify(err));
    } else {
        console.info("setSlotByBundle success");
    }
W
wusongqing 已提交
1326 1327
}
var bundle = {
E
ester.zhou 已提交
1328
    bundle: "bundleName1",
W
wusongqing 已提交
1329 1330 1331 1332 1333 1334 1335 1336 1337
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```



E
ester.zhou 已提交
1338
## Notification.setSlotByBundle
W
wusongqing 已提交
1339

E
ester.zhou 已提交
1340
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
W
wusongqing 已提交
1341

1342
Sets the notification slot for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1343

E
ester.zhou 已提交
1344
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1345

E
ester.zhou 已提交
1346 1347
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1348 1349
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1350
**Parameters**
W
wusongqing 已提交
1351

E
ester.zhou 已提交
1352 1353
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1354 1355
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
| slot   | [NotificationSlot](#notificationslot) | Yes  | Notification slot.|
W
wusongqing 已提交
1356

E
ester.zhou 已提交
1357
**Example**
W
wusongqing 已提交
1358 1359 1360

```js
var bundle = {
E
ester.zhou 已提交
1361
    bundle: "bundleName1",
W
wusongqing 已提交
1362 1363 1364 1365
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
1366
Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
1367
	console.info("setSlotByBundle success");
W
wusongqing 已提交
1368 1369 1370 1371 1372
});
```



E
ester.zhou 已提交
1373
## Notification.getSlotsByBundle
W
wusongqing 已提交
1374

E
ester.zhou 已提交
1375
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
W
wusongqing 已提交
1376

1377
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1378

E
ester.zhou 已提交
1379
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1380

E
ester.zhou 已提交
1381 1382
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1383 1384
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1385
**Parameters**
W
wusongqing 已提交
1386

E
ester.zhou 已提交
1387 1388
| Name    | Type                                    | Mandatory| Description                |
| -------- | ---------------------------------------- | ---- | -------------------- |
1389
| bundle   | [BundleOption](#bundleoption)                             | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1390
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1391

E
ester.zhou 已提交
1392
**Example**
W
wusongqing 已提交
1393 1394 1395

```js
function getSlotsByBundleCallback(err, data) {
E
esterzhou 已提交
1396 1397 1398 1399 1400
    if (err.code) {
        console.info("getSlotsByBundle failed " + JSON.stringify(err));
    } else {
        console.info("getSlotsByBundle success");
    }
W
wusongqing 已提交
1401 1402
}
var bundle = {
E
ester.zhou 已提交
1403
    bundle: "bundleName1",
W
wusongqing 已提交
1404 1405 1406 1407 1408 1409
}
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```



E
ester.zhou 已提交
1410
## Notification.getSlotsByBundle
W
wusongqing 已提交
1411

E
ester.zhou 已提交
1412
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
W
wusongqing 已提交
1413

1414
Obtains the notification slots of a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1415

E
ester.zhou 已提交
1416
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1417

E
ester.zhou 已提交
1418 1419
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1420 1421
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1422
**Parameters**
W
wusongqing 已提交
1423

E
ester.zhou 已提交
1424 1425
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1426
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1427

E
ester.zhou 已提交
1428
**Return value**
W
wusongqing 已提交
1429

E
ester.zhou 已提交
1430 1431 1432 1433 1434
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1435 1436 1437

```js
var bundle = {
E
ester.zhou 已提交
1438
    bundle: "bundleName1",
W
wusongqing 已提交
1439 1440
}
Notification.getSlotsByBundle(bundle).then((data) => {
1441
	console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1442 1443 1444 1445 1446
});
```



E
ester.zhou 已提交
1447
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1448

E
ester.zhou 已提交
1449
getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
W
wusongqing 已提交
1450

1451
Obtains the number of notification slots of a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1452

E
ester.zhou 已提交
1453
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1454

E
ester.zhou 已提交
1455 1456
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1457 1458
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1459
**Parameters**
W
wusongqing 已提交
1460

E
ester.zhou 已提交
1461 1462
| Name    | Type                     | Mandatory| Description                  |
| -------- | ------------------------- | ---- | ---------------------- |
1463
| bundle   | [BundleOption](#bundleoption)              | Yes  | Bundle information of the application.            |
E
ester.zhou 已提交
1464
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1465

E
ester.zhou 已提交
1466
**Example**
W
wusongqing 已提交
1467 1468

```js
E
ester.zhou 已提交
1469
function getSlotNumByBundleCallback(err, data) {
E
esterzhou 已提交
1470 1471 1472 1473 1474
    if (err.code) {
        console.info("getSlotNumByBundle failed " + JSON.stringify(err));
    } else {
        console.info("getSlotNumByBundle success");
    }
W
wusongqing 已提交
1475 1476
}
var bundle = {
E
ester.zhou 已提交
1477
    bundle: "bundleName1",
W
wusongqing 已提交
1478 1479 1480 1481 1482 1483
}
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
```



E
ester.zhou 已提交
1484
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1485

E
ester.zhou 已提交
1486
getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
W
wusongqing 已提交
1487

1488
Obtains the number of notification slots of a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1489

E
ester.zhou 已提交
1490
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1491

E
ester.zhou 已提交
1492 1493
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1494 1495
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1496
**Parameters**
W
wusongqing 已提交
1497

E
ester.zhou 已提交
1498 1499
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1500
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1501

E
ester.zhou 已提交
1502
**Return value**
W
wusongqing 已提交
1503

E
ester.zhou 已提交
1504 1505 1506 1507 1508
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1509 1510 1511

```js
var bundle = {
E
ester.zhou 已提交
1512
    bundle: "bundleName1",
W
wusongqing 已提交
1513 1514
}
Notification.getSlotNumByBundle(bundle).then((data) => {
1515
	console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1516 1517 1518 1519 1520
});
```



E
ester.zhou 已提交
1521
## Notification.remove
W
wusongqing 已提交
1522

E
esterzhou 已提交
1523
remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1524

E
ester.zhou 已提交
1525
Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1526

E
ester.zhou 已提交
1527
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1528

E
ester.zhou 已提交
1529 1530
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1531 1532
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1533
**Parameters**
W
wusongqing 已提交
1534

E
ester.zhou 已提交
1535
| Name           | Type                               | Mandatory| Description                |
E
esterzhou 已提交
1536
| --------------- |   ----------------------------------| ---- | -------------------- |
1537
| bundle          | [BundleOption](#bundleoption)       | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1538
| notificationKey | [NotificationKey](#notificationkey) | Yes  | Notification key.            |
E
esterzhou 已提交
1539
| reason          | [RemoveReason](#removereason9)      | Yes  | Indicates the reason for deleting a notification.        |
E
ester.zhou 已提交
1540
| callback        | AsyncCallback\<void\>               | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1541

E
ester.zhou 已提交
1542
**Example**
W
wusongqing 已提交
1543 1544 1545

```js
function removeCallback(err) {
E
esterzhou 已提交
1546 1547 1548 1549 1550
    if (err.code) {
        console.info("remove failed " + JSON.stringify(err));
    } else {
        console.info("remove success");
    }
W
wusongqing 已提交
1551 1552
}
var bundle = {
E
ester.zhou 已提交
1553
    bundle: "bundleName1",
W
wusongqing 已提交
1554 1555
}
var notificationKey = {
E
ester.zhou 已提交
1556 1557
    id: 0,
    label: "label",
W
wusongqing 已提交
1558
}
E
esterzhou 已提交
1559 1560
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason, removeCallback);
W
wusongqing 已提交
1561 1562 1563 1564
```



E
ester.zhou 已提交
1565
## Notification.remove
W
wusongqing 已提交
1566

E
esterzhou 已提交
1567
remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason): Promise\<void\>
W
wusongqing 已提交
1568

E
ester.zhou 已提交
1569
Removes a notification for a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
1570

E
ester.zhou 已提交
1571
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1572

E
ester.zhou 已提交
1573 1574
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1575 1576
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1577
**Parameters**
W
wusongqing 已提交
1578

E
ester.zhou 已提交
1579 1580
| Name           | Type           | Mandatory| Description      |
| --------------- | --------------- | ---- | ---------- |
1581
| bundle          | [BundleOption](#bundleoption)    | Yes  | Bundle information of the application.|
E
ester.zhou 已提交
1582
| notificationKey | [NotificationKey](#notificationkey) | Yes  | Notification key.  |
E
esterzhou 已提交
1583
| reason          | [RemoveReason](#removereason9) | Yes  | Reason for deleting the notification.        |
W
wusongqing 已提交
1584

E
ester.zhou 已提交
1585
**Example**
W
wusongqing 已提交
1586 1587 1588

```js
var bundle = {
E
ester.zhou 已提交
1589
    bundle: "bundleName1",
W
wusongqing 已提交
1590 1591
}
var notificationKey = {
E
ester.zhou 已提交
1592 1593
    id: 0,
    label: "label",
W
wusongqing 已提交
1594
}
E
esterzhou 已提交
1595 1596
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason).then(() => {
1597
	console.info("remove success");
W
wusongqing 已提交
1598 1599 1600 1601 1602
});
```



E
ester.zhou 已提交
1603
## Notification.remove
W
wusongqing 已提交
1604

E
esterzhou 已提交
1605
remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1606

E
ester.zhou 已提交
1607
Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1608

E
ester.zhou 已提交
1609
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1610

E
ester.zhou 已提交
1611 1612
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1613 1614
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1615
**Parameters**
W
wusongqing 已提交
1616

E
ester.zhou 已提交
1617 1618
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
1619 1620
| hashCode | string                | Yes  | Unique notification ID. It is the **hashCode** in the [NotificationRequest](#notificationrequest) object of [SubscribeCallbackData](#subscribecallbackdata) of the [onConsume](#onconsume) callback.|
| reason   | [RemoveReason](#removereason9) | Yes  | Indicates the reason for deleting a notification.        |
E
ester.zhou 已提交
1621
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1622

E
ester.zhou 已提交
1623
**Example**
W
wusongqing 已提交
1624 1625

```js
E
ester.zhou 已提交
1626 1627
var hashCode = 'hashCode'

W
wusongqing 已提交
1628
function removeCallback(err) {
E
esterzhou 已提交
1629 1630 1631 1632 1633
    if (err.code) {
        console.info("remove failed " + JSON.stringify(err));
    } else {
        console.info("remove success");
    }
W
wusongqing 已提交
1634
}
E
esterzhou 已提交
1635 1636
var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE;
Notification.remove(hashCode, reason, removeCallback);
W
wusongqing 已提交
1637 1638 1639 1640
```



E
ester.zhou 已提交
1641
## Notification.remove
W
wusongqing 已提交
1642

E
esterzhou 已提交
1643
remove(hashCode: string, reason: RemoveReason): Promise\<void\>
W
wusongqing 已提交
1644

E
ester.zhou 已提交
1645
Removes a notification for a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
1646

E
ester.zhou 已提交
1647
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1648

E
ester.zhou 已提交
1649 1650
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1651 1652
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1653
**Parameters**
W
wusongqing 已提交
1654

E
ester.zhou 已提交
1655 1656 1657
| Name    | Type      | Mandatory| Description      |
| -------- | ---------- | ---- | ---------- |
| hashCode | string | Yes  | Unique notification ID.|
1658
| reason   | [RemoveReason](#removereason9) | Yes  | Reason for deleting the notification.        |
W
wusongqing 已提交
1659

E
ester.zhou 已提交
1660
**Example**
W
wusongqing 已提交
1661 1662

```js
E
ester.zhou 已提交
1663
var hashCode = 'hashCode'
E
esterzhou 已提交
1664 1665
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(hashCode, reason).then(() => {
1666
	console.info("remove success");
W
wusongqing 已提交
1667 1668 1669 1670 1671
});
```



E
ester.zhou 已提交
1672
## Notification.removeAll
W
wusongqing 已提交
1673

E
ester.zhou 已提交
1674
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1675

1676
Removes all notifications for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1677

E
ester.zhou 已提交
1678
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1679

E
ester.zhou 已提交
1680 1681
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1682 1683
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1684
**Parameters**
W
wusongqing 已提交
1685

E
ester.zhou 已提交
1686 1687
| Name    | Type                 | Mandatory| Description                        |
| -------- | --------------------- | ---- | ---------------------------- |
1688
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
1689
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1690

E
ester.zhou 已提交
1691
**Example**
W
wusongqing 已提交
1692 1693 1694

```js
function removeAllCallback(err) {
E
esterzhou 已提交
1695 1696 1697 1698 1699
    if (err.code) {
        console.info("removeAll failed " + JSON.stringify(err));
    } else {
        console.info("removeAll success");
    }
W
wusongqing 已提交
1700 1701
}
var bundle = {
E
ester.zhou 已提交
1702
    bundle: "bundleName1",
W
wusongqing 已提交
1703 1704 1705 1706 1707 1708
}
Notification.removeAll(bundle, removeAllCallback);
```



E
ester.zhou 已提交
1709
## Notification.removeAll
W
wusongqing 已提交
1710

E
ester.zhou 已提交
1711
removeAll(callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1712

E
ester.zhou 已提交
1713
Removes all notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1714

E
ester.zhou 已提交
1715
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1716

E
ester.zhou 已提交
1717 1718
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1719 1720
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1721
**Parameters**
W
wusongqing 已提交
1722

E
ester.zhou 已提交
1723 1724 1725
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1726

E
ester.zhou 已提交
1727
**Example**
W
wusongqing 已提交
1728 1729 1730

```js
function removeAllCallback(err) {
E
esterzhou 已提交
1731 1732 1733 1734 1735
    if (err.code) {
        console.info("removeAll failed " + JSON.stringify(err));
    } else {
        console.info("removeAll success");
    }
W
wusongqing 已提交
1736 1737 1738 1739 1740 1741 1742
}

Notification.removeAll(removeAllCallback);
```



E
ester.zhou 已提交
1743
## Notification.removeAll
W
wusongqing 已提交
1744

E
ester.zhou 已提交
1745
removeAll(bundle?: BundleOption): Promise\<void\>
W
wusongqing 已提交
1746

1747
Removes all notifications for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1748

E
ester.zhou 已提交
1749
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1750

E
ester.zhou 已提交
1751 1752
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1753 1754
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1755
**Parameters**
W
wusongqing 已提交
1756

E
ester.zhou 已提交
1757 1758
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1759
| bundle | [BundleOption](#bundleoption) | No  | Bundle information of the application.|
W
wusongqing 已提交
1760

E
ester.zhou 已提交
1761
**Example**
W
wusongqing 已提交
1762 1763

```js
1764
// If no application is specified, notifications of all applications are deleted.
E
ester.zhou 已提交
1765
Notification.removeAll().then(() => {
1766
	console.info("removeAll success");
W
wusongqing 已提交
1767 1768 1769
});
```

E
ester.zhou 已提交
1770
## Notification.removeAll<sup>8+</sup>
W
wusongqing 已提交
1771

E
ester.zhou 已提交
1772
removeAll(userId: number, callback: AsyncCallback\<void>): void
W
wusongqing 已提交
1773

E
ester.zhou 已提交
1774
Removes all notifications for a specified user. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1775

E
ester.zhou 已提交
1776
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1777

E
ester.zhou 已提交
1778 1779
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1780 1781
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1782
**Parameters**
W
wusongqing 已提交
1783

E
ester.zhou 已提交
1784 1785
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1786
| userId | number | Yes  | User ID.|
E
ester.zhou 已提交
1787
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1788

E
ester.zhou 已提交
1789
**Example**
W
wusongqing 已提交
1790

E
ester.zhou 已提交
1791 1792
```js
function removeAllCallback(err) {
E
esterzhou 已提交
1793 1794 1795 1796 1797
    if (err.code) {
        console.info("removeAll failed " + JSON.stringify(err));
    } else {
        console.info("removeAll success");
    }
E
ester.zhou 已提交
1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811
}

var userId = 1
Notification.removeAll(userId, removeAllCallback);
```

## Notification.removeAll<sup>8+</sup>

removeAll(userId: number): Promise\<void>

Removes all notifications for a specified user. This API uses a promise to return the result.

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

E
ester.zhou 已提交
1812 1813
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1814 1815
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1816 1817
**Parameters**

E
ester.zhou 已提交
1818 1819
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
1820
| userId | number | Yes  | User ID.|
E
ester.zhou 已提交
1821 1822 1823 1824 1825

**Example**

```js
var userId = 1
1826 1827 1828
Notification.removeAll(userId).then(() => {
	console.info("removeAll success");
});
E
ester.zhou 已提交
1829 1830 1831 1832
```


## Notification.getAllActiveNotifications
W
wusongqing 已提交
1833

E
ester.zhou 已提交
1834
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
W
wusongqing 已提交
1835

E
ester.zhou 已提交
1836 1837 1838 1839
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

E
ester.zhou 已提交
1840 1841
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1842 1843
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
1844 1845
**Parameters**

E
ester.zhou 已提交
1846 1847 1848
| Name    | Type                                                        | Mandatory| Description                |
| -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
1849 1850

**Example**
W
wusongqing 已提交
1851 1852 1853

```js
function getAllActiveNotificationsCallback(err, data) {
E
esterzhou 已提交
1854 1855 1856 1857 1858
    if (err.code) {
        console.info("getAllActiveNotifications failed " + JSON.stringify(err));
    } else {
        console.info("getAllActiveNotifications success");
    }
W
wusongqing 已提交
1859 1860 1861 1862 1863 1864 1865
}

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



E
ester.zhou 已提交
1866
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1867

E
ester.zhou 已提交
1868
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
W
wusongqing 已提交
1869

E
ester.zhou 已提交
1870
Obtains all active notifications. This API uses a promise to return the result.
W
wusongqing 已提交
1871

E
ester.zhou 已提交
1872
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1873

E
ester.zhou 已提交
1874 1875
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1876
**System API**: This is a system API and cannot be called by third-party applications.
E
ester.zhou 已提交
1877

E
ester.zhou 已提交
1878
**Return value**
W
wusongqing 已提交
1879

E
ester.zhou 已提交
1880 1881 1882
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1883

E
ester.zhou 已提交
1884
**Example**
W
wusongqing 已提交
1885 1886 1887

```js
Notification.getAllActiveNotifications().then((data) => {
1888
	console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1889 1890 1891 1892 1893
});
```



E
ester.zhou 已提交
1894
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1895

E
ester.zhou 已提交
1896
getActiveNotificationCount(callback: AsyncCallback\<number\>): void
W
wusongqing 已提交
1897

1898
Obtains the number of active notifications of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1899

E
ester.zhou 已提交
1900
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1901

E
ester.zhou 已提交
1902
**Parameters**
W
wusongqing 已提交
1903

E
ester.zhou 已提交
1904 1905 1906
| Name    | Type                  | Mandatory| Description                  |
| -------- | ---------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1907

E
ester.zhou 已提交
1908
**Example**
W
wusongqing 已提交
1909 1910 1911

```js
function getActiveNotificationCountCallback(err, data) {
E
esterzhou 已提交
1912 1913 1914 1915 1916
    if (err.code) {
        console.info("getActiveNotificationCount failed " + JSON.stringify(err));
    } else {
        console.info("getActiveNotificationCount success");
    }
W
wusongqing 已提交
1917 1918 1919 1920 1921 1922 1923
}

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



E
ester.zhou 已提交
1924
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1925

E
ester.zhou 已提交
1926
getActiveNotificationCount(): Promise\<number\>
W
wusongqing 已提交
1927

1928
Obtains the number of active notifications of this application. This API uses a promise to return the result.
W
wusongqing 已提交
1929

E
ester.zhou 已提交
1930
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1931

E
ester.zhou 已提交
1932
**Return value**
W
wusongqing 已提交
1933

1934 1935
| Type             | Description                                       |
| ----------------- | ------------------------------------------- |
E
ester.zhou 已提交
1936
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1937

E
ester.zhou 已提交
1938
**Example**
W
wusongqing 已提交
1939 1940 1941

```js
Notification.getActiveNotificationCount().then((data) => {
1942
	console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1943 1944 1945 1946 1947
});
```



E
ester.zhou 已提交
1948
## Notification.getActiveNotifications
W
wusongqing 已提交
1949

E
ester.zhou 已提交
1950
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
W
wusongqing 已提交
1951

E
ester.zhou 已提交
1952
Obtains active notifications of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1953

E
ester.zhou 已提交
1954
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1955

E
ester.zhou 已提交
1956
**Parameters**
W
wusongqing 已提交
1957

E
ester.zhou 已提交
1958 1959 1960
| Name    | Type                                                        | Mandatory| Description                          |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1961

E
ester.zhou 已提交
1962
**Example**
W
wusongqing 已提交
1963 1964 1965

```js
function getActiveNotificationsCallback(err, data) {
E
esterzhou 已提交
1966 1967 1968 1969 1970
    if (err.code) {
        console.info("getActiveNotifications failed " + JSON.stringify(err));
    } else {
        console.info("getActiveNotifications success");
    }
W
wusongqing 已提交
1971 1972 1973 1974 1975 1976 1977
}

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



E
ester.zhou 已提交
1978
## Notification.getActiveNotifications
W
wusongqing 已提交
1979

E
ester.zhou 已提交
1980
getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
W
wusongqing 已提交
1981

E
ester.zhou 已提交
1982
Obtains active notifications of this application. This API uses a promise to return the result.
W
wusongqing 已提交
1983

E
ester.zhou 已提交
1984
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1985

E
ester.zhou 已提交
1986
**Return value**
W
wusongqing 已提交
1987

1988 1989
| Type                                                        | Description                                   |
| ------------------------------------------------------------ | --------------------------------------- |
E
ester.zhou 已提交
1990
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1991

E
ester.zhou 已提交
1992
**Example**
W
wusongqing 已提交
1993 1994 1995

```js
Notification.getActiveNotifications().then((data) => {
1996
	console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1997 1998 1999 2000 2001
});
```



E
ester.zhou 已提交
2002
## Notification.cancelGroup<sup>8+</sup>
W
wusongqing 已提交
2003

E
ester.zhou 已提交
2004
cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
2005

2006
Cancels notifications under a notification group of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2007

E
ester.zhou 已提交
2008
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2009

E
ester.zhou 已提交
2010
**Parameters**
W
wusongqing 已提交
2011

E
ester.zhou 已提交
2012 2013
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
2014
| groupName | string                | Yes  | Name of the notification group, which is specified through [NotificationRequest](#notificationrequest) when the notification is published.|
E
ester.zhou 已提交
2015
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2016

E
ester.zhou 已提交
2017
**Example**
W
wusongqing 已提交
2018 2019 2020

```js
function cancelGroupCallback(err) {
E
esterzhou 已提交
2021 2022 2023 2024 2025
    if (err.code) {
        console.info("cancelGroup failed " + JSON.stringify(err));
    } else {
        console.info("cancelGroup success");
    }
W
wusongqing 已提交
2026 2027 2028 2029 2030 2031 2032 2033 2034
}

var groupName = "GroupName";

Notification.cancelGroup(groupName, cancelGroupCallback);
```



E
ester.zhou 已提交
2035
## Notification.cancelGroup<sup>8+</sup>
W
wusongqing 已提交
2036

E
ester.zhou 已提交
2037
cancelGroup(groupName: string): Promise\<void\>
W
wusongqing 已提交
2038

2039
Cancels notifications under a notification group of this application. This API uses a promise to return the result.
W
wusongqing 已提交
2040

E
ester.zhou 已提交
2041
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2042

E
ester.zhou 已提交
2043
**Parameters**
W
wusongqing 已提交
2044

E
ester.zhou 已提交
2045 2046 2047
| Name     | Type  | Mandatory| Description          |
| --------- | ------ | ---- | -------------- |
| groupName | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
2048

E
ester.zhou 已提交
2049
**Example**
W
wusongqing 已提交
2050 2051 2052 2053

```js
var groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => {
2054
	console.info("cancelGroup success");
W
wusongqing 已提交
2055 2056 2057 2058 2059
});
```



E
ester.zhou 已提交
2060
## Notification.removeGroupByBundle<sup>8+</sup>
W
wusongqing 已提交
2061

E
ester.zhou 已提交
2062
removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
2063

2064
Removes notifications under a notification group of a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2065

E
ester.zhou 已提交
2066
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2067

E
ester.zhou 已提交
2068 2069
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2070 2071
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2072
**Parameters**
W
wusongqing 已提交
2073

E
ester.zhou 已提交
2074 2075
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
2076
| bundle    | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
2077 2078
| groupName | string                | Yes  | Name of the notification group.              |
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2079

E
ester.zhou 已提交
2080
**Example**
W
wusongqing 已提交
2081 2082 2083

```js
function removeGroupByBundleCallback(err) {
E
esterzhou 已提交
2084 2085 2086 2087 2088
    if (err.code) {
        console.info("removeGroupByBundle failed " + JSON.stringify(err));
    } else {
        console.info("removeGroupByBundle success");
    }
W
wusongqing 已提交
2089 2090 2091 2092 2093 2094 2095 2096 2097 2098
}

var bundleOption = {bundle: "Bundle"};
var groupName = "GroupName";

Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
```



E
ester.zhou 已提交
2099
## Notification.removeGroupByBundle<sup>8+</sup>
W
wusongqing 已提交
2100

E
ester.zhou 已提交
2101
removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
W
wusongqing 已提交
2102

2103
Removes notifications under a notification group of a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
2104

E
ester.zhou 已提交
2105
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2106

E
ester.zhou 已提交
2107 2108
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2109 2110
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2111
**Parameters**
W
wusongqing 已提交
2112

E
ester.zhou 已提交
2113 2114
| Name     | Type        | Mandatory| Description          |
| --------- | ------------ | ---- | -------------- |
2115
| bundle    | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.    |
E
ester.zhou 已提交
2116
| groupName | string       | Yes  | Name of the notification group.|
W
wusongqing 已提交
2117

E
ester.zhou 已提交
2118
**Example**
W
wusongqing 已提交
2119 2120 2121 2122 2123

```js
var bundleOption = {bundle: "Bundle"};
var groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
2124
	console.info("removeGroupByBundle success");
W
wusongqing 已提交
2125 2126 2127 2128 2129
});
```



E
ester.zhou 已提交
2130
## Notification.setDoNotDisturbDate<sup>8+</sup>
W
wusongqing 已提交
2131

E
ester.zhou 已提交
2132
setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
2133

E
ester.zhou 已提交
2134
Sets the DND time. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2135

E
ester.zhou 已提交
2136
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2137

E
ester.zhou 已提交
2138 2139
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2140 2141
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2142
**Parameters**
W
wusongqing 已提交
2143

E
ester.zhou 已提交
2144 2145 2146 2147
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2148

E
ester.zhou 已提交
2149
**Example**
W
wusongqing 已提交
2150 2151 2152

```js
function setDoNotDisturbDateCallback(err) {
E
esterzhou 已提交
2153 2154 2155 2156 2157
    if (err.code) {
        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("setDoNotDisturbDate success");
    }
W
wusongqing 已提交
2158 2159 2160
}

var doNotDisturbDate = {
E
ester.zhou 已提交
2161
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2162 2163 2164 2165 2166 2167 2168 2169 2170
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
```



E
ester.zhou 已提交
2171
## Notification.setDoNotDisturbDate<sup>8+</sup>
W
wusongqing 已提交
2172

E
ester.zhou 已提交
2173
setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
W
wusongqing 已提交
2174

E
ester.zhou 已提交
2175
Sets the DND time. This API uses a promise to return the result.
W
wusongqing 已提交
2176

E
ester.zhou 已提交
2177
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2178

E
ester.zhou 已提交
2179 2180
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2181 2182
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2183
**Parameters**
W
wusongqing 已提交
2184

E
ester.zhou 已提交
2185 2186 2187
| Name| Type            | Mandatory| Description          |
| ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
2188

E
ester.zhou 已提交
2189
**Example**
W
wusongqing 已提交
2190 2191 2192

```js
var doNotDisturbDate = {
E
ester.zhou 已提交
2193
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2194 2195 2196 2197
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
2198
	console.info("setDoNotDisturbDate success");
W
wusongqing 已提交
2199 2200 2201 2202
});
```


E
ester.zhou 已提交
2203 2204 2205 2206 2207 2208 2209 2210
## Notification.setDoNotDisturbDate<sup>8+</sup>

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

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

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

E
ester.zhou 已提交
2211 2212
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2213 2214
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2215 2216
**Parameters**

E
ester.zhou 已提交
2217 2218 2219
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
2220
| userId   | number                | Yes  | ID of the user for whom you want to set the DND time.|
E
ester.zhou 已提交
2221
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2222 2223 2224 2225 2226

**Example**

```js
function setDoNotDisturbDateCallback(err) {
E
esterzhou 已提交
2227 2228 2229 2230 2231
    if (err.code) {
        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("setDoNotDisturbDate success");
    }
E
ester.zhou 已提交
2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252
}

var doNotDisturbDate = {
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

var userId = 1
Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
```



## Notification.setDoNotDisturbDate<sup>8+</sup>

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

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

**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2253

E
ester.zhou 已提交
2254 2255
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2256 2257
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2258
**Parameters**
W
wusongqing 已提交
2259

E
ester.zhou 已提交
2260 2261 2262
| Name  | Type            | Mandatory| Description          |
| ------ | ---------------- | ---- | -------------- |
| date   | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
2263
| userId | number           | Yes  | ID of the user for whom you want to set the DND time.|
W
wusongqing 已提交
2264

E
ester.zhou 已提交
2265
**Example**
W
wusongqing 已提交
2266

E
ester.zhou 已提交
2267 2268 2269 2270 2271 2272 2273 2274 2275 2276
```js
var doNotDisturbDate = {
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

var userId = 1

Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
2277
	console.info("setDoNotDisturbDate success");
E
ester.zhou 已提交
2278 2279 2280 2281 2282
});
```


## Notification.getDoNotDisturbDate<sup>8+</sup>
W
wusongqing 已提交
2283

E
ester.zhou 已提交
2284
getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
W
wusongqing 已提交
2285

E
ester.zhou 已提交
2286
Obtains the DND time. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2287

E
ester.zhou 已提交
2288
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2289

E
ester.zhou 已提交
2290 2291
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2292 2293
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2294 2295
**Parameters**

E
ester.zhou 已提交
2296 2297 2298
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2299 2300

**Example**
W
wusongqing 已提交
2301 2302

```js
2303
function getDoNotDisturbDateCallback(err, data) {
E
esterzhou 已提交
2304 2305 2306 2307 2308
    if (err.code) {
        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("getDoNotDisturbDate success");
    }
W
wusongqing 已提交
2309 2310 2311 2312 2313 2314 2315
}

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



E
ester.zhou 已提交
2316
## Notification.getDoNotDisturbDate<sup>8+</sup>
W
wusongqing 已提交
2317

E
ester.zhou 已提交
2318
getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
W
wusongqing 已提交
2319

E
ester.zhou 已提交
2320
Obtains the DND time. This API uses a promise to return the result.
W
wusongqing 已提交
2321

E
ester.zhou 已提交
2322
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2323

E
ester.zhou 已提交
2324 2325
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2326 2327
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2328
**Return value**
W
wusongqing 已提交
2329

2330 2331
| Type                                             | Description                                     |
| ------------------------------------------------- | ----------------------------------------- |
E
ester.zhou 已提交
2332
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2333

E
ester.zhou 已提交
2334
**Example**
W
wusongqing 已提交
2335 2336 2337

```js
Notification.getDoNotDisturbDate().then((data) => {
2338
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
W
wusongqing 已提交
2339 2340 2341 2342
});
```


E
ester.zhou 已提交
2343 2344 2345 2346 2347 2348 2349 2350
## Notification.getDoNotDisturbDate<sup>8+</sup>

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

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

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

E
ester.zhou 已提交
2351 2352 2353 2354
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2355 2356
**Parameters**

E
ester.zhou 已提交
2357 2358 2359 2360
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
| userId   | number                            | Yes  | User ID.|
E
ester.zhou 已提交
2361 2362 2363 2364 2365

**Example**

```js
function getDoNotDisturbDateCallback(err,data) {
E
esterzhou 已提交
2366 2367 2368 2369 2370
    if (err.code) {
        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("getDoNotDisturbDate success");
    }
E
ester.zhou 已提交
2371 2372 2373 2374 2375 2376 2377 2378 2379 2380
}

var userId = 1

Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
```



## Notification.getDoNotDisturbDate<sup>8+</sup>
W
wusongqing 已提交
2381

E
ester.zhou 已提交
2382
getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
W
wusongqing 已提交
2383

E
ester.zhou 已提交
2384
Obtains the DND time of a specified user. This API uses a promise to return the result.
W
wusongqing 已提交
2385

E
ester.zhou 已提交
2386
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2387

E
ester.zhou 已提交
2388 2389 2390 2391
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2392
**Parameters**
W
wusongqing 已提交
2393

E
ester.zhou 已提交
2394 2395 2396
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| userId   | number                            | Yes  | User ID.|
W
wusongqing 已提交
2397

E
ester.zhou 已提交
2398
**Return value**
W
wusongqing 已提交
2399

2400 2401
| Type                                             | Description                                     |
| ------------------------------------------------- | ----------------------------------------- |
E
ester.zhou 已提交
2402
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2403

E
ester.zhou 已提交
2404 2405 2406 2407 2408 2409
**Example**

```js
var userId = 1

Notification.getDoNotDisturbDate(userId).then((data) => {
2410
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
E
ester.zhou 已提交
2411 2412 2413 2414 2415 2416 2417 2418
});
```


## Notification.supportDoNotDisturbMode<sup>8+</sup>

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

2419
Checks whether DND mode is supported. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
2420 2421 2422

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

E
ester.zhou 已提交
2423 2424
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2425 2426
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2427 2428
**Parameters**

E
ester.zhou 已提交
2429 2430 2431
| Name    | Type                    | Mandatory| Description                            |
| -------- | ------------------------ | ---- | -------------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2432 2433

**Example**
W
wusongqing 已提交
2434 2435 2436

```js
function supportDoNotDisturbModeCallback(err,data) {
E
esterzhou 已提交
2437 2438 2439 2440 2441
    if (err.code) {
        console.info("supportDoNotDisturbMode failed " + JSON.stringify(err));
    } else {
        console.info("supportDoNotDisturbMode success");
    }
W
wusongqing 已提交
2442 2443 2444 2445 2446 2447 2448
}

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



E
ester.zhou 已提交
2449
## Notification.supportDoNotDisturbMode<sup>8+</sup>
W
wusongqing 已提交
2450

E
ester.zhou 已提交
2451
supportDoNotDisturbMode(): Promise\<boolean\>
W
wusongqing 已提交
2452

2453
Checks whether DND mode is supported. This API uses a promise to return the result.
W
wusongqing 已提交
2454

E
ester.zhou 已提交
2455
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2456

E
ester.zhou 已提交
2457 2458
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2459 2460
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2461
**Return value**
W
wusongqing 已提交
2462

E
ester.zhou 已提交
2463 2464 2465
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2466

E
ester.zhou 已提交
2467
**Example**
W
wusongqing 已提交
2468 2469 2470

```js
Notification.supportDoNotDisturbMode().then((data) => {
2471
	console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
W
wusongqing 已提交
2472 2473 2474 2475 2476
});
```



E
ester.zhou 已提交
2477
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2478 2479 2480

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

E
ester.zhou 已提交
2481
Checks whether a specified template exists. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2482

E
ester.zhou 已提交
2483
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2484

E
ester.zhou 已提交
2485 2486 2487
**Parameters**

| Name      | Type                    | Mandatory| Description                      |
W
wusongqing 已提交
2488
| ------------ | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
2489 2490
| templateName | string                   | Yes  | Template name.                  |
| callback     | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2491

E
ester.zhou 已提交
2492
**Example**
W
wusongqing 已提交
2493 2494 2495 2496

```javascript
var templateName = 'process';
function isSupportTemplateCallback(err, data) {
E
esterzhou 已提交
2497 2498 2499 2500 2501
    if (err.code) {
        console.info("isSupportTemplate failed " + JSON.stringify(err));
    } else {
        console.info("isSupportTemplate success");
    }
W
wusongqing 已提交
2502 2503 2504 2505 2506 2507 2508
}

Notification.isSupportTemplate(templateName, isSupportTemplateCallback);
```



E
ester.zhou 已提交
2509
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2510 2511 2512

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

E
ester.zhou 已提交
2513
Checks whether a specified template exists. This API uses a promise to return the result.
W
wusongqing 已提交
2514

E
ester.zhou 已提交
2515
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2516

E
ester.zhou 已提交
2517 2518 2519
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2520
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2521
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2522

E
ester.zhou 已提交
2523
**Return value**
W
wusongqing 已提交
2524

E
ester.zhou 已提交
2525
| Type              | Description           |
W
wusongqing 已提交
2526 2527 2528
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2529
**Example**
W
wusongqing 已提交
2530 2531 2532 2533 2534

```javascript
var templateName = 'process';

Notification.isSupportTemplate(templateName).then((data) => {
E
esterzhou 已提交
2535
    console.info("isSupportTemplate success, data: " + JSON.stringify(data));
W
wusongqing 已提交
2536 2537 2538 2539 2540
});
```



E
ester.zhou 已提交
2541
## Notification.requestEnableNotification<sup>8+</sup>
W
wusongqing 已提交
2542

E
ester.zhou 已提交
2543
requestEnableNotification(callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
2544

E
ester.zhou 已提交
2545
Requests notification to be enabled for this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2546

E
ester.zhou 已提交
2547
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2548

E
ester.zhou 已提交
2549
**Parameters**
W
wusongqing 已提交
2550

E
ester.zhou 已提交
2551 2552 2553
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2554

E
ester.zhou 已提交
2555
**Example**
W
wusongqing 已提交
2556

E
ester.zhou 已提交
2557
```javascript
2558
function requestEnableNotificationCallback(err) {
E
esterzhou 已提交
2559 2560 2561 2562 2563
    if (err.code) {
        console.info("requestEnableNotification failed " + JSON.stringify(err));
    } else {
        console.info("requestEnableNotification success");
    }
E
ester.zhou 已提交
2564 2565
};

E
ester.zhou 已提交
2566
Notification.requestEnableNotification(requestEnableNotificationCallback);
W
wusongqing 已提交
2567 2568 2569 2570
```



E
ester.zhou 已提交
2571
## Notification.requestEnableNotification<sup>8+</sup>
W
wusongqing 已提交
2572

E
ester.zhou 已提交
2573
requestEnableNotification(): Promise\<void\>
W
wusongqing 已提交
2574

E
ester.zhou 已提交
2575
Requests notification to be enabled for this application. This API uses a promise to return the result.
W
wusongqing 已提交
2576

E
ester.zhou 已提交
2577
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2578

E
ester.zhou 已提交
2579
**Example**
W
wusongqing 已提交
2580

E
ester.zhou 已提交
2581
```javascript
2582 2583 2584
Notification.requestEnableNotification().then(() => {
    console.info("requestEnableNotification success");
});
E
ester.zhou 已提交
2585
```
W
wusongqing 已提交
2586 2587


E
ester.zhou 已提交
2588
## Notification.enableDistributed<sup>8+</sup>
W
wusongqing 已提交
2589

E
ester.zhou 已提交
2590
enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
2591

E
ester.zhou 已提交
2592
Sets whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2593

E
ester.zhou 已提交
2594
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2595

E
ester.zhou 已提交
2596 2597
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2598 2599
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2600
**Parameters**
W
wusongqing 已提交
2601

E
ester.zhou 已提交
2602 2603
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
2604
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|
E
ester.zhou 已提交
2605
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2606

E
ester.zhou 已提交
2607
**Example**
W
wusongqing 已提交
2608

E
ester.zhou 已提交
2609
```javascript
2610
function enabledNotificationCallback(err) {
E
esterzhou 已提交
2611 2612 2613 2614 2615
    if (err.code) {
        console.info("enableDistributed failed " + JSON.stringify(err));
    } else {
        console.info("enableDistributed success");
    }
E
ester.zhou 已提交
2616
};
W
wusongqing 已提交
2617

E
ester.zhou 已提交
2618
var enable = true
W
wusongqing 已提交
2619

E
ester.zhou 已提交
2620
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2621 2622 2623 2624
```



E
ester.zhou 已提交
2625
## Notification.enableDistributed<sup>8+</sup>
W
wusongqing 已提交
2626

E
ester.zhou 已提交
2627
enableDistributed(enable: boolean): Promise\<void>
W
wusongqing 已提交
2628

E
ester.zhou 已提交
2629
Sets whether this device supports distributed notifications. This API uses a promise to return the result.
W
wusongqing 已提交
2630

E
ester.zhou 已提交
2631
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2632

E
ester.zhou 已提交
2633 2634
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2635 2636
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2637
**Parameters**
W
wusongqing 已提交
2638

E
ester.zhou 已提交
2639 2640
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
2641
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|
W
wusongqing 已提交
2642

E
ester.zhou 已提交
2643
**Example**
W
wusongqing 已提交
2644

E
ester.zhou 已提交
2645 2646
```javascript
var enable = true
2647 2648 2649
Notification.enableDistributed(enable).then(() => {
    console.info("enableDistributed success");
});
E
ester.zhou 已提交
2650
```
W
wusongqing 已提交
2651 2652


E
ester.zhou 已提交
2653
## Notification.isDistributedEnabled<sup>8+</sup>
W
wusongqing 已提交
2654

E
ester.zhou 已提交
2655
isDistributedEnabled(callback: AsyncCallback\<boolean>): void
W
wusongqing 已提交
2656

2657
Checks whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2658

E
ester.zhou 已提交
2659
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2660

E
ester.zhou 已提交
2661
**Parameters**
W
wusongqing 已提交
2662

E
ester.zhou 已提交
2663 2664 2665
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2666

E
ester.zhou 已提交
2667
**Example**
W
wusongqing 已提交
2668

E
ester.zhou 已提交
2669
```javascript
2670
function isDistributedEnabledCallback(err, data) {
E
esterzhou 已提交
2671 2672 2673
    if (err.code) {
        console.info("isDistributedEnabled failed " + JSON.stringify(err));
    } else {
2674
        console.info("isDistributedEnabled success " + JSON.stringify(data));
E
esterzhou 已提交
2675
    }
E
ester.zhou 已提交
2676
};
W
wusongqing 已提交
2677

E
ester.zhou 已提交
2678
Notification.isDistributedEnabled(isDistributedEnabledCallback);
E
ester.zhou 已提交
2679
```
W
wusongqing 已提交
2680 2681 2682



E
ester.zhou 已提交
2683
## Notification.isDistributedEnabled<sup>8+</sup>
W
wusongqing 已提交
2684

E
ester.zhou 已提交
2685
isDistributedEnabled(): Promise\<boolean>
W
wusongqing 已提交
2686

2687
Checks whether this device supports distributed notifications. This API uses a promise to return the result.
W
wusongqing 已提交
2688

E
ester.zhou 已提交
2689
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2690

E
ester.zhou 已提交
2691
**Return value**
W
wusongqing 已提交
2692

2693 2694 2695
| Type              | Description                                         |
| ------------------ | --------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2696

E
ester.zhou 已提交
2697 2698 2699
**Example**

```javascript
2700 2701 2702
Notification.isDistributedEnabled().then((data) => {
    console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
});
W
wusongqing 已提交
2703 2704 2705
```


E
ester.zhou 已提交
2706
## Notification.enableDistributedByBundle<sup>8+</sup>
W
wusongqing 已提交
2707

E
ester.zhou 已提交
2708
enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
W
wusongqing 已提交
2709

2710
Sets whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2711

E
ester.zhou 已提交
2712
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2713

E
ester.zhou 已提交
2714 2715
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2716 2717
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2718
**Parameters**
W
wusongqing 已提交
2719

E
ester.zhou 已提交
2720 2721
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
2722
| bundle   | [BundleOption](#bundleoption)             | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
2723 2724
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                      |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2725

E
ester.zhou 已提交
2726
**Example**
W
wusongqing 已提交
2727

E
ester.zhou 已提交
2728
```javascript
2729
function enableDistributedByBundleCallback(err) {
E
esterzhou 已提交
2730 2731 2732 2733 2734
    if (err.code) {
        console.info("enableDistributedByBundle failed " + JSON.stringify(err));
    } else {
        console.info("enableDistributedByBundle success");
    }
E
ester.zhou 已提交
2735
};
W
wusongqing 已提交
2736

E
ester.zhou 已提交
2737 2738 2739
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2740

E
ester.zhou 已提交
2741
var enable = true
W
wusongqing 已提交
2742

E
ester.zhou 已提交
2743 2744
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2745 2746


E
ester.zhou 已提交
2747 2748 2749

## Notification.enableDistributedByBundle<sup>8+</sup>

E
ester.zhou 已提交
2750
enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
E
ester.zhou 已提交
2751

2752
Sets whether a specified application supports distributed notifications. This API uses a promise to return the result.
E
ester.zhou 已提交
2753 2754 2755

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

E
ester.zhou 已提交
2756 2757
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2758 2759
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771
**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.               |
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                 |

**Example**

```javascript
var bundle = {
    bundle: "bundleName1",
W
wusongqing 已提交
2772 2773
}

E
ester.zhou 已提交
2774
var enable = true
2775 2776 2777
Notification.enableDistributedByBundle(bundle, enable).then(() => {
    console.info("enableDistributedByBundle success");
});
W
wusongqing 已提交
2778 2779
```

E
ester.zhou 已提交
2780
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
W
wusongqing 已提交
2781

E
ester.zhou 已提交
2782
isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
W
wusongqing 已提交
2783

E
ester.zhou 已提交
2784
Obtains whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2785

E
ester.zhou 已提交
2786
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2787

E
ester.zhou 已提交
2788 2789
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2790 2791
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2792
**Parameters**
W
wusongqing 已提交
2793

E
ester.zhou 已提交
2794 2795 2796 2797
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2798

E
ester.zhou 已提交
2799
**Example**
W
wusongqing 已提交
2800

E
ester.zhou 已提交
2801
```javascript
2802
function isDistributedEnabledByBundleCallback(err, data) {
E
esterzhou 已提交
2803 2804 2805
    if (err.code) {
        console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
    } else {
2806
        console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
E
esterzhou 已提交
2807
    }
E
ester.zhou 已提交
2808
};
W
wusongqing 已提交
2809

E
ester.zhou 已提交
2810 2811 2812
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2813

E
ester.zhou 已提交
2814
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
ester.zhou 已提交
2815
```
W
wusongqing 已提交
2816 2817 2818



E
ester.zhou 已提交
2819
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
W
wusongqing 已提交
2820

E
ester.zhou 已提交
2821
isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
W
wusongqing 已提交
2822

2823
Checks whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2824

E
ester.zhou 已提交
2825 2826
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2827 2828
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2829 2830
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2831 2832 2833 2834 2835 2836 2837 2838
**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.               |

**Return value**

2839 2840 2841
| Type              | Description                                             |
| ------------------ | ------------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
E
ester.zhou 已提交
2842 2843 2844 2845 2846 2847

**Example**

```javascript
var bundle = {
    bundle: "bundleName1",
W
wusongqing 已提交
2848
}
E
ester.zhou 已提交
2849

2850 2851 2852
Notification.isDistributedEnabledByBundle(bundle).then((data) => {
    console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
});
W
wusongqing 已提交
2853 2854 2855
```


E
ester.zhou 已提交
2856
## Notification.getDeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
2857

E
ester.zhou 已提交
2858
getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
W
wusongqing 已提交
2859

E
ester.zhou 已提交
2860
Obtains the notification reminder type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2861

E
ester.zhou 已提交
2862
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2863

E
ester.zhou 已提交
2864 2865
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2866 2867
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2868
**Parameters**
W
wusongqing 已提交
2869

E
ester.zhou 已提交
2870 2871 2872
| Name  | Type                              | Mandatory| Description                      |
| -------- | --------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2873

E
ester.zhou 已提交
2874
**Example**
W
wusongqing 已提交
2875

E
ester.zhou 已提交
2876
```javascript
2877
function getDeviceRemindTypeCallback(err,data) {
E
esterzhou 已提交
2878 2879 2880 2881 2882
    if (err.code) {
        console.info("getDeviceRemindType failed " + JSON.stringify(err));
    } else {
        console.info("getDeviceRemindType success");
    }
E
ester.zhou 已提交
2883
};
W
wusongqing 已提交
2884

E
ester.zhou 已提交
2885 2886
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2887 2888 2889



E
ester.zhou 已提交
2890
## Notification.getDeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
2891

E
ester.zhou 已提交
2892
getDeviceRemindType(): Promise\<DeviceRemindType\>
W
wusongqing 已提交
2893

E
ester.zhou 已提交
2894
Obtains the notification reminder type. This API uses a promise to return the result.
W
wusongqing 已提交
2895

E
ester.zhou 已提交
2896 2897
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2898 2899
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2900 2901
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
2902 2903 2904 2905 2906 2907 2908 2909 2910
**Return value**

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

**Example**

```javascript
2911 2912 2913
Notification.getDeviceRemindType().then((data) => {
    console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
});
W
wusongqing 已提交
2914 2915
```

E
ester.zhou 已提交
2916

E
ester.zhou 已提交
2917 2918 2919 2920 2921 2922 2923 2924
## Notification.publishAsBundle<sup>9+</sup>

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

Publishes an agent-powered notification. This API uses an asynchronous callback to return the result.

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

E
ester.zhou 已提交
2925 2926
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2927 2928 2929 2930
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

2931 2932 2933 2934 2935 2936
| Name              | Type                                       | Mandatory| Description                                    |
| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request              | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                      |
| userId               | number                                      | Yes  | User ID.                                |
| callback             | AsyncCallback                               | Yes  | Callback used to return the result.                |
E
ester.zhou 已提交
2937 2938 2939 2940

**Example**

```js
2941 2942
// publishAsBundle callback
function callback(err) {
E
esterzhou 已提交
2943 2944 2945 2946 2947
    if (err.code) {
        console.info("publishAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("publishAsBundle success");
    }
E
ester.zhou 已提交
2948 2949 2950
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
2951
// User ID
E
ester.zhou 已提交
2952 2953
let userId = 100
// NotificationRequest object
2954
let request = {
E
ester.zhou 已提交
2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

2966
Notification.publishAsBundle(request, representativeBundle, userId, callback);
E
ester.zhou 已提交
2967 2968 2969 2970 2971 2972 2973 2974 2975 2976
```

## Notification.publishAsBundle<sup>9+</sup>

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

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

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

E
ester.zhou 已提交
2977 2978
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2979 2980 2981 2982 2983 2984 2985
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
2986
| request              | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
ester.zhou 已提交
2987
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                           |
2988
| userId               | number                                      | Yes  | User ID.                           |
E
ester.zhou 已提交
2989 2990 2991 2992 2993 2994

**Example**

```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
2995
// User ID
E
ester.zhou 已提交
2996 2997
let userId = 100
// NotificationRequest object
2998
var request = {
E
ester.zhou 已提交
2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

3010 3011
Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
	console.info("publishAsBundle success");
E
ester.zhou 已提交
3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022
});
```

## Notification.cancelAsBundle<sup>9+</sup>

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

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

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

E
ester.zhou 已提交
3023 3024
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3025 3026
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
3027
**System API**: This is a system API and cannot be called by third-party applications.
E
ester.zhou 已提交
3028

E
ester.zhou 已提交
3029
**Parameters**
E
ester.zhou 已提交
3030 3031 3032 3033 3034

| Name              | Type         | Mandatory| Description                    |
| -------------------- | ------------- | ---- | ------------------------ |
| id                   | number        | Yes  | Notification ID.                |
| representativeBundle | string        | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.      |
3035
| userId               | number        | Yes  | User ID.      |
E
ester.zhou 已提交
3036 3037 3038 3039 3040
| callback             | AsyncCallback | Yes  | Callback used to return the result.|

**Example**

```js
3041
// cancelAsBundle
E
ester.zhou 已提交
3042
function cancelAsBundleCallback(err) {
E
esterzhou 已提交
3043 3044 3045 3046 3047
    if (err.code) {
        console.info("cancelAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("cancelAsBundle success");
    }
E
ester.zhou 已提交
3048 3049 3050
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
3051
// User ID
E
ester.zhou 已提交
3052 3053 3054 3055 3056 3057 3058 3059 3060
let userId = 100

Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
```

## Notification.cancelAsBundle<sup>9+</sup>

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

3061
Cancels a notification published by the reminder agent. This API uses a promise to return the result.
E
ester.zhou 已提交
3062 3063 3064

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

E
ester.zhou 已提交
3065 3066
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3067 3068
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
3069
**System API**: This is a system API and cannot be called by third-party applications.
E
ester.zhou 已提交
3070

E
ester.zhou 已提交
3071
**Parameters**
E
ester.zhou 已提交
3072 3073 3074 3075 3076

| Name              | Type  | Mandatory| Description              |
| -------------------- | ------ | ---- | ------------------ |
| id                   | number | Yes  | Notification ID.          |
| representativeBundle | string | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.|
3077
| userId               | number | Yes  | User ID.|
E
ester.zhou 已提交
3078 3079 3080 3081 3082 3083

**Example**

```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
3084
// User ID
E
ester.zhou 已提交
3085 3086 3087
let userId = 100

Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
E
esterzhou 已提交
3088
	console.info("cancelAsBundle success");
E
ester.zhou 已提交
3089 3090 3091
});
```

E
ester.zhou 已提交
3092
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
3093

E
ester.zhou 已提交
3094
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
3095

3096
Sets the enabled status of a notification slot type for a specified application. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3097 3098 3099 3100 3101

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

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

E
ester.zhou 已提交
3102 3103
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3104 3105 3106 3107
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
3108
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
3109 3110 3111 3112 3113 3114 3115
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
| enable   | boolean                       | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\>         | Yes  | Callback used to return the result.|

**Example**

```js
3116
// enableNotificationSlot
E
ester.zhou 已提交
3117
function enableSlotCallback(err) {
E
esterzhou 已提交
3118 3119 3120 3121 3122
    if (err.code) {
        console.info("enableNotificationSlot failed " + JSON.stringify(err));
    } else {
        console.info("enableNotificationSlot success");
    }
E
ester.zhou 已提交
3123 3124 3125 3126
};

Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3127
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3128 3129 3130 3131
    true,
    enableSlotCallback);
```

E
ester.zhou 已提交
3132
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
3133

E
ester.zhou 已提交
3134
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> 
E
ester.zhou 已提交
3135

3136
Sets the enabled status of a notification slot type for a specified application. This API uses a promise to return the result.
E
ester.zhou 已提交
3137 3138 3139 3140 3141

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

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

E
ester.zhou 已提交
3142 3143
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3144 3145 3146 3147
**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
3148
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.  |
E
ester.zhou 已提交
3149 3150 3151 3152 3153 3154
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|
| enable | boolean                       | Yes  | Whether to enable notification.    |

**Example**

```js
3155 3156 3157 3158 3159
// enableNotificationSlot
Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", },
    Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => {
    console.info("enableNotificationSlot success");
});
E
ester.zhou 已提交
3160 3161
```

E
ester.zhou 已提交
3162
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3163

E
ester.zhou 已提交
3164
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
E
ester.zhou 已提交
3165

3166
Checks whether a specified notification slot type is enabled for a specified application. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3167 3168 3169 3170 3171

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

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

E
ester.zhou 已提交
3172 3173
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3174 3175 3176 3177
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
3178
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
3179
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
3180
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3181 3182 3183 3184

**Example**

```js
3185
// isNotificationSlotEnabled
E
ester.zhou 已提交
3186
function getEnableSlotCallback(err, data) {
E
esterzhou 已提交
3187 3188 3189 3190 3191
    if (err.code) {
        console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationSlotEnabled success");
    }
E
ester.zhou 已提交
3192 3193 3194 3195
};

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3196
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3197 3198 3199
    getEnableSlotCallback);
```

E
ester.zhou 已提交
3200
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3201

E
ester.zhou 已提交
3202
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>  
E
ester.zhou 已提交
3203

3204
Checks whether a specified notification slot type is enabled for a specified application. This API uses a promise to return the result.
E
ester.zhou 已提交
3205 3206 3207 3208 3209

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

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

E
ester.zhou 已提交
3210 3211
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3212 3213 3214 3215
**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
3216
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.  |
E
ester.zhou 已提交
3217 3218
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|

E
ester.zhou 已提交
3219 3220
**Return value**

3221 3222 3223
| Type              | Description                           |
| ------------------ | ------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
E
ester.zhou 已提交
3224

E
ester.zhou 已提交
3225 3226 3227
**Example**

```js
3228 3229 3230 3231 3232
// isNotificationSlotEnabled
Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
    Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
    console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
E
ester.zhou 已提交
3233 3234
```

E
ester.zhou 已提交
3235

E
ester.zhou 已提交
3236
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3237

E
ester.zhou 已提交
3238
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
E
ester.zhou 已提交
3239

3240
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252

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

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

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

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
3253
| enable | boolean | Yes  | Whether the feature is enabled.  |
E
ester.zhou 已提交
3254
| callback | AsyncCallback\<void\>    | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3255 3256 3257 3258 3259 3260 3261

**Example**

```js
let userId = 100;
let enable = true;

3262
function callback(err) {
E
esterzhou 已提交
3263 3264 3265 3266 3267
    if (err.code) {
        console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
    } else {
        console.info("setSyncNotificationEnabledWithoutApp success");
    }
E
ester.zhou 已提交
3268 3269
}

3270
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
E
ester.zhou 已提交
3271 3272 3273
```


E
ester.zhou 已提交
3274
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3275

E
ester.zhou 已提交
3276
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
E
ester.zhou 已提交
3277

3278
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses a promise to return the result.
E
ester.zhou 已提交
3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290

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

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

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

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
3291
| enable | boolean | Yes  | Whether the feature is enabled.  |
E
ester.zhou 已提交
3292 3293 3294 3295 3296 3297

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|
E
ester.zhou 已提交
3298 3299 3300 3301 3302 3303 3304

**Example**

```js
let userId = 100;
let enable = true;

3305 3306 3307 3308 3309
Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
    console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => {
    console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
});
E
ester.zhou 已提交
3310 3311 3312
```


E
ester.zhou 已提交
3313
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3314

E
ester.zhou 已提交
3315
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
E
ester.zhou 已提交
3316

3317
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329

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

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

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

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
3330
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3331 3332 3333 3334 3335 3336

**Example**

```js
let userId = 100;

3337
function getSyncNotificationEnabledWithoutAppCallback(err, data) {
E
ester.zhou 已提交
3338
    if (err) {
3339
        console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
E
ester.zhou 已提交
3340
    } else {
3341
        console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
E
ester.zhou 已提交
3342
    }
E
ester.zhou 已提交
3343 3344
}

E
ester.zhou 已提交
3345
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3346 3347 3348
```


E
ester.zhou 已提交
3349
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3350

E
ester.zhou 已提交
3351
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
E
ester.zhou 已提交
3352

3353
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses a promise to return the result.
E
ester.zhou 已提交
3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368

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

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

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

**Parameters**

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

**Return value**

3369 3370 3371
| Type              | Description                                                        |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
E
ester.zhou 已提交
3372 3373 3374 3375 3376

**Example**

```js
let userId = 100;
3377 3378 3379 3380 3381
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
    console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => {
    console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
});
E
ester.zhou 已提交
3382 3383 3384 3385
```



E
ester.zhou 已提交
3386 3387
## NotificationSubscriber

3388 3389
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).

E
ester.zhou 已提交
3390 3391
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3392 3393
### onConsume

E
ester.zhou 已提交
3394
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3395

E
ester.zhou 已提交
3396
Callback for receiving notifications.
W
wusongqing 已提交
3397

E
ester.zhou 已提交
3398 3399
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
3400 3401
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3402 3403 3404 3405
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
3406
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification received.|
E
ester.zhou 已提交
3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417

**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3418

E
ester.zhou 已提交
3419 3420 3421 3422
function onConsumeCallback(data) {
    let req = data.request;
    console.info('===> onConsume callback req.id:' + req.id);
};
W
wusongqing 已提交
3423

E
ester.zhou 已提交
3424 3425 3426
var subscriber = {
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
3427

E
ester.zhou 已提交
3428 3429
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3430

E
ester.zhou 已提交
3431
### onCancel
W
wusongqing 已提交
3432

E
ester.zhou 已提交
3433
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3434

3435
Callback for canceling notifications.
W
wusongqing 已提交
3436

E
ester.zhou 已提交
3437
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3438

E
ester.zhou 已提交
3439 3440
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3441
**Parameters**
W
wusongqing 已提交
3442

E
ester.zhou 已提交
3443 3444
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
3445
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification to cancel.|
W
wusongqing 已提交
3446

E
ester.zhou 已提交
3447
**Example**
W
wusongqing 已提交
3448

E
ester.zhou 已提交
3449 3450 3451 3452
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3453
    } else {
E
ester.zhou 已提交
3454
        console.info("subscribeCallback");
W
wusongqing 已提交
3455
    }
E
ester.zhou 已提交
3456 3457 3458 3459 3460
};

function onCancelCallback(data) {
    let req = data.request;
    console.info('===> onCancel callback req.id:' + req.id);
W
wusongqing 已提交
3461 3462
}

E
ester.zhou 已提交
3463 3464 3465
var subscriber = {
    onCancel: onCancelCallback
};
W
wusongqing 已提交
3466

E
ester.zhou 已提交
3467
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3468 3469
```

E
ester.zhou 已提交
3470
### onUpdate
W
wusongqing 已提交
3471

E
ester.zhou 已提交
3472
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
W
wusongqing 已提交
3473

E
ester.zhou 已提交
3474
Callback for notification sorting updates.
W
wusongqing 已提交
3475

E
ester.zhou 已提交
3476
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3477

E
ester.zhou 已提交
3478 3479
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3480
**Parameters**
W
wusongqing 已提交
3481

E
ester.zhou 已提交
3482 3483
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
3484
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Latest notification sorting list.|
W
wusongqing 已提交
3485

E
ester.zhou 已提交
3486
**Example**
W
wusongqing 已提交
3487

E
ester.zhou 已提交
3488 3489 3490 3491 3492 3493 3494 3495
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3496

3497 3498
function onUpdateCallback(map) {
    console.info('===> onUpdateCallback map:' + JSON.stringify(map));
E
ester.zhou 已提交
3499
}
W
wusongqing 已提交
3500

E
ester.zhou 已提交
3501 3502 3503
var subscriber = {
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
3504

E
ester.zhou 已提交
3505 3506
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3507

E
ester.zhou 已提交
3508
### onConnect
W
wusongqing 已提交
3509

E
ester.zhou 已提交
3510
onConnect?:() => void
W
wusongqing 已提交
3511

E
ester.zhou 已提交
3512 3513 3514 3515
Callback for subscription.

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

E
ester.zhou 已提交
3516 3517
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onConnectCallback() {
    console.info('===> onConnect in test');
W
wusongqing 已提交
3531 3532
}

E
ester.zhou 已提交
3533 3534 3535
var subscriber = {
    onConnect: onConnectCallback
};
W
wusongqing 已提交
3536

E
ester.zhou 已提交
3537
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3538 3539
```

E
ester.zhou 已提交
3540
### onDisconnect
W
wusongqing 已提交
3541

E
ester.zhou 已提交
3542
onDisconnect?:() => void
W
wusongqing 已提交
3543

E
ester.zhou 已提交
3544
Callback for unsubscription.
W
wusongqing 已提交
3545

E
ester.zhou 已提交
3546
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3547

E
ester.zhou 已提交
3548 3549
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3550
**Example**
W
wusongqing 已提交
3551

E
ester.zhou 已提交
3552 3553 3554 3555 3556 3557 3558 3559
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
3560 3561 3562 3563 3564 3565 3566
function unsubscribeCallback(err) {
    if (err.code) {
        console.info("unsubscribe failed " + JSON.stringify(err));
    } else {
        console.info("unsubscribeCallback");
    }
};
W
wusongqing 已提交
3567

3568 3569 3570
function onConnectCallback() {
    console.info('===> onConnect in test');
}
E
ester.zhou 已提交
3571 3572 3573
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
3574

E
ester.zhou 已提交
3575
var subscriber = {
3576
    onConnect: onConnectCallback,
E
ester.zhou 已提交
3577 3578
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
3579

3580
// The onConnect callback is invoked when subscription to the notification is complete.
E
ester.zhou 已提交
3581
Notification.subscribe(subscriber, subscribeCallback);
3582 3583
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
Notification.unsubscribe(subscriber, unsubscribeCallback);
E
ester.zhou 已提交
3584
```
W
wusongqing 已提交
3585

E
ester.zhou 已提交
3586
### onDestroy
W
wusongqing 已提交
3587

E
ester.zhou 已提交
3588
onDestroy?:() => void
W
wusongqing 已提交
3589

E
ester.zhou 已提交
3590
Callback for service disconnection.
W
wusongqing 已提交
3591

E
ester.zhou 已提交
3592
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3593

E
ester.zhou 已提交
3594 3595
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3596 3597 3598 3599 3600 3601
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3602
    } else {
E
ester.zhou 已提交
3603
        console.info("subscribeCallback");
W
wusongqing 已提交
3604
    }
E
ester.zhou 已提交
3605 3606 3607 3608
};

function onDestroyCallback() {
    console.info('===> onDestroy in test');
W
wusongqing 已提交
3609 3610
}

E
ester.zhou 已提交
3611 3612 3613
var subscriber = {
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
3614

E
ester.zhou 已提交
3615
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3616 3617
```

E
ester.zhou 已提交
3618 3619
### onDoNotDisturbDateChange<sup>8+</sup>

E
ester.zhou 已提交
3620
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
E
ester.zhou 已提交
3621 3622 3623 3624 3625

Callback for DND time setting updates.

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

E
ester.zhou 已提交
3626 3627
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3628 3629 3630 3631
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3632
| mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
E
ester.zhou 已提交
3633 3634 3635 3636 3637 3638 3639 3640 3641 3642

**Example**
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3643

3644 3645
function onDoNotDisturbDateChangeCallback(mode) {
    console.info('===> onDoNotDisturbDateChange:' + mode);
E
ester.zhou 已提交
3646
}
W
wusongqing 已提交
3647

E
ester.zhou 已提交
3648 3649 3650 3651
var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
Notification.subscribe(subscriber, subscribeCallback);
3652 3653 3654 3655 3656 3657 3658 3659 3660 3661

var doNotDisturbDate = {
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
// Set the onDoNotDisturbDateChange callback for DND time setting updates.
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
	console.info("setDoNotDisturbDate sucess");
});
E
ester.zhou 已提交
3662
```
W
wusongqing 已提交
3663 3664


E
ester.zhou 已提交
3665
### onEnabledNotificationChanged<sup>8+</sup>
W
wusongqing 已提交
3666

E
ester.zhou 已提交
3667
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) => void
W
wusongqing 已提交
3668

3669
Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
3670

E
ester.zhou 已提交
3671
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3672

E
ester.zhou 已提交
3673 3674
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3675
**Parameters**
W
wusongqing 已提交
3676

E
ester.zhou 已提交
3677 3678 3679
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
W
wusongqing 已提交
3680

E
ester.zhou 已提交
3681
**Example**
W
wusongqing 已提交
3682

E
ester.zhou 已提交
3683 3684 3685 3686 3687 3688 3689 3690
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3691

E
ester.zhou 已提交
3692
function onEnabledNotificationChangedCallback(callbackData) {
3693 3694 3695
    console.info("bundle: " + callbackData.bundle);
    console.info("uid: " + callbackData.uid);
    console.info("enable: " + callbackData.enable);
E
ester.zhou 已提交
3696
};
W
wusongqing 已提交
3697

E
ester.zhou 已提交
3698 3699 3700 3701
var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
Notification.subscribe(subscriber, subscribeCallback);
3702 3703 3704 3705 3706 3707 3708 3709

var bundle = {
    bundle: "bundleName1",
}
// Set the onEnabledNotificationChanged callback that is triggered when the notification enabled status changes.
Notification.enableNotification(bundle, false).then(() => {
	console.info("enableNotification sucess");
});
W
wusongqing 已提交
3710 3711
```

E
ester.zhou 已提交
3712
## SubscribeCallbackData
W
wusongqing 已提交
3713

E
ester.zhou 已提交
3714
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3715

E
ester.zhou 已提交
3716 3717
**System API**: This is a system API and cannot be called by third-party applications.

3718 3719 3720 3721 3722 3723 3724
| Name           | Type                                             | Readable| Writable| Description    |
| --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request         | [NotificationRequest](#notificationrequest)       | Yes | No | Notification content.|
| sortingMap      | [NotificationSortingMap](#notificationsortingmap) | Yes | No | Notification sorting information.|
| reason          | number                                            | Yes | No | Reason for deletion.|
| sound           | string                                            | Yes | No | Sound used for notification.|
| vibrationValues | Array\<number\>                                   | Yes | No | Vibration used for notification.|
W
wusongqing 已提交
3725 3726


E
ester.zhou 已提交
3727
## EnabledNotificationCallbackData<sup>8+</sup>
W
wusongqing 已提交
3728

E
ester.zhou 已提交
3729
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3730

E
ester.zhou 已提交
3731 3732
**System API**: This is a system API and cannot be called by third-party applications.

3733 3734 3735 3736 3737
| Name  | Type   | Readable| Writable| Description            |
| ------ | ------- | ---- | --- | ---------------- |
| bundle | string  | Yes | No | Bundle name of the application.      |
| uid    | number  | Yes | No | UID of the application.       |
| enable | boolean | Yes | No | Notification enabled status of the application.|
W
wusongqing 已提交
3738 3739


E
ester.zhou 已提交
3740
## DoNotDisturbDate<sup>8+</sup>
W
wusongqing 已提交
3741

E
ester.zhou 已提交
3742
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3743

E
ester.zhou 已提交
3744 3745
**System API**: This is a system API and cannot be called by third-party applications.

3746 3747 3748 3749 3750
| Name | Type                                  | Readable| Writable| Description                  |
| ----- | -------------------------------------- | ---- | ---- | ---------------------- |
| type  | [DoNotDisturbType](#donotdisturbtype8) | Yes  | Yes  | DND time type.|
| begin | Date                                   | Yes  | Yes  | DND start time.|
| end   | Date                                   | Yes  | Yes  | DND end time.|
W
wusongqing 已提交
3751

E
ester.zhou 已提交
3752
## DoNotDisturbType<sup>8+</sup>
W
wusongqing 已提交
3753

E
ester.zhou 已提交
3754
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3755

E
ester.zhou 已提交
3756
**System API**: This is a system API and cannot be called by third-party applications.
W
wusongqing 已提交
3757

E
ester.zhou 已提交
3758 3759
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
E
ester.zhou 已提交
3760 3761 3762 3763
| TYPE_NONE    | 0 | Non-DND.                          |
| TYPE_ONCE    | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
| TYPE_DAILY   | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute).    |
W
wusongqing 已提交
3764 3765


E
ester.zhou 已提交
3766
## ContentType
W
wusongqing 已提交
3767

E
ester.zhou 已提交
3768
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3769

E
ester.zhou 已提交
3770 3771
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3772 3773 3774 3775 3776
| NOTIFICATION_CONTENT_BASIC_TEXT   | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification.    |
| NOTIFICATION_CONTENT_LONG_TEXT    | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification.  |
| NOTIFICATION_CONTENT_PICTURE      | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification.    |
| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification.    |
| NOTIFICATION_CONTENT_MULTILINE    | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|
W
wusongqing 已提交
3777

E
ester.zhou 已提交
3778
## SlotLevel
W
wusongqing 已提交
3779

E
ester.zhou 已提交
3780
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3781

E
ester.zhou 已提交
3782 3783
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3784 3785 3786
| LEVEL_NONE                        | 0           | The notification function is disabled.    |
| 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.|
| LEVEL_LOW                         | 2           | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
E
ester.zhou 已提交
3787 3788
| 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.|
| LEVEL_HIGH                        | 4           | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.|
W
wusongqing 已提交
3789 3790


E
ester.zhou 已提交
3791
## BundleOption
W
wusongqing 已提交
3792

E
ester.zhou 已提交
3793
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3794

3795 3796 3797 3798
| Name  | Type  | Readable| Writable| Description  |
| ------ | ------ |---- | --- |  ------ |
| bundle | string | Yes | Yes | Bundle information of the application.|
| uid    | number | Yes | Yes | User ID.|
W
wusongqing 已提交
3799 3800 3801



E
ester.zhou 已提交
3802
## NotificationKey
W
wusongqing 已提交
3803

E
ester.zhou 已提交
3804
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3805

3806 3807 3808 3809
| Name | Type  | Readable| Writable| Description    |
| ----- | ------ | ---- | --- | -------- |
| id    | number | Yes | Yes | Notification ID.  |
| label | string | Yes | Yes | Notification label.|
W
wusongqing 已提交
3810 3811


E
ester.zhou 已提交
3812
## SlotType
W
wusongqing 已提交
3813

E
ester.zhou 已提交
3814
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3815

E
ester.zhou 已提交
3816 3817
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
E
ester.zhou 已提交
3818 3819 3820 3821 3822
| UNKNOWN_TYPE         | 0 | Unknown type.|
| SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.|
| SERVICE_INFORMATION  | 2 | Notification slot for service information.|
| CONTENT_INFORMATION  | 3 | Notification slot for content consultation.|
| OTHER_TYPES          | 0xFFFF | Notification slot for other purposes.|
W
wusongqing 已提交
3823 3824


E
ester.zhou 已提交
3825
## NotificationActionButton
W
wusongqing 已提交
3826

3827 3828
Describes the button displayed in the notification.

E
ester.zhou 已提交
3829
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3830

3831 3832 3833 3834 3835 3836
| Name     | Type                                           | Readable| Writable| Description                     |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title     | string                                          | Yes | Yes | Button title.                 |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md)   | Yes | Yes | **WantAgent** of the button.|
| extras    | { [key: string]: any }                          | Yes | Yes | Extra information of the button.             |
| userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | Yes | Yes | User input object.         |
W
wusongqing 已提交
3837 3838


E
ester.zhou 已提交
3839
## NotificationBasicContent
W
wusongqing 已提交
3840

3841 3842
Describes the normal text notification.

E
ester.zhou 已提交
3843
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3844

3845 3846 3847 3848 3849
| Name          | Type  | Readable| Writable| Description                              |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title          | string | Yes  | Yes  | Notification title.                        |
| text           | string | Yes  | Yes  | Notification content.                        |
| additionalText | string | Yes  | Yes  | Additional information of the notification.|
W
wusongqing 已提交
3850 3851


E
ester.zhou 已提交
3852
## NotificationLongTextContent
W
wusongqing 已提交
3853

3854 3855
Describes the long text notification.

E
ester.zhou 已提交
3856
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3857

3858 3859 3860 3861 3862 3863 3864 3865
| Name          | Type  | Readable| Writable| Description                            |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title          | string | Yes | Yes | Notification title.                        |
| text           | string | Yes | Yes | Notification content.                        |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| longText       | string | Yes | Yes | Long text of the notification.                    |
| briefText      | string | Yes | Yes | Brief text of the notification.|
| expandedTitle  | string | Yes | Yes | Title of the notification in the expanded state.                |
W
wusongqing 已提交
3866 3867


E
ester.zhou 已提交
3868 3869
## NotificationMultiLineContent

3870 3871
Describes the multi-line text notification.

E
ester.zhou 已提交
3872 3873
**System capability**: SystemCapability.Notification.Notification

3874 3875 3876 3877 3878 3879 3880 3881
| Name          | Type           | Readable| Writable| Description                            |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title          | string          | Yes | Yes | Notification title.                        |
| text           | string          | Yes | Yes | Notification content.                        |
| additionalText | string          | Yes | Yes | Additional information of the notification.|
| briefText      | string          | Yes | Yes | Brief text of the notification.|
| longTitle      | string          | Yes | Yes | Title of the notification in the expanded state.                |
| lines          | Array\<string\> | Yes | Yes | Multi-line text of the notification.                  |
E
ester.zhou 已提交
3882 3883 3884 3885


## NotificationPictureContent

3886 3887
Describes the picture-attached notification.

E
ester.zhou 已提交
3888 3889
**System capability**: SystemCapability.Notification.Notification

3890 3891 3892 3893 3894 3895 3896 3897
| Name          | Type          | Readable| Writable| Description                            |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title          | string         | Yes | Yes | Notification title.                        |
| text           | string         | Yes | Yes | Notification content.                        |
| additionalText | string         | Yes | Yes | Additional information of the notification.|
| briefText      | string         | Yes | Yes | Brief text of the notification.|
| expandedTitle  | string         | Yes | Yes | Title of the notification in the expanded state.                |
| picture        | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification.                  |
E
ester.zhou 已提交
3898 3899 3900 3901


## NotificationContent

3902 3903
Describes the notification content.

E
ester.zhou 已提交
3904 3905
**System capability**: SystemCapability.Notification.Notification

3906 3907 3908 3909 3910 3911 3912
| Name       | Type                                                        | Readable| Writable| Description              |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](#contenttype)                                  | Yes | Yes | Notification content type.      |
| normal      | [NotificationBasicContent](#notificationbasiccontent)        | Yes | Yes | Normal text.  |
| longText    | [NotificationLongTextContent](#notificationlongtextcontent)  | Yes | Yes | Long text.|
| multiLine   | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text.  |
| picture     | [NotificationPictureContent](#notificationpicturecontent)    | Yes | Yes | Picture-attached.  |
E
ester.zhou 已提交
3913 3914 3915 3916


## NotificationFlagStatus<sup>8+</sup>

3917 3918
Describes the notification flag status.

E
ester.zhou 已提交
3919 3920
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
3921 3922
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3923 3924 3925 3926 3927 3928 3929 3930 3931
| Name          | Value | Description                              |
| -------------- | --- | --------------------------------- |
| TYPE_NONE      | 0   | The default flag is used.                        |
| TYPE_OPEN      | 1   | The notification flag is enabled.                    |
| TYPE_CLOSE     | 2   | The notification flag is disabled.                    |


## NotificationFlags<sup>8+</sup>

3932 3933
Enumerates notification flags.

E
ester.zhou 已提交
3934 3935
**System capability**: SystemCapability.Notification.Notification

3936 3937 3938 3939
| Name            | Type                   | Readable| Writable| Description                              |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled     | [NotificationFlagStatus](#notificationflagstatus8) | Yes  | No  | Whether to enable the sound alert for the notification.                 |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes  | No  | Whether to enable vibration for the notification.              |
E
ester.zhou 已提交
3940 3941 3942 3943


## NotificationRequest

3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986
Describes the notification request.

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

| Name                 | Type                                         | Readable| Writable| Description                      |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content               | [NotificationContent](#notificationcontent)   | Yes | Yes | Notification content.                  |
| id                    | number                                        | Yes | Yes | Notification ID.                    |
| slotType              | [SlotType](#slottype)                         | Yes | Yes | Slot type.                  |
| isOngoing             | boolean                                       | Yes | Yes | Whether the notification is an ongoing notification.            |
| isUnremovable         | boolean                                       | Yes | Yes | Whether the notification can be removed.                |
| deliveryTime          | number                                        | Yes | Yes | Time when the notification is sent.              |
| tapDismissed          | boolean                                       | Yes | Yes | Whether the notification is automatically cleared.          |
| autoDeletedTime       | number                                        | Yes | Yes | Time when the notification is automatically cleared.            |
| wantAgent             | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked. |
| extraInfo             | {[key: string]: any}                          | Yes | Yes | Extended parameters.                  |
| color                 | number                                        | Yes | Yes | Background color of the notification. Not supported currently.|
| colorEnabled          | boolean                                       | Yes | Yes | Whether the notification background color is enabled. Not supported currently.|
| isAlertOnce           | boolean                                       | Yes | Yes | Whether the notification triggers an alert only once.|
| isStopwatch           | boolean                                       | Yes | Yes | Whether to display the stopwatch.          |
| isCountDown           | boolean                                       | Yes | Yes | Whether to display the countdown time.        |
| isFloatingIcon        | boolean                                       | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar.        |
| label                 | string                                        | Yes | Yes | Notification label.                  |
| badgeIconStyle        | number                                        | Yes | Yes | Notification badge type.              |
| showDeliveryTime      | boolean                                       | Yes | Yes | Whether to display the time when the notification is delivered.          |
| actionButtons         | Array\<[NotificationActionButton](#notificationactionbutton)\>             | Yes | Yes | Buttons in the notification. Up to two buttons are allowed.    |
| 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.|
| 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.|
| creatorBundleName     | string                                        | Yes | No | Name of the bundle that creates the notification.            |
| creatorUid            | number                                        | Yes | No | UID used for creating the notification.             |
| creatorPid            | number                                        | Yes | No | PID used for creating the notification.             |
| creatorUserId<sup>8+</sup>| number                                    | Yes | No | ID of the user who creates the notification.          |
| hashCode              | string                                        | Yes | No | Unique ID of the notification.              |
| classification        | string                                        | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| groupName<sup>8+</sup>| string                                        | Yes | Yes | Notification group name.                |
| template<sup>8+</sup> | [NotificationTemplate](#notificationtemplate8) | Yes | Yes | Notification template.                  |
| 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.                  |
| 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.                  |
| distributedOption<sup>8+</sup>   | [DistributedOptions](#distributedoptions8)                 | Yes | Yes | Distributed notification options.         |
| 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.         |
| notificationFlags<sup>8+</sup> | [NotificationFlags](#notificationflags8)                    | Yes | No | Notification flags.         |
| 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.         |
| badgeNumber<sup>9+</sup> | number                    | Yes | Yes | Number of notifications displayed on the application icon.         |
E
ester.zhou 已提交
3987 3988 3989

## DistributedOptions<sup>8+</sup>

3990 3991
Describes distributed notifications options.

E
ester.zhou 已提交
3992 3993
**System capability**: SystemCapability.Notification.Notification

3994 3995 3996 3997 3998 3999
| Name                  | Type           | Readable| Writable| Description                              |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed          | boolean        | Yes  | Yes  | Whether the notification is a distributed notification.                 |
| supportDisplayDevices  | Array\<string> | Yes  | Yes  | List of the devices to which the notification can be synchronized.        |
| supportOperateDevices  | Array\<string> | Yes  | Yes  | List of the devices on which the notification can be opened.             |
| remindType             | number         | Yes  | No  | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications.                   |
E
ester.zhou 已提交
4000 4001 4002 4003


## NotificationSlot

4004 4005
Describes the notification slot.

E
ester.zhou 已提交
4006 4007
**System capability**: SystemCapability.Notification.Notification

4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021
| Name                | Type                 | Readable| Writable| Description                                      |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type                 | [SlotType](#slottype) | Yes | Yes | Slot type.                                  |
| level                | number                | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc                 | string                | Yes | Yes | Notification slot description.                          |
| badgeFlag            | boolean               | Yes | Yes | Whether to display the badge.                              |
| bypassDnd            | boolean               | Yes | Yes | Whether to bypass DND mode in the system.              |
| lockscreenVisibility | number                | Yes | Yes | Mode for displaying the notification on the lock screen.                |
| vibrationEnabled     | boolean               | Yes | Yes | Whether vibration is enabled for the notification.                                |
| sound                | string                | Yes | Yes | Notification alert tone.                                |
| lightEnabled         | boolean               | Yes | Yes | Whether the indicator blinks for the notification.                                  |
| lightColor           | number                | Yes | Yes | Indicator color of the notification.                                |
| vibrationValues      | Array\<number\>       | Yes | Yes | Vibration mode of the notification.                              |
| enabled<sup>9+</sup> | boolean               | Yes | No | Whether the notification slot is enabled.                     |
E
ester.zhou 已提交
4022 4023 4024 4025


## NotificationSorting

4026 4027
Provides sorting information of active notifications.

E
ester.zhou 已提交
4028 4029
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
4030 4031
**System API**: This is a system API and cannot be called by third-party applications.

4032 4033 4034 4035 4036
| Name    | Type                                 | Readable| Writable| Description        |
| -------- | ------------------------------------- | ---- | --- | ------------ |
| slot     | [NotificationSlot](#notificationslot) | Yes | No | Notification slot content.|
| hashCode | string                                | Yes | No | Unique ID of the notification.|
| ranking  | number                                | Yes | No | Notification sequence number.|
E
ester.zhou 已提交
4037 4038 4039 4040


## NotificationSortingMap

4041 4042
Provides sorting information of active notifications in all subscribed notifications.

E
ester.zhou 已提交
4043 4044
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
4045 4046
**System API**: This is a system API and cannot be called by third-party applications.

4047 4048 4049 4050
| Name          | Type                                                        | Readable| Writable| Description            |
| -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- |
| sortings       | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | No | Array of notification sorting information.|
| sortedHashCode | Array\<string\>                                              | Yes | No | Array of unique notification IDs.|
E
ester.zhou 已提交
4051 4052 4053 4054


## NotificationSubscribeInfo

4055 4056
Provides the information about the publisher for notification subscription.

E
ester.zhou 已提交
4057 4058
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
4059 4060
**System API**: This is a system API and cannot be called by third-party applications.

4061 4062 4063 4064
| Name       | Type           | Readable| Writable| Description                           |
| ----------- | --------------- | --- | ---- | ------------------------------- |
| bundleNames | Array\<string\> | Yes | Yes | Bundle names of the applications whose notifications are to be subscribed to.|
| userId      | number          | Yes | Yes | User whose notifications are to be subscribed to.   |
E
ester.zhou 已提交
4065 4066 4067 4068


## NotificationTemplate<sup>8+</sup>

4069 4070
Describes the notification template.

E
ester.zhou 已提交
4071 4072
**System capability**: SystemCapability.Notification.Notification

4073
| Name| Type                   | Readable| Writable| Description      |
E
ester.zhou 已提交
4074 4075 4076 4077 4078 4079 4080
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | Yes  | Yes  | Template name.|
| data | {[key:string]: Object} | Yes  | Yes  | Template data.|


## NotificationUserInput<sup>8+</sup>

4081 4082
Provides the notification user input.

E
ester.zhou 已提交
4083 4084
**System capability**: SystemCapability.Notification.Notification

4085 4086 4087
| Name    | Type  | Readable| Writable| Description                         |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.|
E
ester.zhou 已提交
4088

W
wusongqing 已提交
4089

E
ester.zhou 已提交
4090
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
4091

E
ester.zhou 已提交
4092
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
4093

E
ester.zhou 已提交
4094 4095
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
4096 4097 4098 4099 4100 4101
| Name                | Value | Description                              |
| -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND    | 0   | The device is not in use. No notification is required.           |
| IDLE_REMIND          | 1   | The device is not in use.                |
| ACTIVE_DONOT_REMIND  | 2   | The device is in use. No notification is required.           |
| ACTIVE_REMIND        | 3   | The device is in use.                |
E
ester.zhou 已提交
4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114


## SourceType<sup>8+</sup>

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

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

| Name                | Value | Description                 |
| -------------------- | --- | -------------------- |
| TYPE_NORMAL          | 0   | Normal notification.           |
| TYPE_CONTINUOUS      | 1   | Continuous notification.           |
| TYPE_TIMER           | 2   | Timed notification.           |
E
esterzhou 已提交
4115 4116 4117 4118 4119 4120 4121 4122 4123

## RemoveReason<sup>9+</sup>

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

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

| Name                | Value | Description                 |
| -------------------- | --- | -------------------- |
4124
| CLICK_REASON_REMOVE  | 1   | The notification is removed after a click on it.   |
E
esterzhou 已提交
4125
| CANCEL_REASON_REMOVE | 2   | The notification is removed by the user.        |