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

E
ester.zhou 已提交
3
> **NOTE**<br>
E
ester.zhou 已提交
4
> 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
## 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

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

E
ester.zhou 已提交
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
**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=======================>");
}
E
ester.zhou 已提交
105
// ID of the user who receives the notification
E
ester.zhou 已提交
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
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

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

E
ester.zhou 已提交
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
**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 已提交
155

E
ester.zhou 已提交
156 157 158 159
Notification.publish(notificationRequest, userId).then(() => {
	console.info("==========================>publishCallback=======================>");
});
```
W
wusongqing 已提交
160 161


E
ester.zhou 已提交
162
## Notification.cancel
W
wusongqing 已提交
163

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

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

E
ester.zhou 已提交
168
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
169

E
ester.zhou 已提交
170
**Parameters**
W
wusongqing 已提交
171

E
ester.zhou 已提交
172 173 174 175 176
| 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 已提交
177

E
ester.zhou 已提交
178
**Example**
W
wusongqing 已提交
179 180 181 182 183 184 185 186 187 188 189

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



E
ester.zhou 已提交
190
## Notification.cancel
W
wusongqing 已提交
191

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

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

E
ester.zhou 已提交
196
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
197

E
ester.zhou 已提交
198
**Parameters**
W
wusongqing 已提交
199

E
ester.zhou 已提交
200 201 202 203
| Name | Readable| Writable| Type  | Mandatory| Description    |
| ----- | --- | ---- | ------ | ---- | -------- |
| id    | Yes  | No  | number | Yes  | Notification ID.  |
| label | Yes  | No  | string | No  | Notification label.|
W
wusongqing 已提交
204

E
ester.zhou 已提交
205
**Example**
W
wusongqing 已提交
206 207

```js
E
ester.zhou 已提交
208
Notification.cancel(0).then(() => {
W
wusongqing 已提交
209 210 211 212 213 214
	console.info("==========================>cancelCallback=======================>");
});
```



E
ester.zhou 已提交
215
## Notification.cancel
W
wusongqing 已提交
216

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

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

E
ester.zhou 已提交
221
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
222

E
ester.zhou 已提交
223
**Parameters**
W
wusongqing 已提交
224

E
ester.zhou 已提交
225 226 227 228
| 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 已提交
229

E
ester.zhou 已提交
230
**Example**
W
wusongqing 已提交
231 232 233 234 235 236 237 238 239 240 241

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



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

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

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

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

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

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

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

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



E
ester.zhou 已提交
268
## Notification.cancelAll
W
wusongqing 已提交
269

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

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

E
ester.zhou 已提交
274
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
275

E
ester.zhou 已提交
276
**Example**
W
wusongqing 已提交
277 278

```js
E
ester.zhou 已提交
279 280
Notification.cancelAll().then(() => {
	console.info("==========================>cancelAllCallback=======================>");
W
wusongqing 已提交
281 282 283 284 285
});
```



E
ester.zhou 已提交
286
## Notification.addSlot
W
wusongqing 已提交
287

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

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

E
ester.zhou 已提交
292
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
293

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

E
ester.zhou 已提交
296
**Parameters**
W
wusongqing 已提交
297

E
ester.zhou 已提交
298 299 300 301
| 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 已提交
302

E
ester.zhou 已提交
303
**Example**
W
wusongqing 已提交
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318

```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 已提交
319
## Notification.addSlot
W
wusongqing 已提交
320

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

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

E
ester.zhou 已提交
325
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
326

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

E
ester.zhou 已提交
329
**Parameters**
W
wusongqing 已提交
330

E
ester.zhou 已提交
331 332 333
| Name| Readable| Writable| Type            | Mandatory| Description                |
| ---- | ---- | --- | ---------------- | ---- | -------------------- |
| slot | Yes  | No | [NotificationSlot](#notificationslot) | Yes  | Notification slot to add.|
W
wusongqing 已提交
334

E
ester.zhou 已提交
335
**Example**
W
wusongqing 已提交
336 337 338 339 340 341

```js
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
342
Notification.addSlot(notificationSlot).then(() => {
W
wusongqing 已提交
343 344 345 346 347 348
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
349
## Notification.addSlot
W
wusongqing 已提交
350

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

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

E
ester.zhou 已提交
355
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
356

E
ester.zhou 已提交
357
**Parameters**
W
wusongqing 已提交
358

E
ester.zhou 已提交
359 360 361 362
| 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 已提交
363

E
ester.zhou 已提交
364
**Example**
W
wusongqing 已提交
365 366 367 368 369 370 371 372 373 374 375

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



E
ester.zhou 已提交
376
## Notification.addSlot
W
wusongqing 已提交
377

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

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

E
ester.zhou 已提交
382
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
383

E
ester.zhou 已提交
384
**Parameters**
W
wusongqing 已提交
385

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

E
ester.zhou 已提交
390
**Example**
W
wusongqing 已提交
391 392

```js
E
ester.zhou 已提交
393
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
W
wusongqing 已提交
394 395 396 397 398 399
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
400
## Notification.addSlots
W
wusongqing 已提交
401

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

E
ester.zhou 已提交
404
Adds multiple notification slots. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
405

E
ester.zhou 已提交
406
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
407

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

E
ester.zhou 已提交
410
**Parameters**
W
wusongqing 已提交
411

E
ester.zhou 已提交
412 413 414 415
| 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 已提交
416

E
ester.zhou 已提交
417
**Example**
W
wusongqing 已提交
418 419 420 421 422 423 424 425 426 427 428

```js
// addSlots callback
function addSlotsCallBack(err) {
	console.info("==========================>addSlotsCallBack=======================>");
}
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
// NotificationSlotArray object
E
ester.zhou 已提交
429 430
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
431 432 433 434 435 436

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



E
ester.zhou 已提交
437
## Notification.addSlots
W
wusongqing 已提交
438

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

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

E
ester.zhou 已提交
443
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
444

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

E
ester.zhou 已提交
447
**Parameters**
W
wusongqing 已提交
448

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

E
ester.zhou 已提交
453
**Example**
W
wusongqing 已提交
454 455 456 457 458 459 460

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

E
ester.zhou 已提交
464
Notification.addSlots(notificationSlotArray).then(() => {
W
wusongqing 已提交
465 466 467 468 469 470
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
471
## Notification.getSlot
W
wusongqing 已提交
472

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

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

E
ester.zhou 已提交
477
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
478

E
ester.zhou 已提交
479
**Parameters**
W
wusongqing 已提交
480

E
ester.zhou 已提交
481 482 483 484
| 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 已提交
485

E
ester.zhou 已提交
486
**Example**
W
wusongqing 已提交
487 488 489 490 491 492 493 494 495 496 497 498

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



E
ester.zhou 已提交
499
## Notification.getSlot
W
wusongqing 已提交
500

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

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

E
ester.zhou 已提交
505
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
506

E
ester.zhou 已提交
507
**Parameters**
W
wusongqing 已提交
508

E
ester.zhou 已提交
509 510 511
| 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 已提交
512

E
ester.zhou 已提交
513
**Return value**
W
wusongqing 已提交
514

E
ester.zhou 已提交
515 516 517 518 519
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
520 521 522 523 524 525 526 527 528 529

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



E
ester.zhou 已提交
530
## Notification.getSlots
W
wusongqing 已提交
531

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

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

E
ester.zhou 已提交
536
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
537

E
ester.zhou 已提交
538
**Parameters**
W
wusongqing 已提交
539

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

E
ester.zhou 已提交
544
**Example**
W
wusongqing 已提交
545 546 547 548 549 550 551 552 553 554 555

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



E
ester.zhou 已提交
556
## Notification.getSlots
W
wusongqing 已提交
557

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

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

E
ester.zhou 已提交
562
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
563

E
ester.zhou 已提交
564
**Return value**
W
wusongqing 已提交
565

E
ester.zhou 已提交
566 567 568
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.|
W
wusongqing 已提交
569

E
ester.zhou 已提交
570
**Example**
W
wusongqing 已提交
571 572 573 574 575 576 577 578 579

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



E
ester.zhou 已提交
580
## Notification.removeSlot
W
wusongqing 已提交
581

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

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

E
ester.zhou 已提交
586
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
587

E
ester.zhou 已提交
588
**Parameters**
W
wusongqing 已提交
589

E
ester.zhou 已提交
590 591 592 593
| 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 已提交
594

E
ester.zhou 已提交
595
**Example**
W
wusongqing 已提交
596 597 598 599 600 601 602 603 604 605 606 607

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



E
ester.zhou 已提交
608
## Notification.removeSlot
W
wusongqing 已提交
609

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

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

E
ester.zhou 已提交
614
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
615

E
ester.zhou 已提交
616
**Parameters**
W
wusongqing 已提交
617

E
ester.zhou 已提交
618 619 620
| 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 已提交
621

E
ester.zhou 已提交
622
**Example**
W
wusongqing 已提交
623 624 625

```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
626
Notification.removeSlot(slotType).then(() => {
W
wusongqing 已提交
627 628 629 630 631 632
	console.info("==========================>removeSlotCallback=======================>");
});
```



E
ester.zhou 已提交
633
## Notification.removeAllSlots
W
wusongqing 已提交
634

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

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

E
ester.zhou 已提交
639
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
640

E
ester.zhou 已提交
641
**Parameters**
W
wusongqing 已提交
642

E
ester.zhou 已提交
643 644 645
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
646

E
ester.zhou 已提交
647
**Example**
W
wusongqing 已提交
648 649 650 651 652 653 654 655 656 657

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



E
ester.zhou 已提交
658
## Notification.removeAllSlots
W
wusongqing 已提交
659

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

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

E
ester.zhou 已提交
664
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
665

E
ester.zhou 已提交
666
**Example**
W
wusongqing 已提交
667 668

```js
E
ester.zhou 已提交
669
Notification.removeAllSlots().then(() => {
W
wusongqing 已提交
670 671 672 673 674 675
	console.info("==========================>removeAllCallBack=======================>");
});
```



E
ester.zhou 已提交
676
## Notification.subscribe
W
wusongqing 已提交
677

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

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

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

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

E
ester.zhou 已提交
686
**Parameters**
W
wusongqing 已提交
687

E
ester.zhou 已提交
688 689 690 691 692
| 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 已提交
693

E
ester.zhou 已提交
694
**Example**
W
wusongqing 已提交
695 696 697 698 699 700

```js
// subscribe callback
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
E
ester.zhou 已提交
701
function onConsumeCallback(data) {
W
wusongqing 已提交
702 703 704 705 706 707 708 709 710 711 712 713 714
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
var info = {
    bundleNames: ["bundleName1","bundleName2"]
}
Notification.subscribe(subscriber, info, subscribeCallback);
```



E
ester.zhou 已提交
715
## Notification.subscribe
W
wusongqing 已提交
716

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

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

E
ester.zhou 已提交
721
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
722

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

E
ester.zhou 已提交
725
**Parameters**
W
wusongqing 已提交
726

E
ester.zhou 已提交
727 728 729 730
| 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 已提交
731

E
ester.zhou 已提交
732
**Example**
W
wusongqing 已提交
733 734 735 736 737

```js
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
E
ester.zhou 已提交
738
function onConsumeCallback(data) {
W
wusongqing 已提交
739 740 741 742 743 744 745 746 747 748
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.subscribe(subscriber, subscribeCallback);
```



E
ester.zhou 已提交
749
## Notification.subscribe
W
wusongqing 已提交
750

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

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

E
ester.zhou 已提交
755
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
756

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

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

E
ester.zhou 已提交
761 762 763 764
| Name      | Readable| Writable| Type                     | Mandatory| Description        |
| ---------- | ---- | --- | ------------------------- | ---- | ------------ |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.|
| info       | Yes  | No | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No  | Subscription information.    |
W
wusongqing 已提交
765

E
ester.zhou 已提交
766
**Example**
W
wusongqing 已提交
767 768

```js
E
ester.zhou 已提交
769
function onConsumeCallback(data) {
W
wusongqing 已提交
770 771 772 773 774
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
775
Notification.subscribe(subscriber).then(() => {
W
wusongqing 已提交
776 777 778 779 780 781
	console.info("==========================>subscribeCallback=======================>");
});
```



E
ester.zhou 已提交
782
## Notification.unsubscribe
W
wusongqing 已提交
783

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

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

E
ester.zhou 已提交
788
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
789

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

E
ester.zhou 已提交
792
**Parameters**
W
wusongqing 已提交
793

E
ester.zhou 已提交
794 795 796 797
| 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 已提交
798

E
ester.zhou 已提交
799
**Example**
W
wusongqing 已提交
800 801 802 803 804

```js
function unsubscribeCallback(err) {
	console.info("==========================>unsubscribeCallback=======================>");
}
E
ester.zhou 已提交
805
function onConsumeCallback(data) {
W
wusongqing 已提交
806 807 808 809 810 811 812 813 814 815
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.unsubscribe(subscriber, unsubscribeCallback);
```



E
ester.zhou 已提交
816
## Notification.unsubscribe
W
wusongqing 已提交
817

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

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

E
ester.zhou 已提交
822
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
823

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

E
ester.zhou 已提交
826
**Parameters**
W
wusongqing 已提交
827

E
ester.zhou 已提交
828 829 830
| Name      | Readable| Writable| Type                  | Mandatory| Description        |
| ---------- | ---- | --- | ---------------------- | ---- | ------------ |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
W
wusongqing 已提交
831

E
ester.zhou 已提交
832
**Example**
W
wusongqing 已提交
833 834

```js
E
ester.zhou 已提交
835
function onConsumeCallback(data) {
W
wusongqing 已提交
836 837 838 839 840
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
841
Notification.unsubscribe(subscriber).then(() => {
W
wusongqing 已提交
842 843 844 845 846 847
	console.info("==========================>unsubscribeCallback=======================>");
});
```



E
ester.zhou 已提交
848
## Notification.enableNotification
W
wusongqing 已提交
849

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

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

E
ester.zhou 已提交
854
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
855

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

E
ester.zhou 已提交
858
**Parameters**
W
wusongqing 已提交
859

E
ester.zhou 已提交
860 861 862 863 864
| 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 已提交
865

E
ester.zhou 已提交
866
**Example**
W
wusongqing 已提交
867 868 869 870 871 872

```js
function enableNotificationCallback(err) {
	console.info("==========================>enableNotificationCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
873
    bundle: "bundleName1",
W
wusongqing 已提交
874 875 876 877 878 879
}
Notification.enableNotification(bundle, false, enableNotificationCallback);
```



E
ester.zhou 已提交
880
## Notification.enableNotification
W
wusongqing 已提交
881

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

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

E
ester.zhou 已提交
886
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
887

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

E
ester.zhou 已提交
890
**Parameters**
W
wusongqing 已提交
891

E
ester.zhou 已提交
892 893 894 895
| 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 已提交
896

E
ester.zhou 已提交
897
**Example**
W
wusongqing 已提交
898 899 900

```js
var bundle = {
E
ester.zhou 已提交
901
    bundle: "bundleName1",
W
wusongqing 已提交
902
}
E
ester.zhou 已提交
903
Notification.enableNotification(bundle, false).then(() => {
W
wusongqing 已提交
904 905 906 907 908 909
	console.info("==========================>enableNotificationCallback=======================>");
});
```



E
ester.zhou 已提交
910
## Notification.isNotificationEnabled
W
wusongqing 已提交
911

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

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

E
ester.zhou 已提交
916
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
917

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

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

E
ester.zhou 已提交
922 923 924 925
| 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 已提交
926

E
ester.zhou 已提交
927
**Example**
W
wusongqing 已提交
928 929 930 931 932 933

```js
function isNotificationEnabledCallback(err, data) {
	console.info("==========================>isNotificationEnabledCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
934
    bundle: "bundleName1",
W
wusongqing 已提交
935 936 937 938 939 940
}
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
```



E
ester.zhou 已提交
941 942 943
## Notification.isNotificationEnabled

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

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

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

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

E
ester.zhou 已提交
951
**Parameters**
W
wusongqing 已提交
952

E
ester.zhou 已提交
953 954 955
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
956

E
ester.zhou 已提交
957
**Return value**
W
wusongqing 已提交
958

E
ester.zhou 已提交
959 960 961
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
962

E
ester.zhou 已提交
963
**Example**
W
wusongqing 已提交
964 965 966

```js
var bundle = {
E
ester.zhou 已提交
967
    bundle: "bundleName1",
W
wusongqing 已提交
968 969 970 971 972 973 974 975
}
Notification.isNotificationEnabled(bundle).then((data) => {
	console.info("==========================>isNotificationEnabledCallback=======================>");
});
```



E
ester.zhou 已提交
976
## Notification.isNotificationEnabled
W
wusongqing 已提交
977

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

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

E
ester.zhou 已提交
982
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
983

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

E
ester.zhou 已提交
986
**Parameters**
W
wusongqing 已提交
987

E
ester.zhou 已提交
988 989 990
| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
991

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

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



E
ester.zhou 已提交
1004
## Notification.isNotificationEnabled
W
wusongqing 已提交
1005

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

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

E
ester.zhou 已提交
1010
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1011

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

E
ester.zhou 已提交
1014
**Parameters**
W
wusongqing 已提交
1015

E
ester.zhou 已提交
1016 1017 1018
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1019

E
ester.zhou 已提交
1020 1021 1022 1023 1024
**Return value**

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

E
ester.zhou 已提交
1026
**Example**
W
wusongqing 已提交
1027 1028 1029 1030 1031 1032 1033 1034 1035

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



E
ester.zhou 已提交
1036
## Notification.displayBadge
W
wusongqing 已提交
1037

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

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

E
ester.zhou 已提交
1042
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1043

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

E
ester.zhou 已提交
1046
**Parameters**
W
wusongqing 已提交
1047

E
ester.zhou 已提交
1048 1049 1050 1051 1052
| 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 已提交
1053

E
ester.zhou 已提交
1054
**Example**
W
wusongqing 已提交
1055 1056 1057 1058 1059 1060

```js
function displayBadgeCallback(err) {
	console.info("==========================>displayBadgeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1061
    bundle: "bundleName1",
W
wusongqing 已提交
1062 1063 1064 1065 1066 1067
}
Notification.displayBadge(bundle, false, displayBadgeCallback);
```



E
ester.zhou 已提交
1068
## Notification.displayBadge
W
wusongqing 已提交
1069

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

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

E
ester.zhou 已提交
1074
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1075

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

E
ester.zhou 已提交
1078
**Parameters**
W
wusongqing 已提交
1079

E
ester.zhou 已提交
1080 1081 1082 1083
| 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 已提交
1084

E
ester.zhou 已提交
1085
**Example**
W
wusongqing 已提交
1086 1087 1088

```js
var bundle = {
E
ester.zhou 已提交
1089
    bundle: "bundleName1",
W
wusongqing 已提交
1090
}
E
ester.zhou 已提交
1091
Notification.displayBadge(bundle, false).then(() => {
W
wusongqing 已提交
1092 1093 1094 1095 1096 1097
	console.info("==========================>displayBadgeCallback=======================>");
});
```



E
ester.zhou 已提交
1098
## Notification.isBadgeDisplayed
W
wusongqing 已提交
1099

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

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

E
ester.zhou 已提交
1104
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1105

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

E
ester.zhou 已提交
1108
**Parameters**
W
wusongqing 已提交
1109

E
ester.zhou 已提交
1110 1111 1112 1113
| 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 已提交
1114

E
ester.zhou 已提交
1115
**Example**
W
wusongqing 已提交
1116 1117 1118 1119 1120 1121

```js
function isBadgeDisplayedCallback(err, data) {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1122
    bundle: "bundleName1",
W
wusongqing 已提交
1123 1124 1125 1126 1127 1128
}
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```



E
ester.zhou 已提交
1129 1130 1131
## Notification.isBadgeDisplayed

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

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

E
ester.zhou 已提交
1135
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1136

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

E
ester.zhou 已提交
1139
**Parameters**
W
wusongqing 已提交
1140

E
ester.zhou 已提交
1141 1142 1143
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1144

E
ester.zhou 已提交
1145
**Return value**
W
wusongqing 已提交
1146

E
ester.zhou 已提交
1147 1148 1149
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1150

E
ester.zhou 已提交
1151
**Example**
W
wusongqing 已提交
1152 1153 1154

```js
var bundle = {
E
ester.zhou 已提交
1155
    bundle: "bundleName1",
W
wusongqing 已提交
1156 1157 1158 1159 1160 1161 1162 1163
}
Notification.isBadgeDisplayed(bundle).then((data) => {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
});
```



E
ester.zhou 已提交
1164
## Notification.setSlotByBundle
W
wusongqing 已提交
1165

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

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

E
ester.zhou 已提交
1170
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1171

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

E
ester.zhou 已提交
1174
**Parameters**
W
wusongqing 已提交
1175

E
ester.zhou 已提交
1176 1177 1178 1179 1180
| 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 已提交
1181

E
ester.zhou 已提交
1182
**Example**
W
wusongqing 已提交
1183 1184 1185 1186 1187 1188

```js
function setSlotByBundleCallback(err) {
	console.info("==========================>setSlotByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1189
    bundle: "bundleName1",
W
wusongqing 已提交
1190 1191 1192 1193 1194 1195 1196 1197 1198
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```



E
ester.zhou 已提交
1199
## Notification.setSlotByBundle
W
wusongqing 已提交
1200

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

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

E
ester.zhou 已提交
1205
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1206

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

E
ester.zhou 已提交
1209
**Parameters**
W
wusongqing 已提交
1210

E
ester.zhou 已提交
1211 1212 1213 1214
| 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 已提交
1215

E
ester.zhou 已提交
1216
**Example**
W
wusongqing 已提交
1217 1218 1219

```js
var bundle = {
E
ester.zhou 已提交
1220
    bundle: "bundleName1",
W
wusongqing 已提交
1221 1222 1223 1224
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
1225
Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
W
wusongqing 已提交
1226 1227 1228 1229 1230 1231
	console.info("==========================>setSlotByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1232
## Notification.getSlotsByBundle
W
wusongqing 已提交
1233

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

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

E
ester.zhou 已提交
1238
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1239

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

E
ester.zhou 已提交
1242
**Parameters**
W
wusongqing 已提交
1243

E
ester.zhou 已提交
1244 1245 1246 1247
| 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 已提交
1248

E
ester.zhou 已提交
1249
**Example**
W
wusongqing 已提交
1250 1251 1252 1253 1254 1255

```js
function getSlotsByBundleCallback(err, data) {
	console.info("==========================>getSlotsByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1256
    bundle: "bundleName1",
W
wusongqing 已提交
1257 1258 1259 1260 1261 1262
}
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```



E
ester.zhou 已提交
1263
## Notification.getSlotsByBundle
W
wusongqing 已提交
1264

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

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

E
ester.zhou 已提交
1269
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1270

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

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

E
ester.zhou 已提交
1275 1276 1277
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1278

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

E
ester.zhou 已提交
1281 1282 1283 1284 1285
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1286 1287 1288

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



E
ester.zhou 已提交
1298
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1299

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

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

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

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

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

E
ester.zhou 已提交
1310 1311 1312 1313
| 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 已提交
1314

E
ester.zhou 已提交
1315
**Example**
W
wusongqing 已提交
1316 1317

```js
E
ester.zhou 已提交
1318
function getSlotNumByBundleCallback(err, data) {
W
wusongqing 已提交
1319 1320 1321
	console.info("==========================>getSlotNumByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1322
    bundle: "bundleName1",
W
wusongqing 已提交
1323 1324 1325 1326 1327 1328
}
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
```



E
ester.zhou 已提交
1329
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1330

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

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

E
ester.zhou 已提交
1335
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1336

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

E
ester.zhou 已提交
1339
**Parameters**
W
wusongqing 已提交
1340

E
ester.zhou 已提交
1341 1342 1343
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1344

E
ester.zhou 已提交
1345
**Return value**
W
wusongqing 已提交
1346

E
ester.zhou 已提交
1347 1348 1349 1350 1351
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1352 1353 1354

```js
var bundle = {
E
ester.zhou 已提交
1355
    bundle: "bundleName1",
W
wusongqing 已提交
1356 1357 1358 1359 1360 1361 1362 1363
}
Notification.getSlotNumByBundle(bundle).then((data) => {
	console.info("==========================>getSlotNumByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1364
## Notification.remove
W
wusongqing 已提交
1365

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

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

E
ester.zhou 已提交
1370
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1371

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

E
ester.zhou 已提交
1374
**Parameters**
W
wusongqing 已提交
1375

E
ester.zhou 已提交
1376 1377 1378 1379 1380
| 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 已提交
1381

E
ester.zhou 已提交
1382
**Example**
W
wusongqing 已提交
1383 1384 1385 1386 1387 1388

```js
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1389
    bundle: "bundleName1",
W
wusongqing 已提交
1390 1391
}
var notificationKey = {
E
ester.zhou 已提交
1392 1393
    id: 0,
    label: "label",
W
wusongqing 已提交
1394 1395 1396 1397 1398 1399
}
Notification.remove(bundle, notificationKey, removeCallback);
```



E
ester.zhou 已提交
1400
## Notification.remove
W
wusongqing 已提交
1401

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

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

E
ester.zhou 已提交
1406
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1407

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

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

E
ester.zhou 已提交
1412 1413 1414 1415
| Name           | Readable| Writable| Type           | Mandatory| Description      |
| --------------- | ---- | --- | --------------- | ---- | ---------- |
| bundle          | Yes  | No | [BundleOption](#bundleoption)    | Yes  | Bundle information.|
| notificationKey | Yes  | No | [NotificationKey](#notificationkey) | Yes  | Notification key.  |
W
wusongqing 已提交
1416

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

```js
var bundle = {
E
ester.zhou 已提交
1421
    bundle: "bundleName1",
W
wusongqing 已提交
1422 1423
}
var notificationKey = {
E
ester.zhou 已提交
1424 1425
    id: 0,
    label: "label",
W
wusongqing 已提交
1426
}
E
ester.zhou 已提交
1427
Notification.remove(bundle, notificationKey).then(() => {
W
wusongqing 已提交
1428 1429 1430 1431 1432 1433
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1434
## Notification.remove
W
wusongqing 已提交
1435

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

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

E
ester.zhou 已提交
1440
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1441

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

E
ester.zhou 已提交
1444
**Parameters**
W
wusongqing 已提交
1445

E
ester.zhou 已提交
1446 1447 1448 1449
| 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 已提交
1450

E
ester.zhou 已提交
1451
**Example**
W
wusongqing 已提交
1452 1453

```js
E
ester.zhou 已提交
1454 1455
var hashCode = 'hashCode'

W
wusongqing 已提交
1456 1457 1458 1459 1460 1461 1462 1463 1464
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}

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



E
ester.zhou 已提交
1465
## Notification.remove
W
wusongqing 已提交
1466

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

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

E
ester.zhou 已提交
1471
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1472

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

E
ester.zhou 已提交
1475
**Parameters**
W
wusongqing 已提交
1476

E
ester.zhou 已提交
1477 1478 1479
| Name    | Readable| Writable| Type      | Mandatory| Description      |
| -------- | ---- | --- | ---------- | ---- | ---------- |
| hashCode | Yes  | No | string | Yes  | Unique notification ID.|
W
wusongqing 已提交
1480

E
ester.zhou 已提交
1481
**Example**
W
wusongqing 已提交
1482 1483

```js
E
ester.zhou 已提交
1484 1485
var hashCode = 'hashCode'

E
ester.zhou 已提交
1486
Notification.remove(hashCode).then(() => {
W
wusongqing 已提交
1487 1488 1489 1490 1491 1492
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1493
## Notification.removeAll
W
wusongqing 已提交
1494

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

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

E
ester.zhou 已提交
1499
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1500

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

E
ester.zhou 已提交
1503
**Parameters**
W
wusongqing 已提交
1504

E
ester.zhou 已提交
1505 1506 1507 1508
| 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 已提交
1509

E
ester.zhou 已提交
1510
**Example**
W
wusongqing 已提交
1511 1512 1513 1514 1515 1516

```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1517
    bundle: "bundleName1",
W
wusongqing 已提交
1518 1519 1520 1521 1522 1523
}
Notification.removeAll(bundle, removeAllCallback);
```



E
ester.zhou 已提交
1524
## Notification.removeAll
W
wusongqing 已提交
1525

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

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

E
ester.zhou 已提交
1530
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1531

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

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

E
ester.zhou 已提交
1536 1537 1538
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1539

E
ester.zhou 已提交
1540
**Example**
W
wusongqing 已提交
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551

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

Notification.removeAll(removeAllCallback);
```



E
ester.zhou 已提交
1552
## Notification.removeAll
W
wusongqing 已提交
1553

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

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

E
ester.zhou 已提交
1558
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1559

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

E
ester.zhou 已提交
1562
**Parameters**
W
wusongqing 已提交
1563

E
ester.zhou 已提交
1564 1565 1566
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | No  | Bundle information.|
W
wusongqing 已提交
1567

E
ester.zhou 已提交
1568
**Example**
W
wusongqing 已提交
1569 1570

```js
E
ester.zhou 已提交
1571
Notification.removeAll().then(() => {
W
wusongqing 已提交
1572 1573 1574 1575
	console.info("==========================>removeAllCallback=======================>");
});
```

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

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

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

E
ester.zhou 已提交
1582
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1583

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

E
ester.zhou 已提交
1586
**Parameters**
W
wusongqing 已提交
1587

E
ester.zhou 已提交
1588 1589 1590 1591
| 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 已提交
1592

E
ester.zhou 已提交
1593
**Example**
W
wusongqing 已提交
1594

E
ester.zhou 已提交
1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612
```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

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

E
ester.zhou 已提交
1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
**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 已提交
1635

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

E
ester.zhou 已提交
1638 1639 1640 1641
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

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

E
ester.zhou 已提交
1644 1645 1646 1647 1648 1649 1650
**Parameters**

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

**Example**
W
wusongqing 已提交
1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661

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

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



E
ester.zhou 已提交
1662
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1663

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

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

E
ester.zhou 已提交
1668
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1669

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

E
ester.zhou 已提交
1672
**Return value**
W
wusongqing 已提交
1673

E
ester.zhou 已提交
1674 1675 1676
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1677

E
ester.zhou 已提交
1678
**Example**
W
wusongqing 已提交
1679 1680 1681 1682 1683 1684 1685 1686 1687

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



E
ester.zhou 已提交
1688
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1689

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

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

E
ester.zhou 已提交
1694
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1695

E
ester.zhou 已提交
1696
**Parameters**
W
wusongqing 已提交
1697

E
ester.zhou 已提交
1698 1699 1700
| Name    | Readable| Writable| Type                  | Mandatory| Description                  |
| -------- | ---- | --- | ---------------------- | ---- | ---------------------- |
| callback | Yes  | No | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1701

E
ester.zhou 已提交
1702
**Example**
W
wusongqing 已提交
1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713

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

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



E
ester.zhou 已提交
1714
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1715

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

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

E
ester.zhou 已提交
1720
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1721

E
ester.zhou 已提交
1722
**Return value**
W
wusongqing 已提交
1723

E
ester.zhou 已提交
1724 1725 1726
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1727

E
ester.zhou 已提交
1728
**Example**
W
wusongqing 已提交
1729 1730 1731 1732 1733 1734 1735 1736 1737

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



E
ester.zhou 已提交
1738
## Notification.getActiveNotifications
W
wusongqing 已提交
1739

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

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

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

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

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

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

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

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



E
ester.zhou 已提交
1764
## Notification.getActiveNotifications
W
wusongqing 已提交
1765

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

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

E
ester.zhou 已提交
1770
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1771

E
ester.zhou 已提交
1772
**Return value**
W
wusongqing 已提交
1773

E
ester.zhou 已提交
1774 1775 1776
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1777

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

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



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

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

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

E
ester.zhou 已提交
1794
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1795

E
ester.zhou 已提交
1796
**Parameters**
W
wusongqing 已提交
1797

E
ester.zhou 已提交
1798 1799 1800 1801
| 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 已提交
1802

E
ester.zhou 已提交
1803
**Example**
W
wusongqing 已提交
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816

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

var groupName = "GroupName";

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



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

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

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

E
ester.zhou 已提交
1823
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1824

E
ester.zhou 已提交
1825
**Parameters**
W
wusongqing 已提交
1826

E
ester.zhou 已提交
1827 1828 1829
| Name     | Readable| Writable| Type  | Mandatory| Description          |
| --------- | ---- | --- | ------ | ---- | -------------- |
| groupName | Yes  | No | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
1830

E
ester.zhou 已提交
1831
**Example**
W
wusongqing 已提交
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841

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



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

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

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

E
ester.zhou 已提交
1848
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1849

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

E
ester.zhou 已提交
1852
**Parameters**
W
wusongqing 已提交
1853

E
ester.zhou 已提交
1854 1855 1856 1857 1858
| 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 已提交
1859

E
ester.zhou 已提交
1860
**Example**
W
wusongqing 已提交
1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874

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

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

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



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

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

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

E
ester.zhou 已提交
1881
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1882

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

E
ester.zhou 已提交
1885
**Parameters**
W
wusongqing 已提交
1886

E
ester.zhou 已提交
1887 1888 1889 1890
| 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 已提交
1891

E
ester.zhou 已提交
1892
**Example**
W
wusongqing 已提交
1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903

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



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

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

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

E
ester.zhou 已提交
1910
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1911

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

E
ester.zhou 已提交
1914
**Parameters**
W
wusongqing 已提交
1915

E
ester.zhou 已提交
1916 1917 1918 1919
| 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 已提交
1920

E
ester.zhou 已提交
1921
**Example**
W
wusongqing 已提交
1922 1923 1924 1925 1926 1927 1928

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

var doNotDisturbDate = {
E
ester.zhou 已提交
1929
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
1930 1931 1932 1933 1934 1935 1936 1937 1938
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

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



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

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

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

E
ester.zhou 已提交
1945
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1946

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

E
ester.zhou 已提交
1949
**Parameters**
W
wusongqing 已提交
1950

E
ester.zhou 已提交
1951 1952 1953
| Name| Readable| Writable| Type            | Mandatory| Description          |
| ---- | ---- | --- | ---------------- | ---- | -------------- |
| date | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
1954

E
ester.zhou 已提交
1955
**Example**
W
wusongqing 已提交
1956 1957 1958

```js
var doNotDisturbDate = {
E
ester.zhou 已提交
1959
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
1960 1961 1962 1963 1964 1965 1966 1967 1968
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
	console.info("==========================>setDoNotDisturbDatePromise=======================>");
});
```


E
ester.zhou 已提交
1969 1970 1971 1972 1973 1974 1975 1976
## Notification.setDoNotDisturbDate<sup>8+</sup>

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

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

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

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

E
ester.zhou 已提交
1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013
**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 已提交
2014

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

E
ester.zhou 已提交
2017
**Parameters**
W
wusongqing 已提交
2018

E
ester.zhou 已提交
2019 2020 2021 2022
| 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 已提交
2023

E
ester.zhou 已提交
2024
**Example**
W
wusongqing 已提交
2025

E
ester.zhou 已提交
2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041
```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 已提交
2042

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

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

E
ester.zhou 已提交
2047
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2048

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

E
ester.zhou 已提交
2051 2052 2053 2054 2055 2056 2057
**Parameters**

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

**Example**
W
wusongqing 已提交
2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068

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

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



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

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

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

E
ester.zhou 已提交
2075
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2076

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

E
ester.zhou 已提交
2079
**Return value**
W
wusongqing 已提交
2080

E
ester.zhou 已提交
2081 2082 2083
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2084

E
ester.zhou 已提交
2085
**Example**
W
wusongqing 已提交
2086 2087 2088 2089 2090 2091 2092 2093

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


E
ester.zhou 已提交
2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123
## 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 已提交
2124

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

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

E
ester.zhou 已提交
2129
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2130

E
ester.zhou 已提交
2131
**Parameters**
W
wusongqing 已提交
2132

E
ester.zhou 已提交
2133 2134 2135
| Name    | Readable| Writable| Type                             | Mandatory| Description                  |
| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
| userId   | Yes  | No | number                            | Yes  | User ID.|
W
wusongqing 已提交
2136

E
ester.zhou 已提交
2137
**Return value**
W
wusongqing 已提交
2138

E
ester.zhou 已提交
2139 2140 2141
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2142

E
ester.zhou 已提交
2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161
**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

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

E
ester.zhou 已提交
2164 2165 2166 2167 2168 2169 2170
**Parameters**

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

**Example**
W
wusongqing 已提交
2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181

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

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



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

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

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

E
ester.zhou 已提交
2188
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2189

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

E
ester.zhou 已提交
2192
**Return value**
W
wusongqing 已提交
2193

E
ester.zhou 已提交
2194 2195 2196
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2197

E
ester.zhou 已提交
2198
**Example**
W
wusongqing 已提交
2199 2200 2201 2202 2203 2204 2205 2206 2207

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



E
ester.zhou 已提交
2208
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2209 2210 2211

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

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

E
ester.zhou 已提交
2214
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2215

E
ester.zhou 已提交
2216 2217 2218
**Parameters**

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

E
ester.zhou 已提交
2223
**Example**
W
wusongqing 已提交
2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235

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

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



E
ester.zhou 已提交
2236
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2237 2238 2239

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

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

E
ester.zhou 已提交
2242
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2243

E
ester.zhou 已提交
2244 2245 2246
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2247
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2248
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2249

E
ester.zhou 已提交
2250
**Return value**
W
wusongqing 已提交
2251

E
ester.zhou 已提交
2252
| Type              | Description           |
W
wusongqing 已提交
2253 2254 2255
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2256
**Example**
W
wusongqing 已提交
2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267

```javascript
var templateName = 'process';

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



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

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

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

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

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

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

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

E
ester.zhou 已提交
2284
```javascript
E
ester.zhou 已提交
2285
function requestEnableNotificationCallback() {
E
ester.zhou 已提交
2286 2287 2288
    console.log('------------- requestEnabledNotification --------------');
};

E
ester.zhou 已提交
2289
Notification.requestEnableNotification(requestEnableNotificationCallback);
W
wusongqing 已提交
2290 2291 2292 2293
```



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

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

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

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

E
ester.zhou 已提交
2302
**Example**
W
wusongqing 已提交
2303

E
ester.zhou 已提交
2304 2305 2306 2307 2308 2309
```javascript
Notification.requestEnableNotification()
    .then(() => {
        console.info("requestEnableNotification ");
	});
```
W
wusongqing 已提交
2310 2311


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

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

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

E
ester.zhou 已提交
2318
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2319

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

E
ester.zhou 已提交
2322
**Parameters**
W
wusongqing 已提交
2323

E
ester.zhou 已提交
2324 2325 2326 2327
| 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 已提交
2328

E
ester.zhou 已提交
2329
**Example**
W
wusongqing 已提交
2330

E
ester.zhou 已提交
2331 2332 2333 2334
```javascript
function enabledNotificationCallback() {
    console.log('----------- enableDistributed ------------');
};
W
wusongqing 已提交
2335

E
ester.zhou 已提交
2336
var enable = true
W
wusongqing 已提交
2337

E
ester.zhou 已提交
2338
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2339 2340 2341 2342
```



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

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

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

E
ester.zhou 已提交
2349
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2350

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

E
ester.zhou 已提交
2353
**Parameters**
W
wusongqing 已提交
2354

E
ester.zhou 已提交
2355 2356 2357
| 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 已提交
2358

E
ester.zhou 已提交
2359
**Example**
W
wusongqing 已提交
2360

E
ester.zhou 已提交
2361 2362
```javascript
var enable = true
W
wusongqing 已提交
2363

E
ester.zhou 已提交
2364 2365 2366 2367 2368
Notification.enableDistributed(enable)
    .then(() => {
        console.log('-------- enableDistributed ----------');
    });
```
W
wusongqing 已提交
2369 2370


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

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

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

E
ester.zhou 已提交
2377
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2378

E
ester.zhou 已提交
2379
**Parameters**
W
wusongqing 已提交
2380

E
ester.zhou 已提交
2381 2382 2383
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2384

E
ester.zhou 已提交
2385
**Example**
W
wusongqing 已提交
2386

E
ester.zhou 已提交
2387 2388 2389 2390
```javascript
function isDistributedEnabledCallback() {
    console.log('----------- isDistributedEnabled ------------');
};
W
wusongqing 已提交
2391

E
ester.zhou 已提交
2392
Notification.isDistributedEnabled(isDistributedEnabledCallback);
E
ester.zhou 已提交
2393
```
W
wusongqing 已提交
2394 2395 2396



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

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

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

E
ester.zhou 已提交
2403
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2404

E
ester.zhou 已提交
2405
**Return value**
W
wusongqing 已提交
2406

E
ester.zhou 已提交
2407 2408 2409
| 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 已提交
2410

E
ester.zhou 已提交
2411 2412 2413 2414 2415 2416 2417
**Example**

```javascript
Notification.isDistributedEnabled()
    .then((data) => {
        console.log('-------- isDistributedEnabled ----------');
    });
W
wusongqing 已提交
2418 2419 2420
```


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

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

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

E
ester.zhou 已提交
2427
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2428

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

E
ester.zhou 已提交
2431
**Parameters**
W
wusongqing 已提交
2432

E
ester.zhou 已提交
2433 2434 2435 2436 2437
| 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 已提交
2438

E
ester.zhou 已提交
2439
**Example**
W
wusongqing 已提交
2440

E
ester.zhou 已提交
2441 2442 2443 2444
```javascript
function enableDistributedByBundleCallback() {
    console.log('----------- enableDistributedByBundle ------------');
};
W
wusongqing 已提交
2445

E
ester.zhou 已提交
2446 2447 2448
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2449

E
ester.zhou 已提交
2450
var enable = true
W
wusongqing 已提交
2451

E
ester.zhou 已提交
2452 2453
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2454 2455


E
ester.zhou 已提交
2456 2457 2458

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

E
ester.zhou 已提交
2459
bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
E
ester.zhou 已提交
2460 2461 2462 2463 2464

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

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

E
ester.zhou 已提交
2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478
**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 已提交
2479 2480
}

E
ester.zhou 已提交
2481
var enable = true
W
wusongqing 已提交
2482

E
ester.zhou 已提交
2483 2484 2485 2486
Notification.enableDistributedByBundle(bundle, enable)
    .then(() => {
        console.log('-------- enableDistributedByBundle ----------');
    });
W
wusongqing 已提交
2487 2488
```

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

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

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

E
ester.zhou 已提交
2495
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2496

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

E
ester.zhou 已提交
2499
**Parameters**
W
wusongqing 已提交
2500

E
ester.zhou 已提交
2501 2502 2503 2504
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2505

E
ester.zhou 已提交
2506
**Example**
W
wusongqing 已提交
2507

E
ester.zhou 已提交
2508 2509 2510 2511
```javascript
function isDistributedEnabledByBundleCallback(data) {
    console.log('----------- isDistributedEnabledByBundle ------------', data);
};
W
wusongqing 已提交
2512

E
ester.zhou 已提交
2513 2514 2515
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2516

E
ester.zhou 已提交
2517
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
ester.zhou 已提交
2518
```
W
wusongqing 已提交
2519 2520 2521



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

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

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

E
ester.zhou 已提交
2528 2529
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548
**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 已提交
2549
}
E
ester.zhou 已提交
2550 2551 2552 2553 2554

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


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

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

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

E
ester.zhou 已提交
2564
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2565

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

E
ester.zhou 已提交
2568
**Parameters**
W
wusongqing 已提交
2569

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

E
ester.zhou 已提交
2574
**Example**
W
wusongqing 已提交
2575

E
ester.zhou 已提交
2576 2577 2578 2579
```javascript
function getDeviceRemindTypeCallback(data) {
    console.log('----------- getDeviceRemindType ------------', data);
};
W
wusongqing 已提交
2580

E
ester.zhou 已提交
2581 2582
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2583 2584 2585



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

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

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

E
ester.zhou 已提交
2592 2593
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608
**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 已提交
2609 2610
```

E
ester.zhou 已提交
2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889
## Notification.publishAsBundle<sup>9+</sup>

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

Publishes an agent-powered notification. This API uses an asynchronous callback to return the result.

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

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

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request              | [NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                           |
| userId               | number                                      | Yes  | ID of the user who receives the notification.                           |
| callback             | AsyncCallback                               | Yes  | Callback used to return the result.                     |

**Example**

```js
// Callback for publishAsBundle
function publishAsBundleCallback(err) {
	console.info("==========================>publishAsBundleCallback=======================>");
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100
// NotificationRequest object
let notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback);
```

## Notification.publishAsBundle<sup>9+</sup>

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

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

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

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

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request              | [NotificationRequest](#notificationrequest) | Yes  | Notification to publish.|
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                           |
| userId               | number                                      | Yes  | ID of the user who receives the notification.                           |

**Example**

```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100
// 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.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => {
	console.info("==========================>publishAsBundleCallback=======================>");
});
```

## Notification.cancelAsBundle<sup>9+</sup>

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

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

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

**Parameters**


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

**Example**

```js
//cancelAsBundle
function cancelAsBundleCallback(err) {
	console.info("==========================>cancelAsBundleCallback=======================>");
}
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100

Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
```

## Notification.cancelAsBundle<sup>9+</sup>

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

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

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

**Parameters**


| Name              | Type  | Mandatory| Description              |
| -------------------- | ------ | ---- | ------------------ |
| id                   | number | Yes  | Notification ID.          |
| representativeBundle | string | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.|
| userId               | number | Yes  | ID of the user who receives the notification.|

**Example**

```js
// Bundle name of the application whose notification function is taken over by the reminder agent
let representativeBundle = "com.example.demo"
// ID of the user who receives the notification
let userId = 100

Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
	console.info("==========================>cancelAsBundleCallback=======================>");
});
```

## Notification.enableNotificationSlot<sup>9+</sup>

enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback<void>): void

Sets the enabled status for a notification slot of a specified type. This API uses an asynchronous callback to return the result.

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

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

**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information.          |
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
| enable   | boolean                       | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\>         | Yes  | Callback used to return the result.|

**Example**

```js
//enableNotificationSlot
function enableSlotCallback(err) {
    console.log('===================>enableSlotCallback==================>');
};

Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    true,
    enableSlotCallback);
```

## Notification.enableNotificationSlot<sup>9+</sup>

enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise<void> 

Sets the enabled status for a notification slot of a specified type. This API uses a promise to return the result.

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

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

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.  |
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|
| enable | boolean                       | Yes  | Whether to enable notification.    |

**Example**

```js
//enableNotificationSlot
Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    true).then(() => {
        console.log('====================>enableNotificationSlot====================>');
    });
```

## Notification.isNotificationSlotEnabled<sup>9+</sup>

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback<boolean>): void

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

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

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

**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information.          |
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
| callback | AsyncCallback\<void\>         | Yes  | Callback used to return the result.|

**Example**

```js
//isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
    console.log('===================>getEnableSlotCallback==================');
};

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    getEnableSlotCallback);
```

## Notification.isNotificationSlotEnabled<sup>9+</sup>

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise<boolean>  

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

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

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

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.  |
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|

**Example**

```js
//isNotificationSlotEnabled
Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    true).then((data) => {
      console.log('====================>isNotificationSlotEnabled====================>');
    });
```

E
ester.zhou 已提交
2890 2891
## NotificationSubscriber

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

E
ester.zhou 已提交
2894 2895 2896
### onConsume

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

E
ester.zhou 已提交
2898
Callback for receiving notifications.
W
wusongqing 已提交
2899

E
ester.zhou 已提交
2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917
**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 已提交
2918

E
ester.zhou 已提交
2919 2920 2921 2922 2923 2924 2925
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) => {
E
ester.zhou 已提交
2926
            console.log('===> getWant success want:' + JSON.stringify(data1));
E
ester.zhou 已提交
2927 2928
        })
        .catch((err) => {
E
ester.zhou 已提交
2929
            console.error('===> getWant failed because' + JSON.stringify(err));
E
ester.zhou 已提交
2930
        });
E
ester.zhou 已提交
2931
    console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
E
ester.zhou 已提交
2932
};
W
wusongqing 已提交
2933

E
ester.zhou 已提交
2934 2935 2936
var subscriber = {
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
2937

E
ester.zhou 已提交
2938 2939
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
2940

E
ester.zhou 已提交
2941
### onCancel
W
wusongqing 已提交
2942

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

E
ester.zhou 已提交
2945
Callback for removing notifications.
W
wusongqing 已提交
2946

E
ester.zhou 已提交
2947
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2948

E
ester.zhou 已提交
2949
**Parameters**
W
wusongqing 已提交
2950

E
ester.zhou 已提交
2951 2952 2953
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|
W
wusongqing 已提交
2954

E
ester.zhou 已提交
2955
**Example**
W
wusongqing 已提交
2956

E
ester.zhou 已提交
2957 2958 2959 2960
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
2961
    } else {
E
ester.zhou 已提交
2962
        console.info("subscribeCallback");
W
wusongqing 已提交
2963
    }
E
ester.zhou 已提交
2964 2965 2966 2967 2968 2969
};

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

E
ester.zhou 已提交
2972 2973 2974
var subscriber = {
    onCancel: onCancelCallback
};
W
wusongqing 已提交
2975

E
ester.zhou 已提交
2976
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
2977 2978
```

E
ester.zhou 已提交
2979
### onUpdate
W
wusongqing 已提交
2980

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

E
ester.zhou 已提交
2983
Callback for notification sorting updates.
W
wusongqing 已提交
2984

E
ester.zhou 已提交
2985
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2986

E
ester.zhou 已提交
2987
**Parameters**
W
wusongqing 已提交
2988

E
ester.zhou 已提交
2989 2990 2991
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.|
W
wusongqing 已提交
2992

E
ester.zhou 已提交
2993
**Example**
W
wusongqing 已提交
2994

E
ester.zhou 已提交
2995 2996 2997 2998 2999 3000 3001 3002
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3003

E
ester.zhou 已提交
3004 3005 3006
function onUpdateCallback() {
    console.info('===> onUpdate in test');
}
W
wusongqing 已提交
3007

E
ester.zhou 已提交
3008 3009 3010
var subscriber = {
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
3011

E
ester.zhou 已提交
3012 3013
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3014

E
ester.zhou 已提交
3015
### onConnect
W
wusongqing 已提交
3016

E
ester.zhou 已提交
3017
onConnect?:void
W
wusongqing 已提交
3018

E
ester.zhou 已提交
3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035
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 已提交
3036 3037
}

E
ester.zhou 已提交
3038 3039 3040
var subscriber = {
    onConnect: onConnectCallback
};
W
wusongqing 已提交
3041

E
ester.zhou 已提交
3042
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3043 3044
```

E
ester.zhou 已提交
3045
### onDisconnect
W
wusongqing 已提交
3046

E
ester.zhou 已提交
3047
onDisconnect?:void
W
wusongqing 已提交
3048

E
ester.zhou 已提交
3049
Callback for unsubscription.
W
wusongqing 已提交
3050

E
ester.zhou 已提交
3051
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3052

E
ester.zhou 已提交
3053
**Example**
W
wusongqing 已提交
3054

E
ester.zhou 已提交
3055 3056 3057 3058 3059 3060 3061 3062
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3063

E
ester.zhou 已提交
3064 3065 3066
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
3067

E
ester.zhou 已提交
3068 3069 3070
var subscriber = {
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
3071

E
ester.zhou 已提交
3072 3073
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3074

E
ester.zhou 已提交
3075
### onDestroy
W
wusongqing 已提交
3076

E
ester.zhou 已提交
3077
onDestroy?:void
W
wusongqing 已提交
3078

E
ester.zhou 已提交
3079
Callback for service disconnection.
W
wusongqing 已提交
3080

E
ester.zhou 已提交
3081
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3082

E
ester.zhou 已提交
3083 3084 3085 3086 3087 3088
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3089
    } else {
E
ester.zhou 已提交
3090
        console.info("subscribeCallback");
W
wusongqing 已提交
3091
    }
E
ester.zhou 已提交
3092 3093 3094 3095
};

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

E
ester.zhou 已提交
3098 3099 3100
var subscriber = {
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
3101

E
ester.zhou 已提交
3102
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3103 3104
```

E
ester.zhou 已提交
3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127
### 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 已提交
3128

E
ester.zhou 已提交
3129 3130 3131
function onDoNotDisturbDateChangeCallback() {
    console.info('===> onDoNotDisturbDateChange in test');
}
W
wusongqing 已提交
3132

E
ester.zhou 已提交
3133 3134 3135
var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
W
wusongqing 已提交
3136

E
ester.zhou 已提交
3137 3138
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3139 3140


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

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

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

E
ester.zhou 已提交
3147
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3148

E
ester.zhou 已提交
3149
**Parameters**
W
wusongqing 已提交
3150

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

E
ester.zhou 已提交
3155
**Example**
W
wusongqing 已提交
3156

E
ester.zhou 已提交
3157 3158 3159 3160 3161 3162 3163 3164
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3165

E
ester.zhou 已提交
3166 3167 3168 3169
function onEnabledNotificationChangedCallback(callbackData) {
    console.info("bundle: ", callbackData.bundle);
    console.info("uid: ", callbackData.uid);
    console.info("enable: ", callbackData.enable);
E
ester.zhou 已提交
3170
};
W
wusongqing 已提交
3171

E
ester.zhou 已提交
3172 3173 3174
var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
W
wusongqing 已提交
3175

E
ester.zhou 已提交
3176
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3177 3178
```

E
ester.zhou 已提交
3179
## SubscribeCallbackData
W
wusongqing 已提交
3180

E
ester.zhou 已提交
3181
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3182

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

E
ester.zhou 已提交
3185 3186 3187 3188 3189 3190 3191
| 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 已提交
3192 3193


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

E
ester.zhou 已提交
3196
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3197

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

E
ester.zhou 已提交
3200 3201 3202 3203 3204
| 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 已提交
3205 3206


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

E
ester.zhou 已提交
3209
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3210

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

E
ester.zhou 已提交
3213 3214 3215 3216 3217
| 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 已提交
3218 3219 3220



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

E
ester.zhou 已提交
3223
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3224

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

E
ester.zhou 已提交
3227 3228
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
E
ester.zhou 已提交
3229 3230 3231 3232
| TYPE_NONE    | 0 | Non-DND.                          |
| TYPE_ONCE    | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
| TYPE_DAILY   | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute).    |
W
wusongqing 已提交
3233 3234


E
ester.zhou 已提交
3235
## ContentType
W
wusongqing 已提交
3236

E
ester.zhou 已提交
3237
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3238

E
ester.zhou 已提交
3239 3240
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3241 3242 3243 3244 3245
| NOTIFICATION_CONTENT_BASIC_TEXT   | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification.    |
| NOTIFICATION_CONTENT_LONG_TEXT    | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification.  |
| NOTIFICATION_CONTENT_PICTURE      | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification.    |
| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification.    |
| NOTIFICATION_CONTENT_MULTILINE    | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|
W
wusongqing 已提交
3246

E
ester.zhou 已提交
3247
## SlotLevel
W
wusongqing 已提交
3248

E
ester.zhou 已提交
3249
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3250

E
ester.zhou 已提交
3251 3252
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3253 3254 3255
| LEVEL_NONE                        | 0           | The notification function is disabled.    |
| LEVEL_MIN                         | 1           | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
| LEVEL_LOW                         | 2           | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
E
ester.zhou 已提交
3256 3257
| 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 已提交
3258 3259


E
ester.zhou 已提交
3260
## BundleOption
W
wusongqing 已提交
3261

E
ester.zhou 已提交
3262
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3263

E
ester.zhou 已提交
3264 3265 3266 3267
| Name  | Readable| Writable| Type  | Mandatory| Description  |
| ------ | ---- | --- | ------ | ---- | ------ |
| bundle | Yes | Yes | string | Yes  | Bundle name.  |
| uid    | Yes | Yes | number | No  | User ID.|
W
wusongqing 已提交
3268 3269 3270



E
ester.zhou 已提交
3271
## NotificationKey
W
wusongqing 已提交
3272

E
ester.zhou 已提交
3273
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3274

E
ester.zhou 已提交
3275 3276 3277 3278
| Name | Readable| Writable| Type  | Mandatory| Description    |
| ----- | ---- | --- | ------ | ---- | -------- |
| id    | Yes | Yes | number | Yes  | Notification ID.  |
| label | Yes | Yes | string | No  | Notification label.|
W
wusongqing 已提交
3279 3280


E
ester.zhou 已提交
3281
## SlotType
W
wusongqing 已提交
3282

E
ester.zhou 已提交
3283
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3284

E
ester.zhou 已提交
3285 3286
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
E
ester.zhou 已提交
3287 3288 3289 3290 3291
| UNKNOWN_TYPE         | 0 | Unknown type.|
| SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.|
| SERVICE_INFORMATION  | 2 | Notification slot for service information.|
| CONTENT_INFORMATION  | 3 | Notification slot for content consultation.|
| OTHER_TYPES          | 0xFFFF | Notification slot for other purposes.|
W
wusongqing 已提交
3292 3293


E
ester.zhou 已提交
3294
## NotificationActionButton
W
wusongqing 已提交
3295

E
ester.zhou 已提交
3296
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3297

E
ester.zhou 已提交
3298 3299 3300 3301 3302 3303
| 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 已提交
3304 3305


E
ester.zhou 已提交
3306
## NotificationBasicContent
W
wusongqing 已提交
3307

E
ester.zhou 已提交
3308
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3309

E
ester.zhou 已提交
3310 3311 3312 3313 3314
| 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 已提交
3315 3316


E
ester.zhou 已提交
3317
## NotificationLongTextContent
W
wusongqing 已提交
3318

E
ester.zhou 已提交
3319
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3320

E
ester.zhou 已提交
3321 3322 3323 3324 3325 3326 3327 3328
| 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 已提交
3329 3330


E
ester.zhou 已提交
3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375
## 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

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

E
ester.zhou 已提交
3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425
| 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.             |
E
ester.zhou 已提交
3426
| creatorUserId<sup>8+</sup>| Yes | No | number                                    | No  | ID of the user who creates the notification.          |
E
ester.zhou 已提交
3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466
| 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.                              |
E
ester.zhou 已提交
3467
| enabled<sup>9+</sup> | Yes | No | boolean               | No  | Enabled status of the notification slot.                     |
E
ester.zhou 已提交
3468 3469 3470 3471 3472 3473


## NotificationSorting

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

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

E
ester.zhou 已提交
3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486
| 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

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

E
ester.zhou 已提交
3489 3490 3491 3492 3493 3494 3495 3496 3497 3498
| 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

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

E
ester.zhou 已提交
3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524
| 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 已提交
3525

E
ester.zhou 已提交
3526
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
3527

E
ester.zhou 已提交
3528
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3529

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

E
ester.zhou 已提交
3532 3533 3534 3535 3536 3537
| 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.                |