js-apis-notification.md 108.1 KB
Newer Older
E
ester.zhou 已提交
1
# Notification
W
wusongqing 已提交
2

E
ester.zhou 已提交
3 4
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> 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.
W
wusongqing 已提交
5 6 7 8 9 10 11

## Modules to Import

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

E
ester.zhou 已提交
12
## Notification.publish
W
wusongqing 已提交
13

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

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

E
ester.zhou 已提交
18
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
19

E
ester.zhou 已提交
20
**Parameters**
W
wusongqing 已提交
21

E
ester.zhou 已提交
22 23 24 25
| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
| -------- | ---- | ---- | ------------------------------------------- | ---- | ------------------------------------------- |
| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
| callback | Yes  | No  |AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                           |
W
wusongqing 已提交
26

E
ester.zhou 已提交
27
**Example**
W
wusongqing 已提交
28 29 30 31 32 33 34 35 36 37

```js
// publish callback
function publishCallback(err) {
	console.info("==========================>publishCallback=======================>");
}
// NotificationRequest object
var notificationRequest = {
    id: 1,
    content: {
E
ester.zhou 已提交
38
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
W
wusongqing 已提交
39 40 41 42 43 44 45 46 47 48 49 50
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest, publishCallback)
```



E
ester.zhou 已提交
51
## Notification.publish
W
wusongqing 已提交
52

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

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

E
ester.zhou 已提交
57
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
58

E
ester.zhou 已提交
59
**Example**
W
wusongqing 已提交
60 61 62 63 64 65

```js
// NotificationRequest object
var notificationRequest = {
    notificationId: 1,
    content: {
E
ester.zhou 已提交
66
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
W
wusongqing 已提交
67 68 69 70 71 72 73
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
E
ester.zhou 已提交
74
Notification.publish(notificationRequest).then(() => {
W
wusongqing 已提交
75 76 77 78 79
	console.info("==========================>publishCallback=======================>");
});

```

E
ester.zhou 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
## Notification.publish<sup>8+</sup>

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

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

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

**Parameters**

| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
| userId   | Yes  | No  |number                                      | Yes  | ID of the user who receives the notification.                          |
| callback | Yes  | No  |AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |

**Example**

```js
// publish callback
function publishCallback(err) {
	console.info("==========================>publishCallback=======================>");
}
// ID of the user who receives the notification.
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\>

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

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

**Parameters**

| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
| userId   | Yes  | No  |number                                      | Yes  | ID of the user who receives the notification.                          |

**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 已提交
151

E
ester.zhou 已提交
152 153 154 155
Notification.publish(notificationRequest, userId).then(() => {
	console.info("==========================>publishCallback=======================>");
});
```
W
wusongqing 已提交
156 157


E
ester.zhou 已提交
158
## Notification.cancel
W
wusongqing 已提交
159

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

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

E
ester.zhou 已提交
164
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
165

E
ester.zhou 已提交
166
**Parameters**
W
wusongqing 已提交
167

E
ester.zhou 已提交
168 169 170 171 172
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | --- | ---- | --------------------- | ---- | -------------------- |
| id       | Yes  | No  | number                | Yes  | Notification ID.              |
| label    | Yes  | No  | string                | Yes  | Notification label.            |
| callback | Yes  | No  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
173

E
ester.zhou 已提交
174
**Example**
W
wusongqing 已提交
175 176 177 178 179 180 181 182 183 184 185

```js
// cancel callback
function cancelCallback(err) {
	console.info("==========================>cancelCallback=======================>");
}
Notification.cancel(0, "label", cancelCallback)
```



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

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

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

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

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

E
ester.zhou 已提交
196 197 198 199
| Name | Readable| Writable| Type  | Mandatory| Description    |
| ----- | --- | ---- | ------ | ---- | -------- |
| id    | Yes  | No  | number | Yes  | Notification ID.  |
| label | Yes  | No  | string | No  | Notification label.|
W
wusongqing 已提交
200

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

```js
E
ester.zhou 已提交
204
Notification.cancel(0).then(() => {
W
wusongqing 已提交
205 206 207 208 209 210
	console.info("==========================>cancelCallback=======================>");
});
```



E
ester.zhou 已提交
211
## Notification.cancel
W
wusongqing 已提交
212

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

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

E
ester.zhou 已提交
217
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
218

E
ester.zhou 已提交
219
**Parameters**
W
wusongqing 已提交
220

E
ester.zhou 已提交
221 222 223 224
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| id       | Yes  | No | number                | Yes  | Notification ID.              |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
225

E
ester.zhou 已提交
226
**Example**
W
wusongqing 已提交
227 228 229 230 231 232 233 234 235 236 237

```js
// cancel callback
function cancelCallback(err) {
	console.info("==========================>cancelCallback=======================>");
}
Notification.cancel(0, cancelCallback)
```



E
ester.zhou 已提交
238
## Notification.cancelAll
W
wusongqing 已提交
239

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

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

E
ester.zhou 已提交
244
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
245

E
ester.zhou 已提交
246
**Parameters**
W
wusongqing 已提交
247

E
ester.zhou 已提交
248 249 250
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
251

E
ester.zhou 已提交
252
**Example**
W
wusongqing 已提交
253 254 255

```js
// cancel callback
E
ester.zhou 已提交
256 257
function cancelAllCallback(err) {
	console.info("==========================>cancelAllCallback=======================>");
W
wusongqing 已提交
258
}
E
ester.zhou 已提交
259
Notification.cancelAll(cancelAllCallback)
W
wusongqing 已提交
260 261 262 263
```



E
ester.zhou 已提交
264
## Notification.cancelAll
W
wusongqing 已提交
265

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

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

E
ester.zhou 已提交
270
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
271

E
ester.zhou 已提交
272
**Example**
W
wusongqing 已提交
273 274

```js
E
ester.zhou 已提交
275 276
Notification.cancelAll().then(() => {
	console.info("==========================>cancelAllCallback=======================>");
W
wusongqing 已提交
277 278 279 280 281
});
```



E
ester.zhou 已提交
282
## Notification.addSlot
W
wusongqing 已提交
283

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

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

E
ester.zhou 已提交
288
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
289

E
ester.zhou 已提交
290
**Parameters**
W
wusongqing 已提交
291

E
ester.zhou 已提交
292 293 294 295
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| slot     | Yes  | No | [NotificationSlot](#notificationslot)       | Yes  | Notification slot to add.|
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
296

E
ester.zhou 已提交
297
**Example**
W
wusongqing 已提交
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312

```js
// addSlot callback
function addSlotCallBack(err) {
	console.info("==========================>addSlotCallBack=======================>");
}
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.addSlot(notificationSlot, addSlotCallBack)
```



E
ester.zhou 已提交
313
## Notification.addSlot
W
wusongqing 已提交
314

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

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

E
ester.zhou 已提交
319
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
320

E
ester.zhou 已提交
321
**Parameters**
W
wusongqing 已提交
322

E
ester.zhou 已提交
323 324 325
| Name| Readable| Writable| Type            | Mandatory| Description                |
| ---- | ---- | --- | ---------------- | ---- | -------------------- |
| slot | Yes  | No | [NotificationSlot](#notificationslot) | Yes  | Notification slot to add.|
W
wusongqing 已提交
326

E
ester.zhou 已提交
327
**Example**
W
wusongqing 已提交
328 329 330 331 332 333

```js
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
334
Notification.addSlot(notificationSlot).then(() => {
W
wusongqing 已提交
335 336 337 338 339 340
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
341
## Notification.addSlot
W
wusongqing 已提交
342

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

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

E
ester.zhou 已提交
347
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
348

E
ester.zhou 已提交
349
**Parameters**
W
wusongqing 已提交
350

E
ester.zhou 已提交
351 352 353 354
| Name    | Readable| Writable| Type                 | Mandatory| Description                  |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
| type     | Yes  | No | [SlotType](#slottype)              | Yes  | Type of the notification slot to add.|
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.  |
W
wusongqing 已提交
355

E
ester.zhou 已提交
356
**Example**
W
wusongqing 已提交
357 358 359 360 361 362 363 364 365 366 367

```js
// addSlot callback
function addSlotCallBack(err) {
	console.info("==========================>addSlotCallBack=======================>");
}
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack)
```



E
ester.zhou 已提交
368
## Notification.addSlot
W
wusongqing 已提交
369

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

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

E
ester.zhou 已提交
374
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
375

E
ester.zhou 已提交
376
**Parameters**
W
wusongqing 已提交
377

E
ester.zhou 已提交
378 379 380
| Name| Readable| Writable| Type    | Mandatory| Description                  |
| ---- | ---- | --- | -------- | ---- | ---------------------- |
| type | Yes  | No | [SlotType](#slottype) | Yes  | Type of the notification slot to add.|
W
wusongqing 已提交
381

E
ester.zhou 已提交
382
**Example**
W
wusongqing 已提交
383 384

```js
E
ester.zhou 已提交
385
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
W
wusongqing 已提交
386 387 388 389 390 391
	console.info("==========================>addSlotCallback=======================>");
});
```



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

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

E
ester.zhou 已提交
396
Adds multiple notification slots. 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    | Readable| Writable| Type                     | Mandatory| Description                    |
| -------- | ---- | --- | ------------------------- | ---- | ------------------------ |
| slots    | Yes  | No | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
| callback | Yes  | No | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |
W
wusongqing 已提交
406

E
ester.zhou 已提交
407
**Example**
W
wusongqing 已提交
408 409 410 411 412 413 414 415 416 417 418

```js
// addSlots callback
function addSlotsCallBack(err) {
	console.info("==========================>addSlotsCallBack=======================>");
}
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
// NotificationSlotArray object
E
ester.zhou 已提交
419 420
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
421 422 423 424 425 426

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



E
ester.zhou 已提交
427
## Notification.addSlots
W
wusongqing 已提交
428

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

E
ester.zhou 已提交
431
Adds multiple notification slots. This API uses a promise to return the result.
W
wusongqing 已提交
432

E
ester.zhou 已提交
433
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
434

E
ester.zhou 已提交
435
**Parameters**
W
wusongqing 已提交
436

E
ester.zhou 已提交
437 438 439
| Name | Readable| Writable| Type                     | Mandatory| Description                    |
| ----- | ---- | --- | ------------------------- | ---- | ------------------------ |
| slots | Yes  | No | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
W
wusongqing 已提交
440

E
ester.zhou 已提交
441
**Example**
W
wusongqing 已提交
442 443 444 445 446 447 448

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

E
ester.zhou 已提交
452
Notification.addSlots(notificationSlotArray).then(() => {
W
wusongqing 已提交
453 454 455 456 457 458
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
459
## Notification.getSlot
W
wusongqing 已提交
460

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

E
ester.zhou 已提交
463
Obtains a notification slot of the specified type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
464

E
ester.zhou 已提交
465
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
466

E
ester.zhou 已提交
467
**Parameters**
W
wusongqing 已提交
468

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

E
ester.zhou 已提交
474
**Example**
W
wusongqing 已提交
475 476 477 478 479 480 481 482 483 484 485 486

```js
// getSlot callback
function getSlotCallback(err,data) {
	console.info("==========================>getSlotCallback=======================>");
}
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback)
```



E
ester.zhou 已提交
487
## Notification.getSlot
W
wusongqing 已提交
488

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

E
ester.zhou 已提交
491
Obtains a notification slot of the specified type. This API uses a promise to return the result.
W
wusongqing 已提交
492

E
ester.zhou 已提交
493
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
494

E
ester.zhou 已提交
495
**Parameters**
W
wusongqing 已提交
496

E
ester.zhou 已提交
497 498 499
| Name    | Readable| Writable| Type    | Mandatory| Description                                                       |
| -------- | ---- | --- | -------- | ---- | ----------------------------------------------------------- |
| slotType | Yes  | No | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
W
wusongqing 已提交
500

E
ester.zhou 已提交
501
**Return value**
W
wusongqing 已提交
502

E
ester.zhou 已提交
503 504 505 506 507
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
508 509 510 511 512 513 514 515 516 517

```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => {
	console.info("==========================>getSlotCallback=======================>");
});
```



E
ester.zhou 已提交
518
## Notification.getSlots
W
wusongqing 已提交
519

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

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

E
ester.zhou 已提交
524
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
525

E
ester.zhou 已提交
526
**Parameters**
W
wusongqing 已提交
527

E
ester.zhou 已提交
528 529 530
| Name    | Readable| Writable| Type                             | Mandatory| Description                |
| -------- | ---- | --- | --------------------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<[NotificationSlot](#notificationslot)\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
531

E
ester.zhou 已提交
532
**Example**
W
wusongqing 已提交
533 534 535 536 537 538 539 540 541 542 543

```js
// getSlots callback
function getSlotsCallback(err,data) {
	console.info("==========================>getSlotsCallback=======================>");
}
Notification.getSlots(getSlotsCallback)
```



E
ester.zhou 已提交
544
## Notification.getSlots
W
wusongqing 已提交
545

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

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

E
ester.zhou 已提交
550
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
551

E
ester.zhou 已提交
552
**Return value**
W
wusongqing 已提交
553

E
ester.zhou 已提交
554 555 556
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.|
W
wusongqing 已提交
557

E
ester.zhou 已提交
558
**Example**
W
wusongqing 已提交
559 560 561 562 563 564 565 566 567

```js
Notification.getSlots().then((data) => {
	console.info("==========================>getSlotsCallback=======================>");
});
```



E
ester.zhou 已提交
568
## Notification.removeSlot
W
wusongqing 已提交
569

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

E
ester.zhou 已提交
572
Removes a notification slot of the specified type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
573

E
ester.zhou 已提交
574
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
575

E
ester.zhou 已提交
576
**Parameters**
W
wusongqing 已提交
577

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

E
ester.zhou 已提交
583
**Example**
W
wusongqing 已提交
584 585 586 587 588 589 590 591 592 593 594 595

```js
// removeSlot callback
function removeSlotCallback(err) {
	console.info("==========================>removeSlotCallback=======================>");
}
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback)
```



E
ester.zhou 已提交
596
## Notification.removeSlot
W
wusongqing 已提交
597

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

E
ester.zhou 已提交
600
Removes a notification slot of the specified type. This API uses a promise to return the result.
W
wusongqing 已提交
601

E
ester.zhou 已提交
602
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
603

E
ester.zhou 已提交
604
**Parameters**
W
wusongqing 已提交
605

E
ester.zhou 已提交
606 607 608
| Name    | Readable| Writable| Type    | Mandatory| Description                                                       |
| -------- | ---- | --- | -------- | ---- | ----------------------------------------------------------- |
| slotType | Yes  | No | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
W
wusongqing 已提交
609

E
ester.zhou 已提交
610
**Example**
W
wusongqing 已提交
611 612 613

```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
614
Notification.removeSlot(slotType).then(() => {
W
wusongqing 已提交
615 616 617 618 619 620
	console.info("==========================>removeSlotCallback=======================>");
});
```



E
ester.zhou 已提交
621
## Notification.removeAllSlots
W
wusongqing 已提交
622

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

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

E
ester.zhou 已提交
627
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
628

E
ester.zhou 已提交
629
**Parameters**
W
wusongqing 已提交
630

E
ester.zhou 已提交
631 632 633
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
634

E
ester.zhou 已提交
635
**Example**
W
wusongqing 已提交
636 637 638 639 640 641 642 643 644 645

```js
function removeAllCallBack(err) {
	console.info("================>removeAllCallBack=======================>");
}
Notification.removeAllSlots(removeAllCallBack)
```



E
ester.zhou 已提交
646
## Notification.removeAllSlots
W
wusongqing 已提交
647

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

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

E
ester.zhou 已提交
652
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
653

E
ester.zhou 已提交
654
**Example**
W
wusongqing 已提交
655 656

```js
E
ester.zhou 已提交
657
Notification.removeAllSlots().then(() => {
W
wusongqing 已提交
658 659 660 661 662 663
	console.info("==========================>removeAllCallBack=======================>");
});
```



E
ester.zhou 已提交
664
## Notification.subscribe
W
wusongqing 已提交
665

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

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

E
ester.zhou 已提交
670
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
671

E
ester.zhou 已提交
672
**Parameters**
W
wusongqing 已提交
673

E
ester.zhou 已提交
674 675 676 677 678
| Name      | Readable| Writable| Type                     | Mandatory| Description            |
| ---------- | ---- | --- | ------------------------- | ---- | ---------------- |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.    |
| info       | Yes  | No | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes  | Subscription information.        |
| callback   | Yes  | No | AsyncCallback\<void\>     | Yes  | Callback used to return the result.|
W
wusongqing 已提交
679

E
ester.zhou 已提交
680
**Example**
W
wusongqing 已提交
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700

```js
// subscribe callback
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
var info = {
    bundleNames: ["bundleName1","bundleName2"]
}
Notification.subscribe(subscriber, info, subscribeCallback);
```



E
ester.zhou 已提交
701
## Notification.subscribe
W
wusongqing 已提交
702

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

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

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

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

E
ester.zhou 已提交
711 712 713 714
| Name      | Readable| Writable| Type                  | Mandatory| Description            |
| ---------- | ---- | --- | ---------------------- | ---- | ---------------- |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.    |
| callback   | Yes  | No | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
715

E
ester.zhou 已提交
716
**Example**
W
wusongqing 已提交
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732

```js
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.subscribe(subscriber, subscribeCallback);
```



E
ester.zhou 已提交
733
## Notification.subscribe
W
wusongqing 已提交
734

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

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

E
ester.zhou 已提交
739
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
740

E
ester.zhou 已提交
741
**Parameters**
W
wusongqing 已提交
742

E
ester.zhou 已提交
743 744 745 746
| Name      | Readable| Writable| Type                     | Mandatory| Description        |
| ---------- | ---- | --- | ------------------------- | ---- | ------------ |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.|
| info       | Yes  | No | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No  | Subscription information.    |
W
wusongqing 已提交
747

E
ester.zhou 已提交
748
**Example**
W
wusongqing 已提交
749 750 751 752 753 754 755 756

```js
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
757
Notification.subscribe(subscriber).then(() => {
W
wusongqing 已提交
758 759 760 761 762 763
	console.info("==========================>subscribeCallback=======================>");
});
```



E
ester.zhou 已提交
764
## Notification.unsubscribe
W
wusongqing 已提交
765

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

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

E
ester.zhou 已提交
770
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
771

E
ester.zhou 已提交
772
**Parameters**
W
wusongqing 已提交
773

E
ester.zhou 已提交
774 775 776 777
| Name      | Readable| Writable| Type                  | Mandatory| Description                |
| ---------- | ---- | --- | ---------------------- | ---- | -------------------- |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.        |
| callback   | Yes  | No | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
778

E
ester.zhou 已提交
779
**Example**
W
wusongqing 已提交
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795

```js
function unsubscribeCallback(err) {
	console.info("==========================>unsubscribeCallback=======================>");
}
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.unsubscribe(subscriber, unsubscribeCallback);
```



E
ester.zhou 已提交
796
## Notification.unsubscribe
W
wusongqing 已提交
797

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

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

E
ester.zhou 已提交
802
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
803

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

E
ester.zhou 已提交
806 807 808
| Name      | Readable| Writable| Type                  | Mandatory| Description        |
| ---------- | ---- | --- | ---------------------- | ---- | ------------ |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
W
wusongqing 已提交
809

E
ester.zhou 已提交
810
**Example**
W
wusongqing 已提交
811 812 813 814 815 816 817 818

```js
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
819
Notification.unsubscribe(subscriber).then(() => {
W
wusongqing 已提交
820 821 822 823 824 825
	console.info("==========================>unsubscribeCallback=======================>");
});
```



E
ester.zhou 已提交
826
## Notification.enableNotification
W
wusongqing 已提交
827

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

E
ester.zhou 已提交
830
Sets whether to enable notification for a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
831

E
ester.zhou 已提交
832
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
833

E
ester.zhou 已提交
834
**Parameters**
W
wusongqing 已提交
835

E
ester.zhou 已提交
836 837 838 839 840
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| enable   | Yes  | No | boolean               | Yes  | Whether to enable notification.            |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
841

E
ester.zhou 已提交
842
**Example**
W
wusongqing 已提交
843 844 845 846 847 848

```js
function enableNotificationCallback(err) {
	console.info("==========================>enableNotificationCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
849
    bundle: "bundleName1",
W
wusongqing 已提交
850 851 852 853 854 855
}
Notification.enableNotification(bundle, false, enableNotificationCallback);
```



E
ester.zhou 已提交
856
## Notification.enableNotification
W
wusongqing 已提交
857

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

E
ester.zhou 已提交
860
Sets whether to enable notification for a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
861

E
ester.zhou 已提交
862
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
863

E
ester.zhou 已提交
864
**Parameters**
W
wusongqing 已提交
865

E
ester.zhou 已提交
866 867 868 869
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| enable | Yes  | No | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
870

E
ester.zhou 已提交
871
**Example**
W
wusongqing 已提交
872 873 874

```js
var bundle = {
E
ester.zhou 已提交
875
    bundle: "bundleName1",
W
wusongqing 已提交
876
}
E
ester.zhou 已提交
877
Notification.enableNotification(bundle, false).then(() => {
W
wusongqing 已提交
878 879 880 881 882 883
	console.info("==========================>enableNotificationCallback=======================>");
});
```



E
ester.zhou 已提交
884
## Notification.isNotificationEnabled
W
wusongqing 已提交
885

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

E
ester.zhou 已提交
888
Checks whether notification is enabled for a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
889

E
ester.zhou 已提交
890
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
891

E
ester.zhou 已提交
892
**Parameters**
W
wusongqing 已提交
893

E
ester.zhou 已提交
894 895 896 897
| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.              |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
898

E
ester.zhou 已提交
899
**Example**
W
wusongqing 已提交
900 901 902 903 904 905

```js
function isNotificationEnabledCallback(err, data) {
	console.info("==========================>isNotificationEnabledCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
906
    bundle: "bundleName1",
W
wusongqing 已提交
907 908 909 910 911 912
}
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
```



E
ester.zhou 已提交
913 914 915
## Notification.isNotificationEnabled

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

E
ester.zhou 已提交
917
Checks whether notification is enabled for a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
918

E
ester.zhou 已提交
919
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
920

E
ester.zhou 已提交
921
**Parameters**
W
wusongqing 已提交
922

E
ester.zhou 已提交
923 924 925
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
926

E
ester.zhou 已提交
927
**Return value**
W
wusongqing 已提交
928

E
ester.zhou 已提交
929 930 931
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
932

E
ester.zhou 已提交
933
**Example**
W
wusongqing 已提交
934 935 936

```js
var bundle = {
E
ester.zhou 已提交
937
    bundle: "bundleName1",
W
wusongqing 已提交
938 939 940 941 942 943 944 945
}
Notification.isNotificationEnabled(bundle).then((data) => {
	console.info("==========================>isNotificationEnabledCallback=======================>");
});
```



E
ester.zhou 已提交
946
## Notification.isNotificationEnabled
W
wusongqing 已提交
947

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

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

E
ester.zhou 已提交
952
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
953

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

E
ester.zhou 已提交
956 957 958
| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
959

E
ester.zhou 已提交
960
**Example**
W
wusongqing 已提交
961 962 963 964 965 966 967 968 969 970 971

```js
function isNotificationEnabledCallback(err, data) {
	console.info("==========================>isNotificationEnabledCallback=======================>");
}

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



E
ester.zhou 已提交
972
## Notification.isNotificationEnabled
W
wusongqing 已提交
973

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

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

E
ester.zhou 已提交
978
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
979

E
ester.zhou 已提交
980
**Parameters**
W
wusongqing 已提交
981

E
ester.zhou 已提交
982 983 984
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
985

E
ester.zhou 已提交
986 987 988 989 990
**Return value**

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

E
ester.zhou 已提交
992
**Example**
W
wusongqing 已提交
993 994 995 996 997 998 999 1000 1001

```js
Notification.isNotificationEnabled().then((data) => {
	console.info("==========================>isNotificationEnabledCallback=======================>");
});
```



E
ester.zhou 已提交
1002
## Notification.displayBadge
W
wusongqing 已提交
1003

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

E
ester.zhou 已提交
1006
Sets whether to enable the notification badge for a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1007

E
ester.zhou 已提交
1008
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1009

E
ester.zhou 已提交
1010
**Parameters**
W
wusongqing 已提交
1011

E
ester.zhou 已提交
1012 1013 1014 1015 1016
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| enable   | Yes  | No | boolean               | Yes  | Whether to enable notification.            |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1017

E
ester.zhou 已提交
1018
**Example**
W
wusongqing 已提交
1019 1020 1021 1022 1023 1024

```js
function displayBadgeCallback(err) {
	console.info("==========================>displayBadgeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1025
    bundle: "bundleName1",
W
wusongqing 已提交
1026 1027 1028 1029 1030 1031
}
Notification.displayBadge(bundle, false, displayBadgeCallback);
```



E
ester.zhou 已提交
1032
## Notification.displayBadge
W
wusongqing 已提交
1033

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

E
ester.zhou 已提交
1036
Sets the notification slot for a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
1037

E
ester.zhou 已提交
1038
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1039

E
ester.zhou 已提交
1040
**Parameters**
W
wusongqing 已提交
1041

E
ester.zhou 已提交
1042 1043 1044 1045
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| enable | Yes  | No | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1046

E
ester.zhou 已提交
1047
**Example**
W
wusongqing 已提交
1048 1049 1050

```js
var bundle = {
E
ester.zhou 已提交
1051
    bundle: "bundleName1",
W
wusongqing 已提交
1052
}
E
ester.zhou 已提交
1053
Notification.displayBadge(bundle, false).then(() => {
W
wusongqing 已提交
1054 1055 1056 1057 1058 1059
	console.info("==========================>displayBadgeCallback=======================>");
});
```



E
ester.zhou 已提交
1060
## Notification.isBadgeDisplayed
W
wusongqing 已提交
1061

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

E
ester.zhou 已提交
1064
Checks whether the notification badge is enabled for a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1065

E
ester.zhou 已提交
1066
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1067

E
ester.zhou 已提交
1068
**Parameters**
W
wusongqing 已提交
1069

E
ester.zhou 已提交
1070 1071 1072 1073
| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.              |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1074

E
ester.zhou 已提交
1075
**Example**
W
wusongqing 已提交
1076 1077 1078 1079 1080 1081

```js
function isBadgeDisplayedCallback(err, data) {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1082
    bundle: "bundleName1",
W
wusongqing 已提交
1083 1084 1085 1086 1087 1088
}
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```



E
ester.zhou 已提交
1089 1090 1091
## Notification.isBadgeDisplayed

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

E
ester.zhou 已提交
1093
Checks whether the notification badge is enabled for a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
1094

E
ester.zhou 已提交
1095
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1096

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

E
ester.zhou 已提交
1099 1100 1101
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1102

E
ester.zhou 已提交
1103
**Return value**
W
wusongqing 已提交
1104

E
ester.zhou 已提交
1105 1106 1107
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1108

E
ester.zhou 已提交
1109
**Example**
W
wusongqing 已提交
1110 1111 1112

```js
var bundle = {
E
ester.zhou 已提交
1113
    bundle: "bundleName1",
W
wusongqing 已提交
1114 1115 1116 1117 1118 1119 1120 1121
}
Notification.isBadgeDisplayed(bundle).then((data) => {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
});
```



E
ester.zhou 已提交
1122
## Notification.setSlotByBundle
W
wusongqing 已提交
1123

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

E
ester.zhou 已提交
1126
Sets the notification slot for a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1127

E
ester.zhou 已提交
1128
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1129

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

E
ester.zhou 已提交
1132 1133 1134 1135 1136
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| slot     | Yes  | No | [NotificationSlot](#notificationslot)      | Yes  | Notification slot.            |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1137

E
ester.zhou 已提交
1138
**Example**
W
wusongqing 已提交
1139 1140 1141 1142 1143 1144

```js
function setSlotByBundleCallback(err) {
	console.info("==========================>setSlotByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1145
    bundle: "bundleName1",
W
wusongqing 已提交
1146 1147 1148 1149 1150 1151 1152 1153 1154
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```



E
ester.zhou 已提交
1155
## Notification.setSlotByBundle
W
wusongqing 已提交
1156

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

E
ester.zhou 已提交
1159
Sets the notification slot for a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
1160

E
ester.zhou 已提交
1161
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1162

E
ester.zhou 已提交
1163
**Parameters**
W
wusongqing 已提交
1164

E
ester.zhou 已提交
1165 1166 1167 1168
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| slot   | Yes  | No | [NotificationSlot](#notificationslot) | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1169

E
ester.zhou 已提交
1170
**Example**
W
wusongqing 已提交
1171 1172 1173

```js
var bundle = {
E
ester.zhou 已提交
1174
    bundle: "bundleName1",
W
wusongqing 已提交
1175 1176 1177 1178
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
1179
Notification.displayBadge(bundle, notificationSlot).then(() => {
W
wusongqing 已提交
1180 1181 1182 1183 1184 1185
	console.info("==========================>setSlotByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1186
## Notification.getSlotsByBundle
W
wusongqing 已提交
1187

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

E
ester.zhou 已提交
1190
Obtains the notification slots of a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1191

E
ester.zhou 已提交
1192
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1193

E
ester.zhou 已提交
1194
**Parameters**
W
wusongqing 已提交
1195

E
ester.zhou 已提交
1196 1197 1198 1199
| Name    | Readable| Writable| Type                                    | Mandatory| Description                |
| -------- | ---- | --- | ---------------------------------------- | ---- | -------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)                             | Yes  | Bundle information.          |
| callback | Yes  | No | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1200

E
ester.zhou 已提交
1201
**Example**
W
wusongqing 已提交
1202 1203 1204 1205 1206 1207

```js
function getSlotsByBundleCallback(err, data) {
	console.info("==========================>getSlotsByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1208
    bundle: "bundleName1",
W
wusongqing 已提交
1209 1210 1211 1212 1213 1214
}
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```



E
ester.zhou 已提交
1215
## Notification.getSlotsByBundle
W
wusongqing 已提交
1216

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

E
ester.zhou 已提交
1219
Obtains the notification slots of a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
1220

E
ester.zhou 已提交
1221
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1222

E
ester.zhou 已提交
1223
**Parameters**
W
wusongqing 已提交
1224

E
ester.zhou 已提交
1225 1226 1227
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1228

E
ester.zhou 已提交
1229
**Return value**
W
wusongqing 已提交
1230

E
ester.zhou 已提交
1231 1232 1233 1234 1235
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1236 1237 1238

```js
var bundle = {
E
ester.zhou 已提交
1239
    bundle: "bundleName1",
W
wusongqing 已提交
1240 1241 1242 1243 1244 1245 1246 1247
}
Notification.getSlotsByBundle(bundle).then((data) => {
	console.info("==========================>getSlotsByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1248
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1249

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

E
ester.zhou 已提交
1252
Obtains the number of notification slots of a specified bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1253

E
ester.zhou 已提交
1254
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1255

E
ester.zhou 已提交
1256
**Parameters**
W
wusongqing 已提交
1257

E
ester.zhou 已提交
1258 1259 1260 1261
| Name    | Readable| Writable| Type                     | Mandatory| Description                  |
| -------- | ---- | --- | ------------------------- | ---- | ---------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)              | Yes  | Bundle information.            |
| callback | Yes  | No | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1262

E
ester.zhou 已提交
1263
**Example**
W
wusongqing 已提交
1264 1265 1266 1267 1268 1269

```js
function getSlotNumByBundle(err, data) {
	console.info("==========================>getSlotNumByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1270
    bundle: "bundleName1",
W
wusongqing 已提交
1271 1272 1273 1274 1275 1276
}
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
```



E
ester.zhou 已提交
1277
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1278

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

E
ester.zhou 已提交
1281
Obtains the number of notification slots of a specified bundle. This API uses a promise to return the result.
W
wusongqing 已提交
1282

E
ester.zhou 已提交
1283
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1284

E
ester.zhou 已提交
1285
**Parameters**
W
wusongqing 已提交
1286

E
ester.zhou 已提交
1287 1288 1289
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1290

E
ester.zhou 已提交
1291
**Return value**
W
wusongqing 已提交
1292

E
ester.zhou 已提交
1293 1294 1295 1296 1297
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1298 1299 1300

```js
var bundle = {
E
ester.zhou 已提交
1301
    bundle: "bundleName1",
W
wusongqing 已提交
1302 1303 1304 1305 1306 1307 1308 1309
}
Notification.getSlotNumByBundle(bundle).then((data) => {
	console.info("==========================>getSlotNumByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1310
## Notification.remove
W
wusongqing 已提交
1311

E
ester.zhou 已提交
1312
remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1313

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

E
ester.zhou 已提交
1316
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1317

E
ester.zhou 已提交
1318
**Parameters**
W
wusongqing 已提交
1319

E
ester.zhou 已提交
1320 1321 1322 1323 1324
| Name           | Readable| Writable| Type                               | Mandatory| Description                |
| --------------- | ---- | --- | ----------------------------------- | ---- | -------------------- |
| bundle          | Yes  | No | [BundleOption](#bundleoption)       | Yes  | Bundle information.          |
| notificationKey | Yes  | No | [NotificationKey](#notificationkey) | Yes  | Notification key.            |
| callback        | Yes  | No | AsyncCallback\<void\>               | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1325

E
ester.zhou 已提交
1326
**Example**
W
wusongqing 已提交
1327 1328 1329 1330 1331 1332

```js
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1333
    bundle: "bundleName1",
W
wusongqing 已提交
1334 1335
}
var notificationKey = {
E
ester.zhou 已提交
1336 1337
    id: 0,
    label: "label",
W
wusongqing 已提交
1338 1339 1340 1341 1342 1343
}
Notification.remove(bundle, notificationKey, removeCallback);
```



E
ester.zhou 已提交
1344
## Notification.remove
W
wusongqing 已提交
1345

E
ester.zhou 已提交
1346
remove(bundle: BundleOption, notificationKey: NotificationKey): Promise\<void\>
W
wusongqing 已提交
1347

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

E
ester.zhou 已提交
1350
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1351

E
ester.zhou 已提交
1352
**Parameters**
W
wusongqing 已提交
1353

E
ester.zhou 已提交
1354 1355 1356 1357
| Name           | Readable| Writable| Type           | Mandatory| Description      |
| --------------- | ---- | --- | --------------- | ---- | ---------- |
| bundle          | Yes  | No | [BundleOption](#bundleoption)    | Yes  | Bundle information.|
| notificationKey | Yes  | No | [NotificationKey](#notificationkey) | Yes  | Notification key.  |
W
wusongqing 已提交
1358

E
ester.zhou 已提交
1359
**Example**
W
wusongqing 已提交
1360 1361 1362

```js
var bundle = {
E
ester.zhou 已提交
1363
    bundle: "bundleName1",
W
wusongqing 已提交
1364 1365
}
var notificationKey = {
E
ester.zhou 已提交
1366 1367
    id: 0,
    label: "label",
W
wusongqing 已提交
1368
}
E
ester.zhou 已提交
1369
Notification.remove(bundle, notificationKey).then(() => {
W
wusongqing 已提交
1370 1371 1372 1373 1374 1375
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1376
## Notification.remove
W
wusongqing 已提交
1377

E
ester.zhou 已提交
1378
remove(hashCode: string, callback: AsyncCallback\<void\>): void
W
wusongqing 已提交
1379

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

E
ester.zhou 已提交
1382
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1383

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

E
ester.zhou 已提交
1386 1387 1388 1389
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| hashCode | Yes  | No | string                | Yes  | Unique notification ID.          |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1390

E
ester.zhou 已提交
1391
**Example**
W
wusongqing 已提交
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402

```js
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}

Notification.remove(hashCode, removeCallback);
```



E
ester.zhou 已提交
1403
## Notification.remove
W
wusongqing 已提交
1404

E
ester.zhou 已提交
1405
remove(hashCode: string): Promise\<void\>
W
wusongqing 已提交
1406

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

E
ester.zhou 已提交
1409
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1410

E
ester.zhou 已提交
1411
**Parameters**
W
wusongqing 已提交
1412

E
ester.zhou 已提交
1413 1414 1415
| Name    | Readable| Writable| Type      | Mandatory| Description      |
| -------- | ---- | --- | ---------- | ---- | ---------- |
| hashCode | Yes  | No | string | Yes  | Unique notification ID.|
W
wusongqing 已提交
1416

E
ester.zhou 已提交
1417
**Example**
W
wusongqing 已提交
1418 1419

```js
E
ester.zhou 已提交
1420
Notification.remove(hashCode).then(() => {
W
wusongqing 已提交
1421 1422 1423 1424 1425 1426
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1427
## Notification.removeAll
W
wusongqing 已提交
1428

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

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

E
ester.zhou 已提交
1433
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1434

E
ester.zhou 已提交
1435
**Parameters**
W
wusongqing 已提交
1436

E
ester.zhou 已提交
1437 1438 1439 1440
| Name    | Readable| Writable| Type                 | Mandatory| Description                        |
| -------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1441

E
ester.zhou 已提交
1442
**Example**
W
wusongqing 已提交
1443 1444 1445 1446 1447 1448

```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1449
    bundle: "bundleName1",
W
wusongqing 已提交
1450 1451 1452 1453 1454 1455
}
Notification.removeAll(bundle, removeAllCallback);
```



E
ester.zhou 已提交
1456
## Notification.removeAll
W
wusongqing 已提交
1457

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

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

E
ester.zhou 已提交
1462
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1463

E
ester.zhou 已提交
1464
**Parameters**
W
wusongqing 已提交
1465

E
ester.zhou 已提交
1466 1467 1468
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1469

E
ester.zhou 已提交
1470
**Example**
W
wusongqing 已提交
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481

```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}

Notification.removeAll(removeAllCallback);
```



E
ester.zhou 已提交
1482
## Notification.removeAll
W
wusongqing 已提交
1483

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

E
ester.zhou 已提交
1486
Removes all notifications for a specified user. This API uses a promise to return the result.
W
wusongqing 已提交
1487

E
ester.zhou 已提交
1488
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1489

E
ester.zhou 已提交
1490
**Parameters**
W
wusongqing 已提交
1491

E
ester.zhou 已提交
1492 1493 1494
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | No  | Bundle information.|
W
wusongqing 已提交
1495

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

```js
E
ester.zhou 已提交
1499
Notification.removeAll().then(() => {
W
wusongqing 已提交
1500 1501 1502 1503
	console.info("==========================>removeAllCallback=======================>");
});
```

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

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

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

E
ester.zhou 已提交
1510
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1511

E
ester.zhou 已提交
1512
**Parameters**
W
wusongqing 已提交
1513

E
ester.zhou 已提交
1514 1515 1516 1517
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| userId | Yes  | No | number | Yes  | ID of the user who receives the notification.|
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1518

E
ester.zhou 已提交
1519
**Example**
W
wusongqing 已提交
1520

E
ester.zhou 已提交
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558
```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}

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

**Parameters**

| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| userId | Yes  | No | number | Yes  | ID of the user who receives the notification.|

**Example**

```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}

var userId = 1

Notification.removeAll(userId, removeAllCallback);
```


## Notification.getAllActiveNotifications
W
wusongqing 已提交
1559

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

E
ester.zhou 已提交
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

**Parameters**

| Name    | Readable| Writable| Type                                                        | Mandatory| Description                |
| -------- | ---- | --- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|

**Example**
W
wusongqing 已提交
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583

```js
function getAllActiveNotificationsCallback(err, data) {
	console.info("==========================>getAllActiveNotificationsCallback=======================>");
}

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



E
ester.zhou 已提交
1584
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1585

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

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

E
ester.zhou 已提交
1590
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1591

E
ester.zhou 已提交
1592
**Return value**
W
wusongqing 已提交
1593

E
ester.zhou 已提交
1594 1595 1596
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1597

E
ester.zhou 已提交
1598
**Example**
W
wusongqing 已提交
1599 1600 1601 1602 1603 1604 1605 1606 1607

```js
Notification.getAllActiveNotifications().then((data) => {
	console.info("==========================>getAllActiveNotificationsCallback=======================>");
});
```



E
ester.zhou 已提交
1608
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1609

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

E
ester.zhou 已提交
1612
Obtains the number of active notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1613

E
ester.zhou 已提交
1614
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1615

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

E
ester.zhou 已提交
1618 1619 1620
| Name    | Readable| Writable| Type                  | Mandatory| Description                  |
| -------- | ---- | --- | ---------------------- | ---- | ---------------------- |
| callback | Yes  | No | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1621

E
ester.zhou 已提交
1622
**Example**
W
wusongqing 已提交
1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633

```js
function getActiveNotificationCountCallback(err, data) {
	console.info("==========================>getActiveNotificationCountCallback=======================>");
}

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



E
ester.zhou 已提交
1634
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1635

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

E
ester.zhou 已提交
1638
Obtains the number of active notifications. This API uses a promise to return the result.
W
wusongqing 已提交
1639

E
ester.zhou 已提交
1640
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1641

E
ester.zhou 已提交
1642
**Return value**
W
wusongqing 已提交
1643

E
ester.zhou 已提交
1644 1645 1646
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1647

E
ester.zhou 已提交
1648
**Example**
W
wusongqing 已提交
1649 1650 1651 1652 1653 1654 1655 1656 1657

```js
Notification.getActiveNotificationCount().then((data) => {
	console.info("==========================>getActiveNotificationCountCallback=======================>");
});
```



E
ester.zhou 已提交
1658
## Notification.getActiveNotifications
W
wusongqing 已提交
1659

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

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

E
ester.zhou 已提交
1664
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1665

E
ester.zhou 已提交
1666
**Parameters**
W
wusongqing 已提交
1667

E
ester.zhou 已提交
1668 1669 1670
| Name    | Readable| Writable| Type                                                        | Mandatory| Description                          |
| -------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | Yes  | No | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1671

E
ester.zhou 已提交
1672
**Example**
W
wusongqing 已提交
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683

```js
function getActiveNotificationsCallback(err, data) {
	console.info("==========================>getActiveNotificationsCallback=======================>");
}

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



E
ester.zhou 已提交
1684
## Notification.getActiveNotifications
W
wusongqing 已提交
1685

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

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

E
ester.zhou 已提交
1690
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1691

E
ester.zhou 已提交
1692
**Return value**
W
wusongqing 已提交
1693

E
ester.zhou 已提交
1694 1695 1696
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1697

E
ester.zhou 已提交
1698
**Example**
W
wusongqing 已提交
1699 1700 1701 1702 1703 1704 1705 1706 1707

```js
Notification.getActiveNotifications().then((data) => {
	console.info("==========================>getActiveNotificationsCallback=======================>");
});
```



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

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

E
ester.zhou 已提交
1712
Cancels a notification group of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1713

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

E
ester.zhou 已提交
1716
**Parameters**
W
wusongqing 已提交
1717

E
ester.zhou 已提交
1718 1719 1720 1721
| Name     | Readable| Writable| Type                 | Mandatory| Description                        |
| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| groupName | Yes  | No | string                | Yes  | Name of the notification group.              |
| callback  | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1722

E
ester.zhou 已提交
1723
**Example**
W
wusongqing 已提交
1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736

```js
function cancelGroupCallback(err) {
   console.info("==========================>cancelGroupCallback=======================>");
}

var groupName = "GroupName";

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



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

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

E
ester.zhou 已提交
1741
Cancels a notification group of this application. This API uses a promise to return the result.
W
wusongqing 已提交
1742

E
ester.zhou 已提交
1743
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1744

E
ester.zhou 已提交
1745
**Parameters**
W
wusongqing 已提交
1746

E
ester.zhou 已提交
1747 1748 1749
| Name     | Readable| Writable| Type  | Mandatory| Description          |
| --------- | ---- | --- | ------ | ---- | -------------- |
| groupName | Yes  | No | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
1750

E
ester.zhou 已提交
1751
**Example**
W
wusongqing 已提交
1752 1753 1754 1755 1756 1757 1758 1759 1760 1761

```js
var groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => {
	console.info("==========================>cancelGroupPromise=======================>");
});
```



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

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

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

E
ester.zhou 已提交
1768
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1769

E
ester.zhou 已提交
1770
**Parameters**
W
wusongqing 已提交
1771

E
ester.zhou 已提交
1772 1773 1774 1775 1776
| Name     | Readable| Writable| Type                 | Mandatory| Description                        |
| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| bundle    | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
| groupName | Yes  | No | string                | Yes  | Name of the notification group.              |
| callback  | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1777

E
ester.zhou 已提交
1778
**Example**
W
wusongqing 已提交
1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792

```js
function removeGroupByBundleCallback(err) {
   console.info("==========================>removeGroupByBundleCallback=======================>");
}

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

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



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

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

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

E
ester.zhou 已提交
1799
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1800

E
ester.zhou 已提交
1801
**Parameters**
W
wusongqing 已提交
1802

E
ester.zhou 已提交
1803 1804 1805 1806
| Name     | Readable| Writable| Type        | Mandatory| Description          |
| --------- | ---- | --- | ------------ | ---- | -------------- |
| bundle    | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.    |
| groupName | Yes  | No | string       | Yes  | Name of the notification group.|
W
wusongqing 已提交
1807

E
ester.zhou 已提交
1808
**Example**
W
wusongqing 已提交
1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819

```js
var bundleOption = {bundle: "Bundle"};
var groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
	console.info("==========================>removeGroupByBundlePromise=======================>");
});
```



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

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

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

E
ester.zhou 已提交
1826
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1827

E
ester.zhou 已提交
1828
**Parameters**
W
wusongqing 已提交
1829

E
ester.zhou 已提交
1830 1831 1832 1833
| Name    | Readable| Writable| Type                 | Mandatory| Description                  |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
| date     | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1834

E
ester.zhou 已提交
1835
**Example**
W
wusongqing 已提交
1836 1837 1838 1839 1840 1841 1842

```js
function setDoNotDisturbDateCallback(err) {
   console.info("==========================>setDoNotDisturbDateCallback=======================>");
}

var doNotDisturbDate = {
E
ester.zhou 已提交
1843
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
1844 1845 1846 1847 1848 1849 1850 1851 1852
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

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



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

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

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

E
ester.zhou 已提交
1859
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1860

E
ester.zhou 已提交
1861
**Parameters**
W
wusongqing 已提交
1862

E
ester.zhou 已提交
1863 1864 1865
| Name| Readable| Writable| Type            | Mandatory| Description          |
| ---- | ---- | --- | ---------------- | ---- | -------------- |
| date | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
1866

E
ester.zhou 已提交
1867
**Example**
W
wusongqing 已提交
1868 1869 1870

```js
var doNotDisturbDate = {
E
ester.zhou 已提交
1871
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
1872 1873 1874 1875 1876 1877 1878 1879 1880
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
	console.info("==========================>setDoNotDisturbDatePromise=======================>");
});
```


E
ester.zhou 已提交
1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923
## 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

**Parameters**

| Name    | Readable| Writable| Type                 | Mandatory| Description                  |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
| date     | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| userId   | Yes  | No | number                | Yes  | User ID.|
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|

**Example**

```js
function setDoNotDisturbDateCallback(err) {
   console.info("==========================>setDoNotDisturbDateCallback=======================>");
}

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 已提交
1924

E
ester.zhou 已提交
1925
**Parameters**
W
wusongqing 已提交
1926

E
ester.zhou 已提交
1927 1928 1929 1930
| Name  | Readable| Writable| Type            | Mandatory| Description          |
| ------ | ---- | --- | ---------------- | ---- | -------------- |
| date   | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
| userId | Yes  | No | number           | Yes  | User ID.|
W
wusongqing 已提交
1931

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

E
ester.zhou 已提交
1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949
```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(() => {
	console.info("==========================>setDoNotDisturbDatePromise=======================>");
});
```


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

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

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

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

E
ester.zhou 已提交
1957 1958 1959 1960 1961 1962 1963
**Parameters**

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

**Example**
W
wusongqing 已提交
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974

```js
function getDoNotDisturbDateCallback(err,data) {
   console.info("==========================>getDoNotDisturbDateCallback=======================>");
}

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



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

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

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

E
ester.zhou 已提交
1981
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1982

E
ester.zhou 已提交
1983
**Return value**
W
wusongqing 已提交
1984

E
ester.zhou 已提交
1985 1986 1987
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
1988

E
ester.zhou 已提交
1989
**Example**
W
wusongqing 已提交
1990 1991 1992 1993 1994 1995 1996 1997

```js
Notification.getDoNotDisturbDate().then((data) => {
	console.info("==========================>getDoNotDisturbDatePromise=======================>");
});
```


E
ester.zhou 已提交
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027
## 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

**Parameters**

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

**Example**

```js
function getDoNotDisturbDateCallback(err,data) {
   console.info("==========================>getDoNotDisturbDateCallback=======================>");
}

var userId = 1

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



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

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

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

E
ester.zhou 已提交
2033
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2034

E
ester.zhou 已提交
2035
**Parameters**
W
wusongqing 已提交
2036

E
ester.zhou 已提交
2037 2038 2039
| Name    | Readable| Writable| Type                             | Mandatory| Description                  |
| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
| userId   | Yes  | No | number                            | Yes  | User ID.|
W
wusongqing 已提交
2040

E
ester.zhou 已提交
2041
**Return value**
W
wusongqing 已提交
2042

E
ester.zhou 已提交
2043 2044 2045
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2046

E
ester.zhou 已提交
2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072
**Example**

```js
var userId = 1

Notification.getDoNotDisturbDate(userId).then((data) => {
	console.info("==========================>getDoNotDisturbDatePromise=======================>");
});
```


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

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

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

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

**Parameters**

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

**Example**
W
wusongqing 已提交
2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083

```js
function supportDoNotDisturbModeCallback(err,data) {
   console.info("==========================>supportDoNotDisturbModeCallback=======================>");
}

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



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

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

E
ester.zhou 已提交
2088
Checks whether the DND mode is supported. This API uses a promise to return the result.
W
wusongqing 已提交
2089

E
ester.zhou 已提交
2090
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2091

E
ester.zhou 已提交
2092
**Return value**
W
wusongqing 已提交
2093

E
ester.zhou 已提交
2094 2095 2096
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2097

E
ester.zhou 已提交
2098
**Example**
W
wusongqing 已提交
2099 2100 2101 2102 2103 2104 2105 2106 2107

```js
Notification.supportDoNotDisturbMode().then((data) => {
	console.info("==========================>supportDoNotDisturbModePromise=======================>");
});
```



E
ester.zhou 已提交
2108
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2109 2110 2111

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

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

E
ester.zhou 已提交
2114
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2115

E
ester.zhou 已提交
2116 2117 2118
**Parameters**

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

E
ester.zhou 已提交
2123
**Example**
W
wusongqing 已提交
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135

```javascript
var templateName = 'process';
function isSupportTemplateCallback(err, data) {
    console.info("isSupportTemplateCallback");
}

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



E
ester.zhou 已提交
2136
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2137 2138 2139

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

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

E
ester.zhou 已提交
2142
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2143

E
ester.zhou 已提交
2144 2145 2146
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2147
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2148
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2149

E
ester.zhou 已提交
2150
**Return value**
W
wusongqing 已提交
2151

E
ester.zhou 已提交
2152
| Type              | Description           |
W
wusongqing 已提交
2153 2154 2155
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2156
**Example**
W
wusongqing 已提交
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167

```javascript
var templateName = 'process';

Notification.isSupportTemplate(templateName).then((data) => {
    console.info("isSupportTemplateCallback");
});
```



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

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

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

E
ester.zhou 已提交
2174
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2175

E
ester.zhou 已提交
2176
**Parameters**
W
wusongqing 已提交
2177

E
ester.zhou 已提交
2178 2179 2180
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2181

E
ester.zhou 已提交
2182
**Example**
W
wusongqing 已提交
2183

E
ester.zhou 已提交
2184 2185 2186 2187 2188 2189
```javascript
function requestEnabledNotificationCallback() {
    console.log('------------- requestEnabledNotification --------------');
};

Notification.requestEnabledNotification(requestEnabledNotificationCallback);
W
wusongqing 已提交
2190 2191 2192 2193
```



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

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

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

E
ester.zhou 已提交
2200
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2201

E
ester.zhou 已提交
2202
**Example**
W
wusongqing 已提交
2203

E
ester.zhou 已提交
2204 2205 2206 2207 2208 2209
```javascript
Notification.requestEnableNotification()
    .then(() => {
        console.info("requestEnableNotification ");
	});
```
W
wusongqing 已提交
2210 2211


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

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

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

E
ester.zhou 已提交
2218
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2219

E
ester.zhou 已提交
2220
**Parameters**
W
wusongqing 已提交
2221

E
ester.zhou 已提交
2222 2223 2224 2225
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2226

E
ester.zhou 已提交
2227
**Example**
W
wusongqing 已提交
2228

E
ester.zhou 已提交
2229 2230 2231 2232
```javascript
function enabledNotificationCallback() {
    console.log('----------- enableDistributed ------------');
};
W
wusongqing 已提交
2233

E
ester.zhou 已提交
2234
var enable = true
W
wusongqing 已提交
2235

E
ester.zhou 已提交
2236
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2237 2238 2239 2240
```



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

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

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

E
ester.zhou 已提交
2247
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2248

E
ester.zhou 已提交
2249
**Parameters**
W
wusongqing 已提交
2250

E
ester.zhou 已提交
2251 2252 2253
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|
W
wusongqing 已提交
2254

E
ester.zhou 已提交
2255
**Example**
W
wusongqing 已提交
2256

E
ester.zhou 已提交
2257 2258
```javascript
var enable = true
W
wusongqing 已提交
2259

E
ester.zhou 已提交
2260 2261 2262 2263 2264
Notification.enableDistributed(enable)
    .then(() => {
        console.log('-------- enableDistributed ----------');
    });
```
W
wusongqing 已提交
2265 2266


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

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

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

E
ester.zhou 已提交
2273
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2274

E
ester.zhou 已提交
2275
**Parameters**
W
wusongqing 已提交
2276

E
ester.zhou 已提交
2277 2278 2279
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2280

E
ester.zhou 已提交
2281
**Example**
W
wusongqing 已提交
2282

E
ester.zhou 已提交
2283 2284 2285 2286
```javascript
function isDistributedEnabledCallback() {
    console.log('----------- isDistributedEnabled ------------');
};
W
wusongqing 已提交
2287

E
ester.zhou 已提交
2288 2289
Notification.enableDistributed(isDistributedEnabledCallback);
```
W
wusongqing 已提交
2290 2291 2292



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

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

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

E
ester.zhou 已提交
2299
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2300

E
ester.zhou 已提交
2301
**Return value**
W
wusongqing 已提交
2302

E
ester.zhou 已提交
2303 2304 2305
| Type              | Description           |
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|
W
wusongqing 已提交
2306

E
ester.zhou 已提交
2307 2308 2309 2310 2311 2312 2313
**Example**

```javascript
Notification.isDistributedEnabled()
    .then((data) => {
        console.log('-------- isDistributedEnabled ----------');
    });
W
wusongqing 已提交
2314 2315 2316
```


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

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

E
ester.zhou 已提交
2321
Sets whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2322

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

E
ester.zhou 已提交
2325
**Parameters**
W
wusongqing 已提交
2326

E
ester.zhou 已提交
2327 2328 2329 2330 2331
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                      |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2332

E
ester.zhou 已提交
2333
**Example**
W
wusongqing 已提交
2334

E
ester.zhou 已提交
2335 2336 2337 2338
```javascript
function enableDistributedByBundleCallback() {
    console.log('----------- enableDistributedByBundle ------------');
};
W
wusongqing 已提交
2339

E
ester.zhou 已提交
2340 2341 2342
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2343

E
ester.zhou 已提交
2344
var enable = true
W
wusongqing 已提交
2345

E
ester.zhou 已提交
2346 2347
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2348 2349


E
ester.zhou 已提交
2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370

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

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

Sets whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result.

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

**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 已提交
2371 2372
}

E
ester.zhou 已提交
2373
var enable = true
W
wusongqing 已提交
2374

E
ester.zhou 已提交
2375 2376 2377 2378
Notification.enableDistributedByBundle(bundle, enable)
    .then(() => {
        console.log('-------- enableDistributedByBundle ----------');
    });
W
wusongqing 已提交
2379 2380
```

E
ester.zhou 已提交
2381
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
W
wusongqing 已提交
2382

E
ester.zhou 已提交
2383
isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
W
wusongqing 已提交
2384

E
ester.zhou 已提交
2385
Obtains whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2386

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

E
ester.zhou 已提交
2389
**Parameters**
W
wusongqing 已提交
2390

E
ester.zhou 已提交
2391 2392 2393 2394
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2395

E
ester.zhou 已提交
2396
**Example**
W
wusongqing 已提交
2397

E
ester.zhou 已提交
2398 2399 2400 2401
```javascript
function isDistributedEnabledByBundleCallback(data) {
    console.log('----------- isDistributedEnabledByBundle ------------', data);
};
W
wusongqing 已提交
2402

E
ester.zhou 已提交
2403 2404 2405
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2406

E
ester.zhou 已提交
2407 2408
Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallback);
```
W
wusongqing 已提交
2409 2410 2411



E
ester.zhou 已提交
2412
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
W
wusongqing 已提交
2413

E
ester.zhou 已提交
2414
isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
W
wusongqing 已提交
2415

E
ester.zhou 已提交
2416
Obtains whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result.
W
wusongqing 已提交
2417

E
ester.zhou 已提交
2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436
**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.               |

**Return value**

| Type              | Description           |
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.<br>**true**: The device supports distributed notifications.<br>**false**: The device does not support distributed notifications.|

**Example**

```javascript
var bundle = {
    bundle: "bundleName1",
W
wusongqing 已提交
2437
}
E
ester.zhou 已提交
2438 2439 2440 2441 2442

Notification.isDistributedEnabledByBundle(bundle)
    .then((data) => {
        console.log('-------- isDistributedEnabledByBundle ----------', data);
    });
W
wusongqing 已提交
2443 2444 2445
```


E
ester.zhou 已提交
2446
## Notification.getDeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
2447

E
ester.zhou 已提交
2448
getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
W
wusongqing 已提交
2449

E
ester.zhou 已提交
2450
Obtains the notification reminder type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2451

E
ester.zhou 已提交
2452
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2453

E
ester.zhou 已提交
2454
**Parameters**
W
wusongqing 已提交
2455

E
ester.zhou 已提交
2456 2457 2458
| Name  | Type                              | Mandatory| Description                      |
| -------- | --------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2459

E
ester.zhou 已提交
2460
**Example**
W
wusongqing 已提交
2461

E
ester.zhou 已提交
2462 2463 2464 2465
```javascript
function getDeviceRemindTypeCallback(data) {
    console.log('----------- getDeviceRemindType ------------', data);
};
W
wusongqing 已提交
2466

E
ester.zhou 已提交
2467 2468
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2469 2470 2471



E
ester.zhou 已提交
2472
## Notification.getDeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
2473

E
ester.zhou 已提交
2474
getDeviceRemindType(): Promise\<DeviceRemindType\>
W
wusongqing 已提交
2475

E
ester.zhou 已提交
2476
Obtains the notification reminder type. This API uses a promise to return the result.
W
wusongqing 已提交
2477

E
ester.zhou 已提交
2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492
**System capability**: SystemCapability.Notification.Notification

**Return value**

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

**Example**

```javascript
Notification.getDeviceRemindType()
    .then((data) => {
        console.log('-------- getDeviceRemindType ----------', data);
    });
W
wusongqing 已提交
2493 2494
```

E
ester.zhou 已提交
2495 2496 2497 2498 2499
## NotificationSubscriber

### onConsume

onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata))
W
wusongqing 已提交
2500

E
ester.zhou 已提交
2501
Callback for receiving notifications.
W
wusongqing 已提交
2502

E
ester.zhou 已提交
2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520
**System capability**: SystemCapability.Notification.Notification

**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|

**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
2521

E
ester.zhou 已提交
2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535
function onConsumeCallback(data) {
    console.info('===> onConsume in test');
    let req = data.request;
    console.info('===> onConsume callback req.id:' + req.id);
    let wantAgent = data.wantAgent;
    wantAgent .getWant(wantAgent)
        .then((data1) => {
            console.log('===> getWant success want:' + JSON.stringfy(data1));
        })
        .catch((err) => {
            console.error('===> getWant failed because' + JSON.stringfy(err));
        });
    console.info('===> onConsume callback req.wantAgent:' + JSON.stringfy(req.wantAgent));
};
W
wusongqing 已提交
2536

E
ester.zhou 已提交
2537 2538 2539
var subscriber = {
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
2540

E
ester.zhou 已提交
2541 2542
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
2543

E
ester.zhou 已提交
2544
### onCancel
W
wusongqing 已提交
2545

E
ester.zhou 已提交
2546
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata))
W
wusongqing 已提交
2547

E
ester.zhou 已提交
2548
Callback for removing notifications.
W
wusongqing 已提交
2549

E
ester.zhou 已提交
2550
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2551

E
ester.zhou 已提交
2552
**Parameters**
W
wusongqing 已提交
2553

E
ester.zhou 已提交
2554 2555 2556
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|
W
wusongqing 已提交
2557

E
ester.zhou 已提交
2558
**Example**
W
wusongqing 已提交
2559

E
ester.zhou 已提交
2560 2561 2562 2563
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
2564
    } else {
E
ester.zhou 已提交
2565
        console.info("subscribeCallback");
W
wusongqing 已提交
2566
    }
E
ester.zhou 已提交
2567 2568 2569 2570 2571 2572
};

function onCancelCallback(data) {
    console.info('===> onCancel in test');
    let req = data.request;
    console.info('===> onCancel callback req.id:' + req.id);
W
wusongqing 已提交
2573 2574
}

E
ester.zhou 已提交
2575 2576 2577
var subscriber = {
    onCancel: onCancelCallback
};
W
wusongqing 已提交
2578

E
ester.zhou 已提交
2579
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
2580 2581
```

E
ester.zhou 已提交
2582
### onUpdate
W
wusongqing 已提交
2583

E
ester.zhou 已提交
2584
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap))
W
wusongqing 已提交
2585

E
ester.zhou 已提交
2586
Callback for notification sorting updates.
W
wusongqing 已提交
2587

E
ester.zhou 已提交
2588
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2589

E
ester.zhou 已提交
2590
**Parameters**
W
wusongqing 已提交
2591

E
ester.zhou 已提交
2592 2593 2594
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.|
W
wusongqing 已提交
2595

E
ester.zhou 已提交
2596
**Example**
W
wusongqing 已提交
2597

E
ester.zhou 已提交
2598 2599 2600 2601 2602 2603 2604 2605
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
2606

E
ester.zhou 已提交
2607 2608 2609
function onUpdateCallback() {
    console.info('===> onUpdate in test');
}
W
wusongqing 已提交
2610

E
ester.zhou 已提交
2611 2612 2613
var subscriber = {
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
2614

E
ester.zhou 已提交
2615 2616
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
2617

E
ester.zhou 已提交
2618
### onConnect
W
wusongqing 已提交
2619

E
ester.zhou 已提交
2620
onConnect?:void
W
wusongqing 已提交
2621

E
ester.zhou 已提交
2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638
Callback for subscription.

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

**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 已提交
2639 2640
}

E
ester.zhou 已提交
2641 2642 2643
var subscriber = {
    onConnect: onConnectCallback
};
W
wusongqing 已提交
2644

E
ester.zhou 已提交
2645
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
2646 2647
```

E
ester.zhou 已提交
2648
### onDisconnect
W
wusongqing 已提交
2649

E
ester.zhou 已提交
2650
onDisconnect?:void
W
wusongqing 已提交
2651

E
ester.zhou 已提交
2652
Callback for unsubscription.
W
wusongqing 已提交
2653

E
ester.zhou 已提交
2654
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2655

E
ester.zhou 已提交
2656
**Example**
W
wusongqing 已提交
2657

E
ester.zhou 已提交
2658 2659 2660 2661 2662 2663 2664 2665
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
2666

E
ester.zhou 已提交
2667 2668 2669
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
2670

E
ester.zhou 已提交
2671 2672 2673
var subscriber = {
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
2674

E
ester.zhou 已提交
2675 2676
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
2677

E
ester.zhou 已提交
2678
### onDestroy
W
wusongqing 已提交
2679

E
ester.zhou 已提交
2680
onDestroy?:void
W
wusongqing 已提交
2681

E
ester.zhou 已提交
2682
Callback for service disconnection.
W
wusongqing 已提交
2683

E
ester.zhou 已提交
2684
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2685

E
ester.zhou 已提交
2686 2687 2688 2689 2690 2691
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
2692
    } else {
E
ester.zhou 已提交
2693
        console.info("subscribeCallback");
W
wusongqing 已提交
2694
    }
E
ester.zhou 已提交
2695 2696 2697 2698
};

function onDestroyCallback() {
    console.info('===> onDestroy in test');
W
wusongqing 已提交
2699 2700
}

E
ester.zhou 已提交
2701 2702 2703
var subscriber = {
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
2704

E
ester.zhou 已提交
2705
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
2706 2707
```

E
ester.zhou 已提交
2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730
### onDoNotDisturbDateChange<sup>8+</sup>

onDoNotDisturbDateChange?:(mode: Notification.[DoNotDisturbDate](#donotdisturbdate8))

Callback for DND time setting updates.

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

**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | Notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|

**Example**
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
2731

E
ester.zhou 已提交
2732 2733 2734
function onDoNotDisturbDateChangeCallback() {
    console.info('===> onDoNotDisturbDateChange in test');
}
W
wusongqing 已提交
2735

E
ester.zhou 已提交
2736 2737 2738
var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
W
wusongqing 已提交
2739

E
ester.zhou 已提交
2740 2741
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
2742 2743


E
ester.zhou 已提交
2744
### onEnabledNotificationChanged<sup>8+</sup>
W
wusongqing 已提交
2745

E
ester.zhou 已提交
2746
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8))
W
wusongqing 已提交
2747

E
ester.zhou 已提交
2748
Listens for the notification enable status changes. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2749

E
ester.zhou 已提交
2750
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2751

E
ester.zhou 已提交
2752
**Parameters**
W
wusongqing 已提交
2753

E
ester.zhou 已提交
2754 2755 2756
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
W
wusongqing 已提交
2757

E
ester.zhou 已提交
2758
**Example**
W
wusongqing 已提交
2759

E
ester.zhou 已提交
2760 2761 2762 2763 2764 2765 2766 2767
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
2768

E
ester.zhou 已提交
2769 2770 2771 2772 2773 2774 2775 2776 2777
function onEnabledNotificationChangedCallback(err, callbackData) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("bundle: ", callbackData.bundle);
        console.info("uid: ", callbackData.uid);
        console.info("enable: ", callbackData.enable);
    }
};
W
wusongqing 已提交
2778

E
ester.zhou 已提交
2779 2780 2781
var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
W
wusongqing 已提交
2782

E
ester.zhou 已提交
2783
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
2784 2785
```

E
ester.zhou 已提交
2786
## SubscribeCallbackData
W
wusongqing 已提交
2787

E
ester.zhou 已提交
2788
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2789

E
ester.zhou 已提交
2790 2791 2792 2793 2794 2795 2796
| Name           | Readable| Writable| Type                                             | Mandatory| Description    |
| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- |
| request         | Yes | No | [NotificationRequest](#notificationrequest)       | Yes  | Notification content.|
| sortingMap      | Yes | No | [NotificationSortingMap](#notificationsortingmap) | No  | Notification sorting information.|
| reason          | Yes | No | number                                            | No  | Reason for deletion.|
| sound           | Yes | No | string                                            | No  | Sound used for notification.|
| vibrationValues | Yes | No | Array\<number\>                                   | No  | Vibration used for notification.|
W
wusongqing 已提交
2797 2798


E
ester.zhou 已提交
2799
## EnabledNotificationCallbackData<sup>8+</sup>
W
wusongqing 已提交
2800

E
ester.zhou 已提交
2801
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2802

E
ester.zhou 已提交
2803 2804 2805 2806 2807
| Name  | Readable| Writable| Type   | Mandatory| Description            |
| ------ | ---- | --- | ------- | ---- | ---------------- |
| bundle | Yes | No | string  | Yes  | Bundle name of the application.      |
| uid    | Yes | No | number  | Yes  | UID of the application.       |
| enable | Yes | No | boolean | Yes  | Notification enable status of the application.|
W
wusongqing 已提交
2808 2809


E
ester.zhou 已提交
2810
## DoNotDisturbDate<sup>8+</sup>
W
wusongqing 已提交
2811

E
ester.zhou 已提交
2812
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2813

E
ester.zhou 已提交
2814 2815 2816 2817 2818
| Name | Readable| Writable| Type                                 | Description                    |
| ----- | ---- | --- | ------------------------------------- | ------------------------ |
| type  | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.|
| begin | Yes | No | Date                                  | DND start time.|
| end   | Yes | No | Date                                  | DND end time.|
W
wusongqing 已提交
2819 2820 2821



E
ester.zhou 已提交
2822
## DoNotDisturbType<sup>8+</sup>
W
wusongqing 已提交
2823

E
ester.zhou 已提交
2824
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2825 2826


E
ester.zhou 已提交
2827 2828 2829 2830 2831 2832
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
| TYPE_NONE    | DoNotDisturbType | Non-DND.                          |
| TYPE_ONCE    | DoNotDisturbType | One-shot DND at the specified time segment (only considering the hour and minute).|
| TYPE_DAILY   | DoNotDisturbType | Daily DND at the specified time segment (only considering the hour and minute).|
| TYPE_CLEARLY | DoNotDisturbType | DND at the specified time segment (considering the year, month, day, hour, and minute).    |
W
wusongqing 已提交
2833 2834


E
ester.zhou 已提交
2835
## ContentType
W
wusongqing 已提交
2836

E
ester.zhou 已提交
2837
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2838

E
ester.zhou 已提交
2839 2840 2841 2842 2843 2844 2845
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
| NOTIFICATION_CONTENT_BASIC_TEXT   | ContentType | Normal text notification.    |
| NOTIFICATION_CONTENT_LONG_TEXT    | ContentType | Long text notification.  |
| NOTIFICATION_CONTENT_PICTURE      | ContentType | Picture-attached notification.    |
| NOTIFICATION_CONTENT_CONVERSATION | ContentType | Conversation notification.    |
| NOTIFICATION_CONTENT_MULTILINE    | ContentType | Multi-line text notification.|
W
wusongqing 已提交
2846

E
ester.zhou 已提交
2847
## SlotLevel
W
wusongqing 已提交
2848

E
ester.zhou 已提交
2849
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2850

E
ester.zhou 已提交
2851 2852 2853 2854 2855 2856 2857
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE                        | 0           | The notification feature is disabled.    |
| LEVEL_MIN                         | 1           | The notification feature is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
| LEVEL_LOW                         | 2           | The notification feature is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
| 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 已提交
2858 2859


E
ester.zhou 已提交
2860
## BundleOption
W
wusongqing 已提交
2861

E
ester.zhou 已提交
2862
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2863

E
ester.zhou 已提交
2864 2865 2866 2867
| Name  | Readable| Writable| Type  | Mandatory| Description  |
| ------ | ---- | --- | ------ | ---- | ------ |
| bundle | Yes | Yes | string | Yes  | Bundle name.  |
| uid    | Yes | Yes | number | No  | User ID.|
W
wusongqing 已提交
2868 2869 2870



E
ester.zhou 已提交
2871
## NotificationKey
W
wusongqing 已提交
2872

E
ester.zhou 已提交
2873
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2874

E
ester.zhou 已提交
2875 2876 2877 2878
| Name | Readable| Writable| Type  | Mandatory| Description    |
| ----- | ---- | --- | ------ | ---- | -------- |
| id    | Yes | Yes | number | Yes  | Notification ID.  |
| label | Yes | Yes | string | No  | Notification label.|
W
wusongqing 已提交
2879 2880


E
ester.zhou 已提交
2881
## SlotType
W
wusongqing 已提交
2882

E
ester.zhou 已提交
2883
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2884

E
ester.zhou 已提交
2885 2886 2887 2888 2889 2890 2891
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
| UNKNOWN_TYPE         | SlotType | Unknown type.|
| SOCIAL_COMMUNICATION | SlotType | Notification slot for social communication.|
| SERVICE_INFORMATION  | SlotType | Notification slot for service information.|
| CONTENT_INFORMATION  | SlotType | Notification slot for content consultation.|
| OTHER_TYPES          | SlotType | Notification slot for other purposes.|
W
wusongqing 已提交
2892 2893


E
ester.zhou 已提交
2894
## NotificationActionButton
W
wusongqing 已提交
2895

E
ester.zhou 已提交
2896
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2897

E
ester.zhou 已提交
2898 2899 2900 2901 2902 2903
| Name     | Readable| Writable| Type                                           | Mandatory| Description                     |
| --------- | --- | ---- | ----------------------------------------------- | ---- | ------------------------- |
| title     | Yes | Yes | string                                          | Yes  | Button title.                 |
| wantAgent | Yes | Yes | WantAgent                                       | Yes  | **WantAgent** of the button.|
| extras    | Yes | Yes | { [key: string]: any }                          | No  | Extra information of the button.             |
| userInput<sup>9+</sup> | Yes | Yes | [NotificationUserInput](#notificationuserinput8) | No  | User input object.         |
W
wusongqing 已提交
2904 2905


E
ester.zhou 已提交
2906
## NotificationBasicContent
W
wusongqing 已提交
2907

E
ester.zhou 已提交
2908
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2909

E
ester.zhou 已提交
2910 2911 2912 2913 2914
| Name          | Readable| Writable| Type  | Mandatory| Description                              |
| -------------- | ---- | ---- | ------ | ---- | ---------------------------------- |
| title          | Yes  | Yes  | string | Yes  | Notification title.                        |
| text           | Yes  | Yes  | string | Yes  | Notification content.                        |
| additionalText | Yes  | Yes  | string | No  | Additional information of the notification.|
W
wusongqing 已提交
2915 2916


E
ester.zhou 已提交
2917
## NotificationLongTextContent
W
wusongqing 已提交
2918

E
ester.zhou 已提交
2919
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2920

E
ester.zhou 已提交
2921 2922 2923 2924 2925 2926 2927 2928
| Name          | Readable| Writable| Type  | Mandatory| Description                            |
| -------------- | ---- | --- | ------ | ---- | -------------------------------- |
| title          | Yes | Yes | string | Yes  | Notification title.                        |
| text           | Yes | Yes | string | Yes  | Notification content.                        |
| additionalText | Yes | Yes | string | No  | Additional information of the notification.|
| longText       | Yes | Yes | string | Yes  | Long text of the notification.                    |
| briefText      | Yes | Yes | string | Yes  | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string | Yes  | Title of the notification in the expanded state.                |
W
wusongqing 已提交
2929 2930


E
ester.zhou 已提交
2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115
## NotificationMultiLineContent

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

| Name          | Readable| Writable| Type           | Mandatory| Description                            |
| -------------- | --- | --- | --------------- | ---- | -------------------------------- |
| title          | Yes | Yes | string          | Yes  | Notification title.                        |
| text           | Yes | Yes | string          | Yes  | Notification content.                        |
| additionalText | Yes | Yes | string          | No  | Additional information of the notification.|
| briefText      | Yes | Yes | string          | Yes  | Brief text of the notification.|
| longTitle      | Yes | Yes | string          | Yes  | Title of the notification in the expanded state.                |
| lines          | Yes | Yes | Array\<string\> | Yes  | Multi-line text of the notification.                  |


## NotificationPictureContent

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

| Name          | Readable| Writable| Type          | Mandatory| Description                            |
| -------------- | ---- | --- | -------------- | ---- | -------------------------------- |
| title          | Yes | Yes | string         | Yes  | Notification title.                        |
| text           | Yes | Yes | string         | Yes  | Notification content.                        |
| additionalText | Yes | Yes | string         | No  | Additional information of the notification.|
| briefText      | Yes | Yes | string         | Yes  | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string         | Yes  | Title of the notification in the expanded state.                |
| picture        | Yes | Yes | image.PixelMap | Yes  | Picture attached to the notification.                  |


## NotificationContent

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

| Name       | Readable| Writable| Type                                                        | Mandatory| Description              |
| ----------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------ |
| contentType | Yes | Yes | [ContentType](#contenttype)                                  | Yes  | Notification content type.      |
| normal      | Yes | Yes | [NotificationBasicContent](#notificationbasiccontent)        | No  | Normal text.  |
| longText    | Yes | Yes | [NotificationLongTextContent](#notificationlongtextcontent)  | No  | Long text.|
| multiLine   | Yes | Yes | [NotificationMultiLineContent](#notificationmultilinecontent) | No  | Multi-line text.  |
| picture     | Yes | Yes | [NotificationPictureContent](#notificationpicturecontent)    | No  | Picture-attached.  |


## NotificationFlagStatus<sup>8+</sup>

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

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

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

| Name            | Readable| Writable| Type                   | Mandatory| Description                              |
| ---------------- | ---- | ---- | ---------------------- | ---- | --------------------------------- |
| soundEnabled     | Yes  | No  | NotificationFlagStatus | No  | Whether to enable the sound alert for the notification.                 |
| vibrationEnabled | Yes  | No  | NotificationFlagStatus | No  | Whether to enable vibration for the notification.              |


## NotificationRequest

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

| Name                 | Readable| Writable| Type                                         | Mandatory| Description                      |
| --------------------- | ---- | --- | --------------------------------------------- | ---- | -------------------------- |
| content               | Yes | Yes | [NotificationContent](#notificationcontent)   | Yes  | Notification content.                  |
| id                    | Yes | Yes | number                                        | No  | Notification ID.                    |
| slotType              | Yes | Yes | [SlotType](#slottype)                                      | No  | Slot type.                  |
| isOngoing             | Yes | Yes | boolean                                       | No  | Whether the notification is an ongoing notification.            |
| isUnremovable         | Yes | Yes | boolean                                       | No  | Whether the notification can be removed.                |
| deliveryTime          | Yes | Yes | number                                        | No  | Time when the notification is sent.              |
| tapDismissed          | Yes | Yes | boolean                                       | No  | Whether the notification is automatically cleared.          |
| autoDeletedTime       | Yes | Yes | number                                        | No  | Time when the notification is automatically cleared.            |
| wantAgent             | Yes | Yes | WantAgent                                     | No  | **WantAgent** instance to which the notification will be redirected after being clicked.       |
| extraInfo             | Yes | Yes | {[key: string]: any}                          | No  | Extended parameters.                  |
| color                 | Yes | Yes | number                                        | No  | Background color of the notification.              |
| colorEnabled          | Yes | Yes | boolean                                       | No  | Whether the notification background color is enabled.      |
| isAlertOnce           | Yes | Yes | boolean                                       | No  | Whether the notification triggers an alert only once.|
| isStopwatch           | Yes | Yes | boolean                                       | No  | Whether to display the stopwatch.          |
| isCountDown           | Yes | Yes | boolean                                       | No  | Whether to display the countdown time.        |
| isFloatingIcon        | Yes | Yes | boolean                                       | No  | Whether the notification is displayed as a floating icon.        |
| label                 | Yes | Yes | string                                        | No  | Notification label.                  |
| badgeIconStyle        | Yes | Yes | number                                        | No  | Notification badge type.              |
| showDeliveryTime      | Yes | Yes | boolean                                       | No  | Whether to display the time when the notification is delivered.          |
| actionButtons         | Yes | Yes | Array\<[NotificationActionButton](#notificationactionbutton)\>             | No  | Buttons in the notification. Up to two buttons are allowed.    |
| smallIcon             | Yes | Yes | PixelMap                                      | No  | Small notification icon.                |
| largeIcon             | Yes | Yes | PixelMap                                      | No  | Large notification icon.                |
| creatorBundleName     | Yes | No | string                                        | No  | Name of the bundle that creates the notification.            |
| creatorUid            | Yes | No | number                                        | No  | UID used for creating the notification.             |
| creatorPid            | Yes | No | number                                        | No  | PID used for creating the notification.             |
| creatorUserId<sup>8+</sup>| Yes | No | number                                    | No  | ID of the user who creates a notification.          |
| hashCode              | Yes | No | string                                        | No  | Unique ID of the notification.              |
| classification        | Yes | Yes | string                                        | No  | Notification category.                  |
| groupName<sup>8+</sup>| Yes | Yes | string                                        | No  | Group notification name.                |
| template<sup>8+</sup> | Yes | Yes | [NotificationTemplate](#notificationtemplate8) | No  | Notification template.                  |
| isRemoveAllowed<sup>8+</sup> | Yes | No | boolean                                | No  | Whether the notification can be removed.                  |
| source<sup>8+</sup>   | Yes | No | number                                        | No  | Notification source.                  |
| distributedOption<sup>8+</sup>   | Yes | Yes | [DistributedOptions](#distributedoptions8)                 | No  | Option of distributed notification.         |
| deviceId<sup>8+</sup> | Yes | No | string                                        | No  | Device ID of the notification source.         |
| notificationFlags<sup>8+</sup> | Yes | No | [NotificationFlags](#notificationflags8)                    | No  | Notification flags.         |


## DistributedOptions<sup>8+</sup>

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

| Name                  | Readable| Writable| Type           | Mandatory| Description                              |
| ---------------------- | ---- | ---- | -------------- | ---- | ---------------------------------- |
| isDistributed          | Yes  | Yes  | boolean        | No  | Whether the notification is a distributed notification.                 |
| supportDisplayDevices  | Yes  | Yes  | Array\<string> | Yes  | Types of the devices to which the notification can be synchronized.          |
| supportOperateDevices  | Yes  | Yes  | Array\<string> | No  | Devices on which notification can be enabled.               |
| remindType             | Yes  | No  | number         | No  | Notification reminder type.                   |


## NotificationSlot

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

| Name                | Readable| Writable| Type                 | Mandatory| Description                                      |
| -------------------- | ---- | --- | --------------------- | ---- | ------------------------------------------ |
| type                 | Yes | Yes | [SlotType](#slottype) | Yes  | Slot type.                                  |
| level                | Yes | Yes | number                | No  | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc                 | Yes | Yes | string                | No  | Notification slot description.                          |
| badgeFlag            | Yes | Yes | boolean               | No  | Whether to display the badge.                              |
| bypassDnd            | Yes | Yes | boolean               | No  | Whether to bypass the DND mode in the system.              |
| lockscreenVisibility | Yes | Yes | boolean               | No  | Mode for displaying the notification on the lock screen.                |
| vibrationEnabled     | Yes | Yes | boolean               | No  | Whether vibration is supported for the notification.                                |
| sound                | Yes | Yes | string                | No  | Notification alert tone.                                |
| lightEnabled         | Yes | Yes | boolean               | No  | Whether the indicator blinks for the notification.                                  |
| lightColor           | Yes | Yes | number                | No  | Indicator color of the notification.                                |
| vibrationValues      | Yes | Yes | Array\<number\>       | No  | Vibration mode of the notification.                              |


## NotificationSorting

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

| Name    | Readable| Writable| Type                                 | Mandatory| Description        |
| -------- | ---- | --- | ------------------------------------- | ---- | ------------ |
| slot     | Yes | No | [NotificationSlot](#notificationslot) | Yes  | Notification slot content.|
| hashCode | Yes | No | string                                | Yes  | Unique ID of the notification.|
| ranking  | Yes | No | number                                | Yes  | Notification sequence number.|


## NotificationSortingMap

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

| Name          | Readable| Writable| Type                                                        | Mandatory| Description            |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- |
| sortings       | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes  | Array of notification sorting information.|
| sortedHashCode | Yes | No | Array\<string\>                                              | Yes  | Array of unique notification IDs.|


## NotificationSubscribeInfo

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

| Name       | Readable| Writable| Type           | Mandatory| Description                           |
| ----------- | --- | ---- | --------------- | ---- | ------------------------------- |
| bundleNames | Yes | Yes | Array\<string\> | No  | Bundle names of the applications whose notifications are to be subscribed to.|
| userId      | Yes | Yes | number          | No  | User whose notifications are to be subscribed to.   |


## NotificationTemplate<sup>8+</sup>

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

| Name| Type              | Readable| Writable| Description      |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | Yes  | Yes  | Template name.|
| data | {[key:string]: Object} | Yes  | Yes  | Template data.|


## NotificationUserInput<sup>8+</sup>

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

| Name    | Readable| Writable| Type  | Mandatory| Description                         |
| -------- | --- | ---- | ------ | ---- | ----------------------------- |
| inputKey | Yes | Yes | string | Yes  | Key to identify the user input.|

W
wusongqing 已提交
3116

E
ester.zhou 已提交
3117
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
3118

E
ester.zhou 已提交
3119
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3120

E
ester.zhou 已提交
3121 3122 3123 3124 3125 3126
| 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.                |