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

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

Generally, only system applications have the permission to subscribe to and unsubscribe from notifications.

E
ester.zhou 已提交
7
> **NOTE**
E
ester.zhou 已提交
8
>
E
ester.zhou 已提交
9
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
W
wusongqing 已提交
10 11 12 13 14 15 16

## Modules to Import

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

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

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

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

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

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

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

E
ester.zhou 已提交
32
**Example**
W
wusongqing 已提交
33 34 35 36 37 38 39 40 41 42

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



E
ester.zhou 已提交
56
## Notification.publish
W
wusongqing 已提交
57

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

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

E
ester.zhou 已提交
62
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
63

E
ester.zhou 已提交
64 65 66 67 68 69
**Parameters**

| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
| request  | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|

E
ester.zhou 已提交
70
**Example**
W
wusongqing 已提交
71 72 73 74 75 76

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

```

E
ester.zhou 已提交
91 92 93 94 95 96 97 98
## 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 已提交
99 100
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
103 104
**Parameters**

E
ester.zhou 已提交
105 106 107 108 109
| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request  | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
| userId   | number                                      | Yes  | ID of the user who receives the notification.                          |
| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |
E
ester.zhou 已提交
110 111 112 113 114 115 116 117

**Example**

```js
// publish callback
function publishCallback(err) {
	console.info("==========================>publishCallback=======================>");
}
E
ester.zhou 已提交
118
// ID of the user who receives the notification
E
ester.zhou 已提交
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
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 已提交
143 144
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
147 148
**Parameters**

E
ester.zhou 已提交
149 150 151 152
| Name    |  Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request  | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
| userId   | number                                      | Yes  | ID of the user who receives the notification.                          |
E
ester.zhou 已提交
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169

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

E
ester.zhou 已提交
171 172 173 174
Notification.publish(notificationRequest, userId).then(() => {
	console.info("==========================>publishCallback=======================>");
});
```
W
wusongqing 已提交
175 176


E
ester.zhou 已提交
177
## Notification.cancel
W
wusongqing 已提交
178

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

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

E
ester.zhou 已提交
183
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
184

E
ester.zhou 已提交
185
**Parameters**
W
wusongqing 已提交
186

E
ester.zhou 已提交
187 188 189 190 191
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| id       | number                | Yes  | Notification ID.              |
| label    | string                | Yes  | Notification label.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
192

E
ester.zhou 已提交
193
**Example**
W
wusongqing 已提交
194 195 196 197 198 199 200 201 202 203 204

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



E
ester.zhou 已提交
205
## Notification.cancel
W
wusongqing 已提交
206

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

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

E
ester.zhou 已提交
211
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
212

E
ester.zhou 已提交
213
**Parameters**
W
wusongqing 已提交
214

E
ester.zhou 已提交
215 216 217 218
| Name | Type  | Mandatory| Description    |
| ----- | ------ | ---- | -------- |
| id    | number | Yes  | Notification ID.  |
| label | string | No  | Notification label.|
W
wusongqing 已提交
219

E
ester.zhou 已提交
220
**Example**
W
wusongqing 已提交
221 222

```js
E
ester.zhou 已提交
223
Notification.cancel(0).then(() => {
W
wusongqing 已提交
224 225 226 227 228 229
	console.info("==========================>cancelCallback=======================>");
});
```



E
ester.zhou 已提交
230
## Notification.cancel
W
wusongqing 已提交
231

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

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

E
ester.zhou 已提交
236
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
237

E
ester.zhou 已提交
238
**Parameters**
W
wusongqing 已提交
239

E
ester.zhou 已提交
240 241 242 243
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| id       | number                | Yes  | Notification ID.              |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
244

E
ester.zhou 已提交
245
**Example**
W
wusongqing 已提交
246 247 248 249 250 251 252 253 254 255 256

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



E
ester.zhou 已提交
257
## Notification.cancelAll
W
wusongqing 已提交
258

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

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

E
ester.zhou 已提交
263
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
264

E
ester.zhou 已提交
265
**Parameters**
W
wusongqing 已提交
266

E
ester.zhou 已提交
267 268 269
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
270

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

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



E
ester.zhou 已提交
283
## Notification.cancelAll
W
wusongqing 已提交
284

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

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

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

E
ester.zhou 已提交
291
**Example**
W
wusongqing 已提交
292 293

```js
E
ester.zhou 已提交
294 295
Notification.cancelAll().then(() => {
	console.info("==========================>cancelAllCallback=======================>");
W
wusongqing 已提交
296 297 298 299 300
});
```



E
ester.zhou 已提交
301
## Notification.addSlot
W
wusongqing 已提交
302

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

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

E
ester.zhou 已提交
307
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
308

E
ester.zhou 已提交
309 310
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
313
**Parameters**
W
wusongqing 已提交
314

E
ester.zhou 已提交
315 316 317 318
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| slot     | [NotificationSlot](#notificationslot)       | Yes  | Notification slot to add.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
319

E
ester.zhou 已提交
320
**Example**
W
wusongqing 已提交
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335

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

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

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

E
ester.zhou 已提交
342
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
343

E
ester.zhou 已提交
344 345
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
350 351 352
| Name| Type            | Mandatory| Description                |
| ---- | ---------------- | ---- | -------------------- |
| slot | [NotificationSlot](#notificationslot) | Yes  | Notification slot to add.|
W
wusongqing 已提交
353

E
ester.zhou 已提交
354
**Example**
W
wusongqing 已提交
355 356 357 358 359 360

```js
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
361
Notification.addSlot(notificationSlot).then(() => {
W
wusongqing 已提交
362 363 364 365 366 367
	console.info("==========================>addSlotCallback=======================>");
});
```



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

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

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

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

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

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

E
ester.zhou 已提交
383
**Example**
W
wusongqing 已提交
384 385 386 387 388 389 390 391 392 393 394

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



E
ester.zhou 已提交
395
## Notification.addSlot
W
wusongqing 已提交
396

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

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

E
ester.zhou 已提交
401
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
402

E
ester.zhou 已提交
403
**Parameters**
W
wusongqing 已提交
404

E
ester.zhou 已提交
405 406 407
| Name| Type    | Mandatory| Description                  |
| ---- | -------- | ---- | ---------------------- |
| type | [SlotType](#slottype) | Yes  | Type of the notification slot to add.|
W
wusongqing 已提交
408

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

```js
E
ester.zhou 已提交
412
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
W
wusongqing 已提交
413 414 415 416 417 418
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
419
## Notification.addSlots
W
wusongqing 已提交
420

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

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

E
ester.zhou 已提交
425
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
426

E
ester.zhou 已提交
427 428
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
433 434 435 436
| Name    | Type                     | Mandatory| Description                    |
| -------- | ------------------------- | ---- | ------------------------ |
| slots    | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
| callback | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |
W
wusongqing 已提交
437

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

```js
// addSlots callback
function addSlotsCallBack(err) {
	console.info("==========================>addSlotsCallBack=======================>");
}
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
// NotificationSlotArray object
E
ester.zhou 已提交
450 451
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
452 453 454 455 456 457

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



E
ester.zhou 已提交
458
## Notification.addSlots
W
wusongqing 已提交
459

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

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

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

E
ester.zhou 已提交
466 467
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
470
**Parameters**
W
wusongqing 已提交
471

E
ester.zhou 已提交
472 473 474
| Name | Type                     | Mandatory| Description                    |
| ----- | ------------------------- | ---- | ------------------------ |
| slots | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
W
wusongqing 已提交
475

E
ester.zhou 已提交
476
**Example**
W
wusongqing 已提交
477 478 479 480 481 482 483

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

E
ester.zhou 已提交
487
Notification.addSlots(notificationSlotArray).then(() => {
W
wusongqing 已提交
488 489 490 491 492 493
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
494
## Notification.getSlot
W
wusongqing 已提交
495

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

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

E
ester.zhou 已提交
500
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
501

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

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

E
ester.zhou 已提交
509
**Example**
W
wusongqing 已提交
510 511 512 513 514 515 516 517 518 519 520 521

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



E
ester.zhou 已提交
522
## Notification.getSlot
W
wusongqing 已提交
523

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

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

E
ester.zhou 已提交
528
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
529

E
ester.zhou 已提交
530
**Parameters**
W
wusongqing 已提交
531

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

E
ester.zhou 已提交
536
**Return value**
W
wusongqing 已提交
537

E
ester.zhou 已提交
538 539 540 541 542
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
543 544 545 546 547 548 549 550 551 552

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



E
ester.zhou 已提交
553
## Notification.getSlots
W
wusongqing 已提交
554

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

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

E
ester.zhou 已提交
559
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
560

E
ester.zhou 已提交
561
**Parameters**
W
wusongqing 已提交
562

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

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

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



E
ester.zhou 已提交
579
## Notification.getSlots
W
wusongqing 已提交
580

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

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

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

E
ester.zhou 已提交
587
**Return value**
W
wusongqing 已提交
588

E
ester.zhou 已提交
589 590 591
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.|
W
wusongqing 已提交
592

E
ester.zhou 已提交
593
**Example**
W
wusongqing 已提交
594 595 596 597 598 599 600 601 602

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



E
ester.zhou 已提交
603
## Notification.removeSlot
W
wusongqing 已提交
604

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

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

E
ester.zhou 已提交
609
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
610

E
ester.zhou 已提交
611
**Parameters**
W
wusongqing 已提交
612

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

E
ester.zhou 已提交
618
**Example**
W
wusongqing 已提交
619 620 621 622 623 624 625 626 627 628 629 630

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



E
ester.zhou 已提交
631
## Notification.removeSlot
W
wusongqing 已提交
632

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

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

E
ester.zhou 已提交
637
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
638

E
ester.zhou 已提交
639
**Parameters**
W
wusongqing 已提交
640

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

E
ester.zhou 已提交
645
**Example**
W
wusongqing 已提交
646 647 648

```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
649
Notification.removeSlot(slotType).then(() => {
W
wusongqing 已提交
650 651 652 653 654 655
	console.info("==========================>removeSlotCallback=======================>");
});
```



E
ester.zhou 已提交
656
## Notification.removeAllSlots
W
wusongqing 已提交
657

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

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

E
ester.zhou 已提交
662
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
663

E
ester.zhou 已提交
664
**Parameters**
W
wusongqing 已提交
665

E
ester.zhou 已提交
666 667 668
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
669

E
ester.zhou 已提交
670
**Example**
W
wusongqing 已提交
671 672 673 674 675 676 677 678 679 680

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



E
ester.zhou 已提交
681
## Notification.removeAllSlots
W
wusongqing 已提交
682

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

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

E
ester.zhou 已提交
687
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
688

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

```js
E
ester.zhou 已提交
692
Notification.removeAllSlots().then(() => {
W
wusongqing 已提交
693 694 695 696 697 698
	console.info("==========================>removeAllCallBack=======================>");
});
```



E
ester.zhou 已提交
699
## Notification.subscribe
W
wusongqing 已提交
700

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

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

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

E
ester.zhou 已提交
707 708
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
711
**Parameters**
W
wusongqing 已提交
712

E
ester.zhou 已提交
713 714 715 716 717
| Name      | Type                     | Mandatory| Description            |
| ---------- | ------------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.    |
| info       | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes  | Subscription information.        |
| callback   | AsyncCallback\<void\>     | Yes  | Callback used to return the result.|
W
wusongqing 已提交
718

E
ester.zhou 已提交
719
**Example**
W
wusongqing 已提交
720 721 722 723 724 725

```js
// subscribe callback
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
E
ester.zhou 已提交
726
function onConsumeCallback(data) {
W
wusongqing 已提交
727 728 729 730 731 732 733 734 735 736 737 738 739
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
var info = {
    bundleNames: ["bundleName1","bundleName2"]
}
Notification.subscribe(subscriber, info, subscribeCallback);
```



E
ester.zhou 已提交
740
## Notification.subscribe
W
wusongqing 已提交
741

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

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

E
ester.zhou 已提交
746
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
747

E
ester.zhou 已提交
748 749
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
752
**Parameters**
W
wusongqing 已提交
753

E
ester.zhou 已提交
754 755 756 757
| Name      | Type                  | Mandatory| Description            |
| ---------- | ---------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.    |
| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
758

E
ester.zhou 已提交
759
**Example**
W
wusongqing 已提交
760 761 762 763 764

```js
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
E
ester.zhou 已提交
765
function onConsumeCallback(data) {
W
wusongqing 已提交
766 767 768 769 770 771 772 773 774 775
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.subscribe(subscriber, subscribeCallback);
```



E
ester.zhou 已提交
776
## Notification.subscribe
W
wusongqing 已提交
777

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

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

E
ester.zhou 已提交
782
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
783

E
ester.zhou 已提交
784 785
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
788
**Parameters**
W
wusongqing 已提交
789

E
ester.zhou 已提交
790 791 792 793
| Name      | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.|
| info       | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No  | Subscription information.    |
W
wusongqing 已提交
794

E
ester.zhou 已提交
795
**Example**
W
wusongqing 已提交
796 797

```js
E
ester.zhou 已提交
798
function onConsumeCallback(data) {
W
wusongqing 已提交
799 800 801 802 803
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
804
Notification.subscribe(subscriber).then(() => {
W
wusongqing 已提交
805 806 807 808 809 810
	console.info("==========================>subscribeCallback=======================>");
});
```



E
ester.zhou 已提交
811
## Notification.unsubscribe
W
wusongqing 已提交
812

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

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

E
ester.zhou 已提交
817
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
818

E
ester.zhou 已提交
819 820
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
823
**Parameters**
W
wusongqing 已提交
824

E
ester.zhou 已提交
825 826 827 828
| Name      | Type                  | Mandatory| Description                |
| ---------- | ---------------------- | ---- | -------------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.        |
| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
829

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

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



E
ester.zhou 已提交
847
## Notification.unsubscribe
W
wusongqing 已提交
848

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

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

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

E
ester.zhou 已提交
855 856
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
861 862 863
| Name      | Type                  | Mandatory| Description        |
| ---------- | ---------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
W
wusongqing 已提交
864

E
ester.zhou 已提交
865
**Example**
W
wusongqing 已提交
866 867

```js
E
ester.zhou 已提交
868
function onConsumeCallback(data) {
W
wusongqing 已提交
869 870 871 872 873
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
874
Notification.unsubscribe(subscriber).then(() => {
W
wusongqing 已提交
875 876 877 878 879 880
	console.info("==========================>unsubscribeCallback=======================>");
});
```



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

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

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

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

E
ester.zhou 已提交
889 890
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

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

```js
function enableNotificationCallback(err) {
	console.info("==========================>enableNotificationCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
908
    bundle: "bundleName1",
W
wusongqing 已提交
909 910 911 912 913 914
}
Notification.enableNotification(bundle, false, enableNotificationCallback);
```



E
ester.zhou 已提交
915
## Notification.enableNotification
W
wusongqing 已提交
916

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

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

E
ester.zhou 已提交
921
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
922

E
ester.zhou 已提交
923 924
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
929 930 931 932
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| enable | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
933

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

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



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

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

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

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

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

E
ester.zhou 已提交
957 958
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
959
**Parameters**
W
wusongqing 已提交
960

E
ester.zhou 已提交
961 962 963 964
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information.              |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
965

E
ester.zhou 已提交
966
**Example**
W
wusongqing 已提交
967 968 969 970 971 972

```js
function isNotificationEnabledCallback(err, data) {
	console.info("==========================>isNotificationEnabledCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
973
    bundle: "bundleName1",
W
wusongqing 已提交
974 975 976 977 978 979
}
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
```



E
ester.zhou 已提交
980 981 982
## Notification.isNotificationEnabled

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

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

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

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

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

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

E
ester.zhou 已提交
994 995 996
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
997

E
ester.zhou 已提交
998
**Return value**
W
wusongqing 已提交
999

E
ester.zhou 已提交
1000 1001 1002
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1003

E
ester.zhou 已提交
1004
**Example**
W
wusongqing 已提交
1005 1006 1007

```js
var bundle = {
E
ester.zhou 已提交
1008
    bundle: "bundleName1",
W
wusongqing 已提交
1009 1010 1011 1012 1013 1014 1015 1016
}
Notification.isNotificationEnabled(bundle).then((data) => {
	console.info("==========================>isNotificationEnabledCallback=======================>");
});
```



E
ester.zhou 已提交
1017
## Notification.isNotificationEnabled
W
wusongqing 已提交
1018

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

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

E
ester.zhou 已提交
1023
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1024

E
ester.zhou 已提交
1025 1026
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1029
**Parameters**
W
wusongqing 已提交
1030

E
ester.zhou 已提交
1031 1032 1033
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1034

E
ester.zhou 已提交
1035
**Example**
W
wusongqing 已提交
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



E
ester.zhou 已提交
1047
## Notification.isNotificationEnabled
W
wusongqing 已提交
1048

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

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

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

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

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

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

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

E
ester.zhou 已提交
1065 1066 1067 1068 1069
**Return value**

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

E
ester.zhou 已提交
1071
**Example**
W
wusongqing 已提交
1072 1073 1074 1075 1076 1077 1078 1079 1080

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



E
ester.zhou 已提交
1081
## Notification.displayBadge
W
wusongqing 已提交
1082

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

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

E
ester.zhou 已提交
1087
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1088

E
ester.zhou 已提交
1089 1090
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1093
**Parameters**
W
wusongqing 已提交
1094

E
ester.zhou 已提交
1095 1096 1097 1098 1099
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1100

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

```js
function displayBadgeCallback(err) {
	console.info("==========================>displayBadgeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1108
    bundle: "bundleName1",
W
wusongqing 已提交
1109 1110 1111 1112 1113 1114
}
Notification.displayBadge(bundle, false, displayBadgeCallback);
```



E
ester.zhou 已提交
1115
## Notification.displayBadge
W
wusongqing 已提交
1116

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

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

E
ester.zhou 已提交
1121
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1122

E
ester.zhou 已提交
1123 1124
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1127
**Parameters**
W
wusongqing 已提交
1128

E
ester.zhou 已提交
1129 1130 1131 1132
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| enable | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1133

E
ester.zhou 已提交
1134
**Example**
W
wusongqing 已提交
1135 1136 1137

```js
var bundle = {
E
ester.zhou 已提交
1138
    bundle: "bundleName1",
W
wusongqing 已提交
1139
}
E
ester.zhou 已提交
1140
Notification.displayBadge(bundle, false).then(() => {
W
wusongqing 已提交
1141 1142 1143 1144 1145 1146
	console.info("==========================>displayBadgeCallback=======================>");
});
```



E
ester.zhou 已提交
1147
## Notification.isBadgeDisplayed
W
wusongqing 已提交
1148

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

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

E
ester.zhou 已提交
1153
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1154

E
ester.zhou 已提交
1155 1156
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1159
**Parameters**
W
wusongqing 已提交
1160

E
ester.zhou 已提交
1161 1162 1163 1164
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information.              |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1165

E
ester.zhou 已提交
1166
**Example**
W
wusongqing 已提交
1167 1168 1169 1170 1171 1172

```js
function isBadgeDisplayedCallback(err, data) {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1173
    bundle: "bundleName1",
W
wusongqing 已提交
1174 1175 1176 1177 1178 1179
}
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```



E
ester.zhou 已提交
1180 1181 1182
## Notification.isBadgeDisplayed

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

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

E
ester.zhou 已提交
1186
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1187

E
ester.zhou 已提交
1188 1189
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1192
**Parameters**
W
wusongqing 已提交
1193

E
ester.zhou 已提交
1194 1195 1196
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1197

E
ester.zhou 已提交
1198
**Return value**
W
wusongqing 已提交
1199

E
ester.zhou 已提交
1200 1201 1202
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1203

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

```js
var bundle = {
E
ester.zhou 已提交
1208
    bundle: "bundleName1",
W
wusongqing 已提交
1209 1210 1211 1212 1213 1214 1215 1216
}
Notification.isBadgeDisplayed(bundle).then((data) => {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
});
```



E
ester.zhou 已提交
1217
## Notification.setSlotByBundle
W
wusongqing 已提交
1218

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

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

E
ester.zhou 已提交
1223
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1224

E
ester.zhou 已提交
1225 1226
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1231 1232 1233 1234 1235
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| slot     | [NotificationSlot](#notificationslot)      | Yes  | Notification slot.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1236

E
ester.zhou 已提交
1237
**Example**
W
wusongqing 已提交
1238 1239 1240 1241 1242 1243

```js
function setSlotByBundleCallback(err) {
	console.info("==========================>setSlotByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1244
    bundle: "bundleName1",
W
wusongqing 已提交
1245 1246 1247 1248 1249 1250 1251 1252 1253
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```



E
ester.zhou 已提交
1254
## Notification.setSlotByBundle
W
wusongqing 已提交
1255

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

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

E
ester.zhou 已提交
1260
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1261

E
ester.zhou 已提交
1262 1263
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1266
**Parameters**
W
wusongqing 已提交
1267

E
ester.zhou 已提交
1268 1269 1270 1271
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| slot   | [NotificationSlot](#notificationslot) | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1272

E
ester.zhou 已提交
1273
**Example**
W
wusongqing 已提交
1274 1275 1276

```js
var bundle = {
E
ester.zhou 已提交
1277
    bundle: "bundleName1",
W
wusongqing 已提交
1278 1279 1280 1281
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
1282
Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
W
wusongqing 已提交
1283 1284 1285 1286 1287 1288
	console.info("==========================>setSlotByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1289
## Notification.getSlotsByBundle
W
wusongqing 已提交
1290

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

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

E
ester.zhou 已提交
1295
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1296

E
ester.zhou 已提交
1297 1298
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1301
**Parameters**
W
wusongqing 已提交
1302

E
ester.zhou 已提交
1303 1304 1305 1306
| Name    | Type                                    | Mandatory| Description                |
| -------- | ---------------------------------------- | ---- | -------------------- |
| bundle   | [BundleOption](#bundleoption)                             | Yes  | Bundle information.          |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1307

E
ester.zhou 已提交
1308
**Example**
W
wusongqing 已提交
1309 1310 1311 1312 1313 1314

```js
function getSlotsByBundleCallback(err, data) {
	console.info("==========================>getSlotsByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1315
    bundle: "bundleName1",
W
wusongqing 已提交
1316 1317 1318 1319 1320 1321
}
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```



E
ester.zhou 已提交
1322
## Notification.getSlotsByBundle
W
wusongqing 已提交
1323

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

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

E
ester.zhou 已提交
1328
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1329

E
ester.zhou 已提交
1330 1331
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1334
**Parameters**
W
wusongqing 已提交
1335

E
ester.zhou 已提交
1336 1337 1338
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1339

E
ester.zhou 已提交
1340
**Return value**
W
wusongqing 已提交
1341

E
ester.zhou 已提交
1342 1343 1344 1345 1346
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1347 1348 1349

```js
var bundle = {
E
ester.zhou 已提交
1350
    bundle: "bundleName1",
W
wusongqing 已提交
1351 1352 1353 1354 1355 1356 1357 1358
}
Notification.getSlotsByBundle(bundle).then((data) => {
	console.info("==========================>getSlotsByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1359
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1360

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

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

E
ester.zhou 已提交
1365
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1366

E
ester.zhou 已提交
1367 1368
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1371
**Parameters**
W
wusongqing 已提交
1372

E
ester.zhou 已提交
1373 1374 1375 1376
| Name    | Type                     | Mandatory| Description                  |
| -------- | ------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption)              | Yes  | Bundle information.            |
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1377

E
ester.zhou 已提交
1378
**Example**
W
wusongqing 已提交
1379 1380

```js
E
ester.zhou 已提交
1381
function getSlotNumByBundleCallback(err, data) {
W
wusongqing 已提交
1382 1383 1384
	console.info("==========================>getSlotNumByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1385
    bundle: "bundleName1",
W
wusongqing 已提交
1386 1387 1388 1389 1390 1391
}
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
```



E
ester.zhou 已提交
1392
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1393

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

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

E
ester.zhou 已提交
1398
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1399

E
ester.zhou 已提交
1400 1401
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1404
**Parameters**
W
wusongqing 已提交
1405

E
ester.zhou 已提交
1406 1407 1408
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1409

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

E
ester.zhou 已提交
1412 1413 1414 1415 1416
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1417 1418 1419

```js
var bundle = {
E
ester.zhou 已提交
1420
    bundle: "bundleName1",
W
wusongqing 已提交
1421 1422 1423 1424 1425 1426 1427 1428
}
Notification.getSlotNumByBundle(bundle).then((data) => {
	console.info("==========================>getSlotNumByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1429
## Notification.remove
W
wusongqing 已提交
1430

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

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

E
ester.zhou 已提交
1435
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1436

E
ester.zhou 已提交
1437 1438
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1441
**Parameters**
W
wusongqing 已提交
1442

E
ester.zhou 已提交
1443 1444 1445 1446 1447
| Name           | Type                               | Mandatory| Description                |
| --------------- | ----------------------------------- | ---- | -------------------- |
| bundle          | [BundleOption](#bundleoption)       | Yes  | Bundle information.          |
| notificationKey | [NotificationKey](#notificationkey) | Yes  | Notification key.            |
| callback        | AsyncCallback\<void\>               | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1448

E
ester.zhou 已提交
1449
**Example**
W
wusongqing 已提交
1450 1451 1452 1453 1454 1455

```js
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1456
    bundle: "bundleName1",
W
wusongqing 已提交
1457 1458
}
var notificationKey = {
E
ester.zhou 已提交
1459 1460
    id: 0,
    label: "label",
W
wusongqing 已提交
1461 1462 1463 1464 1465 1466
}
Notification.remove(bundle, notificationKey, removeCallback);
```



E
ester.zhou 已提交
1467
## Notification.remove
W
wusongqing 已提交
1468

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

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

E
ester.zhou 已提交
1473
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1474

E
ester.zhou 已提交
1475 1476
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1479
**Parameters**
W
wusongqing 已提交
1480

E
ester.zhou 已提交
1481 1482 1483 1484
| Name           | Type           | Mandatory| Description      |
| --------------- | --------------- | ---- | ---------- |
| bundle          | [BundleOption](#bundleoption)    | Yes  | Bundle information.|
| notificationKey | [NotificationKey](#notificationkey) | Yes  | Notification key.  |
W
wusongqing 已提交
1485

E
ester.zhou 已提交
1486
**Example**
W
wusongqing 已提交
1487 1488 1489

```js
var bundle = {
E
ester.zhou 已提交
1490
    bundle: "bundleName1",
W
wusongqing 已提交
1491 1492
}
var notificationKey = {
E
ester.zhou 已提交
1493 1494
    id: 0,
    label: "label",
W
wusongqing 已提交
1495
}
E
ester.zhou 已提交
1496
Notification.remove(bundle, notificationKey).then(() => {
W
wusongqing 已提交
1497 1498 1499 1500 1501 1502
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1503
## Notification.remove
W
wusongqing 已提交
1504

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

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

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

E
ester.zhou 已提交
1511 1512
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1515
**Parameters**
W
wusongqing 已提交
1516

E
ester.zhou 已提交
1517 1518 1519 1520
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| hashCode | string                | Yes  | Unique notification ID.          |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1521

E
ester.zhou 已提交
1522
**Example**
W
wusongqing 已提交
1523 1524

```js
E
ester.zhou 已提交
1525 1526
var hashCode = 'hashCode'

W
wusongqing 已提交
1527 1528 1529 1530 1531 1532 1533 1534 1535
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}

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



E
ester.zhou 已提交
1536
## Notification.remove
W
wusongqing 已提交
1537

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

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

E
ester.zhou 已提交
1542
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1543

E
ester.zhou 已提交
1544 1545
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1548
**Parameters**
W
wusongqing 已提交
1549

E
ester.zhou 已提交
1550 1551 1552
| Name    | Type      | Mandatory| Description      |
| -------- | ---------- | ---- | ---------- |
| hashCode | string | Yes  | Unique notification ID.|
W
wusongqing 已提交
1553

E
ester.zhou 已提交
1554
**Example**
W
wusongqing 已提交
1555 1556

```js
E
ester.zhou 已提交
1557 1558
var hashCode = 'hashCode'

E
ester.zhou 已提交
1559
Notification.remove(hashCode).then(() => {
W
wusongqing 已提交
1560 1561 1562 1563 1564 1565
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1566
## Notification.removeAll
W
wusongqing 已提交
1567

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

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

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

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

E
ester.zhou 已提交
1576 1577
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1580 1581 1582 1583
| Name    | Type                 | Mandatory| Description                        |
| -------- | --------------------- | ---- | ---------------------------- |
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1584

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

```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1592
    bundle: "bundleName1",
W
wusongqing 已提交
1593 1594 1595 1596 1597 1598
}
Notification.removeAll(bundle, removeAllCallback);
```



E
ester.zhou 已提交
1599
## Notification.removeAll
W
wusongqing 已提交
1600

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

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

E
ester.zhou 已提交
1605
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1606

E
ester.zhou 已提交
1607 1608
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1611
**Parameters**
W
wusongqing 已提交
1612

E
ester.zhou 已提交
1613 1614 1615
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1616

E
ester.zhou 已提交
1617
**Example**
W
wusongqing 已提交
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628

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

Notification.removeAll(removeAllCallback);
```



E
ester.zhou 已提交
1629
## Notification.removeAll
W
wusongqing 已提交
1630

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

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

E
ester.zhou 已提交
1635
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1636

E
ester.zhou 已提交
1637 1638
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1641
**Parameters**
W
wusongqing 已提交
1642

E
ester.zhou 已提交
1643 1644 1645
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | No  | Bundle information.|
W
wusongqing 已提交
1646

E
ester.zhou 已提交
1647
**Example**
W
wusongqing 已提交
1648 1649

```js
E
ester.zhou 已提交
1650
Notification.removeAll().then(() => {
W
wusongqing 已提交
1651 1652 1653 1654
	console.info("==========================>removeAllCallback=======================>");
});
```

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

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

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

E
ester.zhou 已提交
1661
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1662

E
ester.zhou 已提交
1663 1664
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1669 1670 1671 1672
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| userId | number | Yes  | ID of the user who receives the notification.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1673

E
ester.zhou 已提交
1674
**Example**
W
wusongqing 已提交
1675

E
ester.zhou 已提交
1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693
```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 已提交
1694 1695
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1698 1699
**Parameters**

E
ester.zhou 已提交
1700 1701 1702
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| userId | number | Yes  | ID of the user who receives the notification.|
E
ester.zhou 已提交
1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717

**Example**

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

var userId = 1

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


## Notification.getAllActiveNotifications
W
wusongqing 已提交
1718

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

E
ester.zhou 已提交
1721 1722 1723 1724
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

E
ester.zhou 已提交
1725 1726
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1729 1730
**Parameters**

E
ester.zhou 已提交
1731 1732 1733
| Name    | Type                                                        | Mandatory| Description                |
| -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
1734 1735

**Example**
W
wusongqing 已提交
1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746

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

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



E
ester.zhou 已提交
1747
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1748

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

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

E
ester.zhou 已提交
1753
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1754

E
ester.zhou 已提交
1755 1756
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1759
**Return value**
W
wusongqing 已提交
1760

E
ester.zhou 已提交
1761 1762 1763
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1764

E
ester.zhou 已提交
1765
**Example**
W
wusongqing 已提交
1766 1767 1768 1769 1770 1771 1772 1773 1774

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



E
ester.zhou 已提交
1775
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1776

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

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

E
ester.zhou 已提交
1781
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1782

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

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

E
ester.zhou 已提交
1789
**Example**
W
wusongqing 已提交
1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800

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

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



E
ester.zhou 已提交
1801
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1802

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

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

E
ester.zhou 已提交
1807
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1808

E
ester.zhou 已提交
1809
**Return value**
W
wusongqing 已提交
1810

E
ester.zhou 已提交
1811 1812 1813
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1814

E
ester.zhou 已提交
1815
**Example**
W
wusongqing 已提交
1816 1817 1818 1819 1820 1821 1822 1823 1824

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



E
ester.zhou 已提交
1825
## Notification.getActiveNotifications
W
wusongqing 已提交
1826

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

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

E
ester.zhou 已提交
1831
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1832

E
ester.zhou 已提交
1833
**Parameters**
W
wusongqing 已提交
1834

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

E
ester.zhou 已提交
1839
**Example**
W
wusongqing 已提交
1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850

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

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



E
ester.zhou 已提交
1851
## Notification.getActiveNotifications
W
wusongqing 已提交
1852

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

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

E
ester.zhou 已提交
1857
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1858

E
ester.zhou 已提交
1859
**Return value**
W
wusongqing 已提交
1860

E
ester.zhou 已提交
1861 1862 1863
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1864

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

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



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

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

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

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

E
ester.zhou 已提交
1883
**Parameters**
W
wusongqing 已提交
1884

E
ester.zhou 已提交
1885 1886 1887 1888
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
| groupName | string                | Yes  | Name of the notification group.              |
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1889

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

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

var groupName = "GroupName";

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



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

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

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

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

E
ester.zhou 已提交
1912
**Parameters**
W
wusongqing 已提交
1913

E
ester.zhou 已提交
1914 1915 1916
| Name     | Type  | Mandatory| Description          |
| --------- | ------ | ---- | -------------- |
| groupName | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
1917

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

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



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

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

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

E
ester.zhou 已提交
1935
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1936

E
ester.zhou 已提交
1937 1938
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1941
**Parameters**
W
wusongqing 已提交
1942

E
ester.zhou 已提交
1943 1944 1945 1946 1947
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
| bundle    | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
| groupName | string                | Yes  | Name of the notification group.              |
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1948

E
ester.zhou 已提交
1949
**Example**
W
wusongqing 已提交
1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963

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

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

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



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

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

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

E
ester.zhou 已提交
1970
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1971

E
ester.zhou 已提交
1972 1973
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1976
**Parameters**
W
wusongqing 已提交
1977

E
ester.zhou 已提交
1978 1979 1980 1981
| Name     | Type        | Mandatory| Description          |
| --------- | ------------ | ---- | -------------- |
| bundle    | [BundleOption](#bundleoption) | Yes  | Bundle information.    |
| groupName | string       | Yes  | Name of the notification group.|
W
wusongqing 已提交
1982

E
ester.zhou 已提交
1983
**Example**
W
wusongqing 已提交
1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994

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



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

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

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

E
ester.zhou 已提交
2001
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2002

E
ester.zhou 已提交
2003 2004
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2007
**Parameters**
W
wusongqing 已提交
2008

E
ester.zhou 已提交
2009 2010 2011 2012
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2013

E
ester.zhou 已提交
2014
**Example**
W
wusongqing 已提交
2015 2016 2017 2018 2019 2020 2021

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

var doNotDisturbDate = {
E
ester.zhou 已提交
2022
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2023 2024 2025 2026 2027 2028 2029 2030 2031
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

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



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

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

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

E
ester.zhou 已提交
2038
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2039

E
ester.zhou 已提交
2040 2041
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
2046 2047 2048
| Name| Type            | Mandatory| Description          |
| ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
2049

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

```js
var doNotDisturbDate = {
E
ester.zhou 已提交
2054
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2055 2056 2057 2058 2059 2060 2061 2062 2063
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
	console.info("==========================>setDoNotDisturbDatePromise=======================>");
});
```


E
ester.zhou 已提交
2064 2065 2066 2067 2068 2069 2070 2071
## 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 已提交
2072 2073
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2076 2077
**Parameters**

E
ester.zhou 已提交
2078 2079 2080 2081 2082
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| userId   | number                | Yes  | User ID.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110

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

E
ester.zhou 已提交
2112 2113
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2116
**Parameters**
W
wusongqing 已提交
2117

E
ester.zhou 已提交
2118 2119 2120 2121
| Name  | Type            | Mandatory| Description          |
| ------ | ---------------- | ---- | -------------- |
| date   | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
| userId | number           | Yes  | User ID.|
W
wusongqing 已提交
2122

E
ester.zhou 已提交
2123
**Example**
W
wusongqing 已提交
2124

E
ester.zhou 已提交
2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140
```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 已提交
2141

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

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

E
ester.zhou 已提交
2146
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2147

E
ester.zhou 已提交
2148 2149
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2152 2153
**Parameters**

E
ester.zhou 已提交
2154 2155 2156
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2157 2158

**Example**
W
wusongqing 已提交
2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169

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

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



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

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

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

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

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

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

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

E
ester.zhou 已提交
2184 2185 2186
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2187

E
ester.zhou 已提交
2188
**Example**
W
wusongqing 已提交
2189 2190 2191 2192 2193 2194 2195 2196

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


E
ester.zhou 已提交
2197 2198 2199 2200 2201 2202 2203 2204
## Notification.getDoNotDisturbDate<sup>8+</sup>

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

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

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

E
ester.zhou 已提交
2205 2206 2207 2208
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2209 2210
**Parameters**

E
ester.zhou 已提交
2211 2212 2213 2214
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
| userId   | number                            | Yes  | User ID.|
E
ester.zhou 已提交
2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230

**Example**

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

var userId = 1

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



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

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

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

E
ester.zhou 已提交
2236
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2237

E
ester.zhou 已提交
2238 2239 2240 2241
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2242
**Parameters**
W
wusongqing 已提交
2243

E
ester.zhou 已提交
2244 2245 2246
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| userId   | number                            | Yes  | User ID.|
W
wusongqing 已提交
2247

E
ester.zhou 已提交
2248
**Return value**
W
wusongqing 已提交
2249

E
ester.zhou 已提交
2250 2251 2252
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2253

E
ester.zhou 已提交
2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272
**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 已提交
2273 2274
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2277 2278
**Parameters**

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

**Example**
W
wusongqing 已提交
2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294

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

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



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

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

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

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

E
ester.zhou 已提交
2303 2304
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2307
**Return value**
W
wusongqing 已提交
2308

E
ester.zhou 已提交
2309 2310 2311
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2312

E
ester.zhou 已提交
2313
**Example**
W
wusongqing 已提交
2314 2315 2316 2317 2318 2319 2320 2321 2322

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



E
ester.zhou 已提交
2323
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2324 2325 2326

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

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

E
ester.zhou 已提交
2329
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2330

E
ester.zhou 已提交
2331 2332 2333
**Parameters**

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

E
ester.zhou 已提交
2338
**Example**
W
wusongqing 已提交
2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350

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

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



E
ester.zhou 已提交
2351
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2352 2353 2354

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

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

E
ester.zhou 已提交
2357
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2358

E
ester.zhou 已提交
2359 2360 2361
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2362
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2363
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2364

E
ester.zhou 已提交
2365
**Return value**
W
wusongqing 已提交
2366

E
ester.zhou 已提交
2367
| Type              | Description           |
W
wusongqing 已提交
2368 2369 2370
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2371
**Example**
W
wusongqing 已提交
2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382

```javascript
var templateName = 'process';

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



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

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

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

E
ester.zhou 已提交
2389
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2390

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

E
ester.zhou 已提交
2393 2394 2395
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2396

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

E
ester.zhou 已提交
2399
```javascript
E
ester.zhou 已提交
2400
function requestEnableNotificationCallback() {
E
ester.zhou 已提交
2401 2402 2403
    console.log('------------- requestEnabledNotification --------------');
};

E
ester.zhou 已提交
2404
Notification.requestEnableNotification(requestEnableNotificationCallback);
W
wusongqing 已提交
2405 2406 2407 2408
```



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

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

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

E
ester.zhou 已提交
2415
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2416

E
ester.zhou 已提交
2417
**Example**
W
wusongqing 已提交
2418

E
ester.zhou 已提交
2419 2420 2421 2422 2423 2424
```javascript
Notification.requestEnableNotification()
    .then(() => {
        console.info("requestEnableNotification ");
	});
```
W
wusongqing 已提交
2425 2426


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

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

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

E
ester.zhou 已提交
2433
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2434

E
ester.zhou 已提交
2435 2436
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
2441 2442 2443 2444
| 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 已提交
2445

E
ester.zhou 已提交
2446
**Example**
W
wusongqing 已提交
2447

E
ester.zhou 已提交
2448 2449 2450 2451
```javascript
function enabledNotificationCallback() {
    console.log('----------- enableDistributed ------------');
};
W
wusongqing 已提交
2452

E
ester.zhou 已提交
2453
var enable = true
W
wusongqing 已提交
2454

E
ester.zhou 已提交
2455
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2456 2457 2458 2459
```



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

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

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

E
ester.zhou 已提交
2466
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2467

E
ester.zhou 已提交
2468 2469
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2472
**Parameters**
W
wusongqing 已提交
2473

E
ester.zhou 已提交
2474 2475 2476
| 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 已提交
2477

E
ester.zhou 已提交
2478
**Example**
W
wusongqing 已提交
2479

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

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


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

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

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

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

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

E
ester.zhou 已提交
2500 2501 2502
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2503

E
ester.zhou 已提交
2504
**Example**
W
wusongqing 已提交
2505

E
ester.zhou 已提交
2506 2507 2508 2509
```javascript
function isDistributedEnabledCallback() {
    console.log('----------- isDistributedEnabled ------------');
};
W
wusongqing 已提交
2510

E
ester.zhou 已提交
2511
Notification.isDistributedEnabled(isDistributedEnabledCallback);
E
ester.zhou 已提交
2512
```
W
wusongqing 已提交
2513 2514 2515



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

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

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

E
ester.zhou 已提交
2522
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2523

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

E
ester.zhou 已提交
2526 2527 2528
| 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 已提交
2529

E
ester.zhou 已提交
2530 2531 2532 2533 2534 2535 2536
**Example**

```javascript
Notification.isDistributedEnabled()
    .then((data) => {
        console.log('-------- isDistributedEnabled ----------');
    });
W
wusongqing 已提交
2537 2538 2539
```


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

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

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

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

E
ester.zhou 已提交
2548 2549
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
2554 2555 2556 2557 2558
| 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 已提交
2559

E
ester.zhou 已提交
2560
**Example**
W
wusongqing 已提交
2561

E
ester.zhou 已提交
2562 2563 2564 2565
```javascript
function enableDistributedByBundleCallback() {
    console.log('----------- enableDistributedByBundle ------------');
};
W
wusongqing 已提交
2566

E
ester.zhou 已提交
2567 2568 2569
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2570

E
ester.zhou 已提交
2571
var enable = true
W
wusongqing 已提交
2572

E
ester.zhou 已提交
2573 2574
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2575 2576


E
ester.zhou 已提交
2577 2578 2579

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

E
ester.zhou 已提交
2580
enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
E
ester.zhou 已提交
2581 2582 2583 2584 2585

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 已提交
2586 2587
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601
**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 已提交
2602 2603
}

E
ester.zhou 已提交
2604
var enable = true
W
wusongqing 已提交
2605

E
ester.zhou 已提交
2606 2607 2608 2609
Notification.enableDistributedByBundle(bundle, enable)
    .then(() => {
        console.log('-------- enableDistributedByBundle ----------');
    });
W
wusongqing 已提交
2610 2611
```

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

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

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

E
ester.zhou 已提交
2618
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2619

E
ester.zhou 已提交
2620 2621
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2624
**Parameters**
W
wusongqing 已提交
2625

E
ester.zhou 已提交
2626 2627 2628 2629
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2630

E
ester.zhou 已提交
2631
**Example**
W
wusongqing 已提交
2632

E
ester.zhou 已提交
2633 2634 2635 2636
```javascript
function isDistributedEnabledByBundleCallback(data) {
    console.log('----------- isDistributedEnabledByBundle ------------', data);
};
W
wusongqing 已提交
2637

E
ester.zhou 已提交
2638 2639 2640
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2641

E
ester.zhou 已提交
2642
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
ester.zhou 已提交
2643
```
W
wusongqing 已提交
2644 2645 2646



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

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

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

E
ester.zhou 已提交
2653 2654
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2655 2656
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675
**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 已提交
2676
}
E
ester.zhou 已提交
2677 2678 2679 2680 2681

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


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

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

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

E
ester.zhou 已提交
2691
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2692

E
ester.zhou 已提交
2693 2694
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2697
**Parameters**
W
wusongqing 已提交
2698

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

E
ester.zhou 已提交
2703
**Example**
W
wusongqing 已提交
2704

E
ester.zhou 已提交
2705 2706 2707 2708
```javascript
function getDeviceRemindTypeCallback(data) {
    console.log('----------- getDeviceRemindType ------------', data);
};
W
wusongqing 已提交
2709

E
ester.zhou 已提交
2710 2711
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2712 2713 2714



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

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

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

E
ester.zhou 已提交
2721 2722
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2723 2724
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739
**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 已提交
2740 2741
```

E
ester.zhou 已提交
2742

E
ester.zhou 已提交
2743 2744 2745 2746 2747 2748 2749 2750
## Notification.publishAsBundle<sup>9+</sup>

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

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

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

E
ester.zhou 已提交
2751 2752
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

**Parameters**

| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
2759
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
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
| 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

E
ester.zhou 已提交
2799 2800
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2801 2802 2803 2804 2805 2806 2807
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
2808
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
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
| 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

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

E
ester.zhou 已提交
2847 2848
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

E
ester.zhou 已提交
2851
**Parameters**
E
ester.zhou 已提交
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

| 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

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

E
ester.zhou 已提交
2885 2886
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

E
ester.zhou 已提交
2889
**Parameters**
E
ester.zhou 已提交
2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909

| 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=======================>");
});
```

E
ester.zhou 已提交
2910
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
2911

E
ester.zhou 已提交
2912
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
2913 2914 2915 2916 2917 2918 2919

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.

E
ester.zhou 已提交
2920 2921
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940
**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", },
E
ester.zhou 已提交
2941
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
2942 2943 2944 2945
    true,
    enableSlotCallback);
```

E
ester.zhou 已提交
2946
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
2947

E
ester.zhou 已提交
2948
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> 
E
ester.zhou 已提交
2949 2950 2951 2952 2953 2954 2955

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.

E
ester.zhou 已提交
2956 2957
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971
**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", },
E
ester.zhou 已提交
2972
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
2973 2974 2975 2976 2977
    true).then(() => {
        console.log('====================>enableNotificationSlot====================>');
    });
```

E
ester.zhou 已提交
2978
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
2979

E
ester.zhou 已提交
2980
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
E
ester.zhou 已提交
2981

E
ester.zhou 已提交
2982
Obtains the enabled status of the notification slot of a specified type. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
2983 2984 2985 2986 2987

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

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

E
ester.zhou 已提交
2988 2989
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2990 2991 2992 2993 2994 2995
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information.          |
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
2996
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007

**Example**

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

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3008
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3009 3010 3011
    getEnableSlotCallback);
```

E
ester.zhou 已提交
3012
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3013

E
ester.zhou 已提交
3014
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>  
E
ester.zhou 已提交
3015

E
ester.zhou 已提交
3016
Obtains the enabled status of the notification slot of a specified type. This API uses a promise to return the result.
E
ester.zhou 已提交
3017 3018 3019 3020 3021

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

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

E
ester.zhou 已提交
3022 3023
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3024 3025 3026 3027 3028 3029 3030
**Parameters**

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

E
ester.zhou 已提交
3031 3032 3033 3034 3035 3036
**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the enabled status of the notification slot of the specified type.|

E
ester.zhou 已提交
3037 3038 3039 3040 3041 3042
**Example**

```js
//isNotificationSlotEnabled
Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3043 3044
    Notification.SlotType.SOCIAL_COMMUNICATION
    ).then((data) => {
E
ester.zhou 已提交
3045 3046 3047 3048
      console.log('====================>isNotificationSlotEnabled====================>');
    });
```

E
ester.zhou 已提交
3049

E
ester.zhou 已提交
3050
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3051

E
ester.zhou 已提交
3052
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
E
ester.zhou 已提交
3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066

Sets whether to sync notifications to devices where the application is not installed. This API uses an asynchronous callback to return the result.

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
E
ester.zhou 已提交
3067 3068
| enable | boolean | Yes  | Whether the feature is enabled.<br>**true**: enabled<br>**false**: disabled  |
| callback | AsyncCallback\<void\>    | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3069 3070 3071 3072 3073 3074 3075

**Example**

```js
let userId = 100;
let enable = true;

E
ester.zhou 已提交
3076 3077
function setSyncNotificationEnabledWithoutAppCallback(err) {
    console.log('setSyncNotificationEnabledWithoutAppCallback');
E
ester.zhou 已提交
3078 3079
}

E
ester.zhou 已提交
3080
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3081 3082 3083
```


E
ester.zhou 已提交
3084
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3085

E
ester.zhou 已提交
3086
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
E
ester.zhou 已提交
3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100

Sets whether to sync notifications to devices where the application is not installed. This API uses a promise to return the result.

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
E
ester.zhou 已提交
3101 3102 3103 3104 3105 3106 3107
| enable | boolean | Yes  | Whether the feature is enabled.<br>**true**: enabled<br>**false**: disabled  |

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|
E
ester.zhou 已提交
3108 3109 3110 3111 3112 3113 3114

**Example**

```js
let userId = 100;
let enable = true;

E
ester.zhou 已提交
3115
Notification.setSyncNotificationEnabledWithoutApp(userId, enable)
E
ester.zhou 已提交
3116
    .then((data) => {
E
ester.zhou 已提交
3117
        console.log('setSyncNotificationEnabledWithoutApp');
E
ester.zhou 已提交
3118 3119
    })
    .catch((err) => {
E
ester.zhou 已提交
3120
        console.log('setSyncNotificationEnabledWithoutApp, err:', err);
E
ester.zhou 已提交
3121 3122 3123 3124
    });
```


E
ester.zhou 已提交
3125
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3126

E
ester.zhou 已提交
3127
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
E
ester.zhou 已提交
3128

E
ester.zhou 已提交
3129
Obtains whether notifications are synced to devices where the application is not installed. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
E
ester.zhou 已提交
3142
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.<br>**true**: Notifications are synced to devices where the application is not installed.<br>**false**: Notifications are not synced to devices where the application is not installed.|
E
ester.zhou 已提交
3143 3144 3145 3146 3147 3148

**Example**

```js
let userId = 100;

E
ester.zhou 已提交
3149 3150 3151 3152 3153 3154
function getSyncNotificationEnabledWithoutAppCallback(data, err) {
    if (err) {
        console.log('getSyncNotificationEnabledWithoutAppCallback, err' + err);
    } else {
        console.log('getSyncNotificationEnabledWithoutAppCallback, data' + data);
    }
E
ester.zhou 已提交
3155 3156
}

E
ester.zhou 已提交
3157
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3158 3159 3160
```


E
ester.zhou 已提交
3161
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3162

E
ester.zhou 已提交
3163
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
E
ester.zhou 已提交
3164

E
ester.zhou 已提交
3165
Obtains whether notifications are synced to devices where the application is not installed. This API uses a promise to return the result.
E
ester.zhou 已提交
3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
E
ester.zhou 已提交
3183
| Promise\<boolean\> | Promise used to return the result.<br>**true**: Notifications are synced to devices where the application is not installed.<br>**false**: Notifications are not synced to devices where the application is not installed.|
E
ester.zhou 已提交
3184 3185 3186 3187 3188 3189

**Example**

```js
let userId = 100;

E
ester.zhou 已提交
3190
Notification.getSyncNotificationEnabledWithoutApp(userId)
E
ester.zhou 已提交
3191
    .then((data) => {
E
ester.zhou 已提交
3192
        console.log('getSyncNotificationEnabledWithoutApp, data:', data);
E
ester.zhou 已提交
3193 3194
    })
    .catch((err) => {
E
ester.zhou 已提交
3195
        console.log('getSyncNotificationEnabledWithoutApp, err:', err);
E
ester.zhou 已提交
3196 3197 3198 3199 3200
    });
```



E
ester.zhou 已提交
3201 3202
## NotificationSubscriber

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

E
ester.zhou 已提交
3205 3206
### onConsume

E
ester.zhou 已提交
3207
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3208

E
ester.zhou 已提交
3209
Callback for receiving notifications.
W
wusongqing 已提交
3210

E
ester.zhou 已提交
3211 3212
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230
**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 已提交
3231

E
ester.zhou 已提交
3232 3233 3234 3235 3236 3237 3238
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 已提交
3239
            console.log('===> getWant success want:' + JSON.stringify(data1));
E
ester.zhou 已提交
3240 3241
        })
        .catch((err) => {
E
ester.zhou 已提交
3242
            console.error('===> getWant failed because' + JSON.stringify(err));
E
ester.zhou 已提交
3243
        });
E
ester.zhou 已提交
3244
    console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
E
ester.zhou 已提交
3245
};
W
wusongqing 已提交
3246

E
ester.zhou 已提交
3247 3248 3249
var subscriber = {
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
3250

E
ester.zhou 已提交
3251 3252
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3253

E
ester.zhou 已提交
3254
### onCancel
W
wusongqing 已提交
3255

E
ester.zhou 已提交
3256
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3257

E
ester.zhou 已提交
3258
Callback for removing notifications.
W
wusongqing 已提交
3259

E
ester.zhou 已提交
3260
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3261

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

E
ester.zhou 已提交
3264
**Parameters**
W
wusongqing 已提交
3265

E
ester.zhou 已提交
3266 3267 3268
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|
W
wusongqing 已提交
3269

E
ester.zhou 已提交
3270
**Example**
W
wusongqing 已提交
3271

E
ester.zhou 已提交
3272 3273 3274 3275
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3276
    } else {
E
ester.zhou 已提交
3277
        console.info("subscribeCallback");
W
wusongqing 已提交
3278
    }
E
ester.zhou 已提交
3279 3280 3281 3282 3283 3284
};

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

E
ester.zhou 已提交
3287 3288 3289
var subscriber = {
    onCancel: onCancelCallback
};
W
wusongqing 已提交
3290

E
ester.zhou 已提交
3291
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3292 3293
```

E
ester.zhou 已提交
3294
### onUpdate
W
wusongqing 已提交
3295

E
ester.zhou 已提交
3296
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
W
wusongqing 已提交
3297

E
ester.zhou 已提交
3298
Callback for notification sorting updates.
W
wusongqing 已提交
3299

E
ester.zhou 已提交
3300
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3301

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

E
ester.zhou 已提交
3304
**Parameters**
W
wusongqing 已提交
3305

E
ester.zhou 已提交
3306 3307 3308
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.|
W
wusongqing 已提交
3309

E
ester.zhou 已提交
3310
**Example**
W
wusongqing 已提交
3311

E
ester.zhou 已提交
3312 3313 3314 3315 3316 3317 3318 3319
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3320

E
ester.zhou 已提交
3321 3322 3323
function onUpdateCallback() {
    console.info('===> onUpdate in test');
}
W
wusongqing 已提交
3324

E
ester.zhou 已提交
3325 3326 3327
var subscriber = {
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
3328

E
ester.zhou 已提交
3329 3330
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3331

E
ester.zhou 已提交
3332
### onConnect
W
wusongqing 已提交
3333

E
ester.zhou 已提交
3334
onConnect?:() => void
W
wusongqing 已提交
3335

E
ester.zhou 已提交
3336 3337 3338 3339
Callback for subscription.

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

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

E
ester.zhou 已提交
3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354
**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 已提交
3355 3356
}

E
ester.zhou 已提交
3357 3358 3359
var subscriber = {
    onConnect: onConnectCallback
};
W
wusongqing 已提交
3360

E
ester.zhou 已提交
3361
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3362 3363
```

E
ester.zhou 已提交
3364
### onDisconnect
W
wusongqing 已提交
3365

E
ester.zhou 已提交
3366
onDisconnect?:() => void
W
wusongqing 已提交
3367

E
ester.zhou 已提交
3368
Callback for unsubscription.
W
wusongqing 已提交
3369

E
ester.zhou 已提交
3370
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3371

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

E
ester.zhou 已提交
3374
**Example**
W
wusongqing 已提交
3375

E
ester.zhou 已提交
3376 3377 3378 3379 3380 3381 3382 3383
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3384

E
ester.zhou 已提交
3385 3386 3387
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
3388

E
ester.zhou 已提交
3389 3390 3391
var subscriber = {
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
3392

E
ester.zhou 已提交
3393 3394
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3395

E
ester.zhou 已提交
3396
### onDestroy
W
wusongqing 已提交
3397

E
ester.zhou 已提交
3398
onDestroy?:() => void
W
wusongqing 已提交
3399

E
ester.zhou 已提交
3400
Callback for service disconnection.
W
wusongqing 已提交
3401

E
ester.zhou 已提交
3402
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3403

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

E
ester.zhou 已提交
3406 3407 3408 3409 3410 3411
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3412
    } else {
E
ester.zhou 已提交
3413
        console.info("subscribeCallback");
W
wusongqing 已提交
3414
    }
E
ester.zhou 已提交
3415 3416 3417 3418
};

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

E
ester.zhou 已提交
3421 3422 3423
var subscriber = {
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
3424

E
ester.zhou 已提交
3425
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3426 3427
```

E
ester.zhou 已提交
3428 3429
### onDoNotDisturbDateChange<sup>8+</sup>

E
ester.zhou 已提交
3430
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
E
ester.zhou 已提交
3431 3432 3433 3434 3435

Callback for DND time setting updates.

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

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

E
ester.zhou 已提交
3438 3439 3440 3441
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3442
| mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
E
ester.zhou 已提交
3443 3444 3445 3446 3447 3448 3449 3450 3451 3452

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

E
ester.zhou 已提交
3454 3455 3456
function onDoNotDisturbDateChangeCallback() {
    console.info('===> onDoNotDisturbDateChange in test');
}
W
wusongqing 已提交
3457

E
ester.zhou 已提交
3458 3459 3460
var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
W
wusongqing 已提交
3461

E
ester.zhou 已提交
3462 3463
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3464 3465


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

E
ester.zhou 已提交
3468
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) => void
W
wusongqing 已提交
3469

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

E
ester.zhou 已提交
3472
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3473

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

E
ester.zhou 已提交
3476
**Parameters**
W
wusongqing 已提交
3477

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

E
ester.zhou 已提交
3482
**Example**
W
wusongqing 已提交
3483

E
ester.zhou 已提交
3484 3485 3486 3487 3488 3489 3490 3491
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3492

E
ester.zhou 已提交
3493 3494 3495 3496
function onEnabledNotificationChangedCallback(callbackData) {
    console.info("bundle: ", callbackData.bundle);
    console.info("uid: ", callbackData.uid);
    console.info("enable: ", callbackData.enable);
E
ester.zhou 已提交
3497
};
W
wusongqing 已提交
3498

E
ester.zhou 已提交
3499 3500 3501
var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
W
wusongqing 已提交
3502

E
ester.zhou 已提交
3503
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3504 3505
```

E
ester.zhou 已提交
3506
## SubscribeCallbackData
W
wusongqing 已提交
3507

E
ester.zhou 已提交
3508
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3509

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

E
ester.zhou 已提交
3512 3513 3514 3515 3516 3517 3518
| Name           | Readable| Writable| Type                                             | Description    |
| --------------- | ---- | --- | ------------------------------------------------- | -------- |
| request         | Yes | No | [NotificationRequest](#notificationrequest)       | Notification content.|
| sortingMap      | Yes | No | [NotificationSortingMap](#notificationsortingmap) | Notification sorting information.|
| reason          | Yes | No | number                                            | Reason for deletion.|
| sound           | Yes | No | string                                            | Sound used for notification.|
| vibrationValues | Yes | No | Array\<number\>                                   | Vibration used for notification.|
W
wusongqing 已提交
3519 3520


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

E
ester.zhou 已提交
3523
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3524

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

E
ester.zhou 已提交
3527 3528 3529 3530 3531
| Name  | Readable| Writable| Type   | Description            |
| ------ | ---- | --- | ------- | ---------------- |
| bundle | Yes | No | string  | Bundle name of the application.      |
| uid    | Yes | No | number  | UID of the application.       |
| enable | Yes | No | boolean | Notification enabled status of the application.|
W
wusongqing 已提交
3532 3533


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

E
ester.zhou 已提交
3536
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3537

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

E
ester.zhou 已提交
3540 3541 3542 3543 3544
| 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 已提交
3545 3546 3547



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

E
ester.zhou 已提交
3550
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3551

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

E
ester.zhou 已提交
3554 3555
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
E
ester.zhou 已提交
3556 3557 3558 3559
| 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 已提交
3560 3561


E
ester.zhou 已提交
3562
## ContentType
W
wusongqing 已提交
3563

E
ester.zhou 已提交
3564
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3565

E
ester.zhou 已提交
3566 3567
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3568 3569 3570 3571 3572
| 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 已提交
3573

E
ester.zhou 已提交
3574
## SlotLevel
W
wusongqing 已提交
3575

E
ester.zhou 已提交
3576
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3577

E
ester.zhou 已提交
3578 3579
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3580 3581 3582
| 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 已提交
3583 3584
| 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 已提交
3585 3586


E
ester.zhou 已提交
3587
## BundleOption
W
wusongqing 已提交
3588

E
ester.zhou 已提交
3589
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3590

E
ester.zhou 已提交
3591 3592 3593 3594
| Name  | Readable| Writable| Type  | Description  |
| ------ | ---- | --- | ------ | ------ |
| bundle | Yes | Yes | string | Bundle name.  |
| uid    | Yes | Yes | number | User ID.|
W
wusongqing 已提交
3595 3596 3597



E
ester.zhou 已提交
3598
## NotificationKey
W
wusongqing 已提交
3599

E
ester.zhou 已提交
3600
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3601

E
ester.zhou 已提交
3602 3603 3604 3605
| Name | Readable| Writable| Type  | Description    |
| ----- | ---- | --- | ------ | -------- |
| id    | Yes | Yes | number | Notification ID.  |
| label | Yes | Yes | string | Notification label.|
W
wusongqing 已提交
3606 3607


E
ester.zhou 已提交
3608
## SlotType
W
wusongqing 已提交
3609

E
ester.zhou 已提交
3610
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3611

E
ester.zhou 已提交
3612 3613
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
E
ester.zhou 已提交
3614 3615 3616 3617 3618
| 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 已提交
3619 3620


E
ester.zhou 已提交
3621
## NotificationActionButton
W
wusongqing 已提交
3622

E
ester.zhou 已提交
3623
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3624

E
ester.zhou 已提交
3625 3626 3627 3628 3629 3630
| Name     | Readable| Writable| Type                                           | Description                     |
| --------- | --- | ---- | ----------------------------------------------- | ------------------------- |
| title     | Yes | Yes | string                                          | Button title.                 |
| wantAgent | Yes | Yes | WantAgent                                       | **WantAgent** of the button.|
| extras    | Yes | Yes | { [key: string]: any }                          | Extra information of the button.             |
| userInput<sup>8+</sup> | Yes | Yes | [NotificationUserInput](#notificationuserinput8) | User input object.         |
W
wusongqing 已提交
3631 3632


E
ester.zhou 已提交
3633
## NotificationBasicContent
W
wusongqing 已提交
3634

E
ester.zhou 已提交
3635
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3636

E
ester.zhou 已提交
3637 3638 3639 3640 3641
| Name          | Readable| Writable| Type  | Description                              |
| -------------- | ---- | ---- | ------ | ---------------------------------- |
| title          | Yes  | Yes  | string | Notification title.                        |
| text           | Yes  | Yes  | string | Notification content.                        |
| additionalText | Yes  | Yes  | string | Additional information of the notification.|
W
wusongqing 已提交
3642 3643


E
ester.zhou 已提交
3644
## NotificationLongTextContent
W
wusongqing 已提交
3645

E
ester.zhou 已提交
3646
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3647

E
ester.zhou 已提交
3648 3649 3650 3651 3652 3653 3654 3655
| Name          | Readable| Writable| Type  | Description                            |
| -------------- | ---- | --- | ------ | -------------------------------- |
| title          | Yes | Yes | string | Notification title.                        |
| text           | Yes | Yes | string | Notification content.                        |
| additionalText | Yes | Yes | string | Additional information of the notification.|
| longText       | Yes | Yes | string | Long text of the notification.                    |
| briefText      | Yes | Yes | string | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string | Title of the notification in the expanded state.                |
W
wusongqing 已提交
3656 3657


E
ester.zhou 已提交
3658 3659 3660 3661
## NotificationMultiLineContent

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

E
ester.zhou 已提交
3662 3663 3664 3665 3666 3667 3668 3669
| Name          | Readable| Writable| Type           | Description                            |
| -------------- | --- | --- | --------------- | -------------------------------- |
| title          | Yes | Yes | string          | Notification title.                        |
| text           | Yes | Yes | string          | Notification content.                        |
| additionalText | Yes | Yes | string          | Additional information of the notification.|
| briefText      | Yes | Yes | string          | Brief text of the notification.|
| longTitle      | Yes | Yes | string          | Title of the notification in the expanded state.                |
| lines          | Yes | Yes | Array\<string\> | Multi-line text of the notification.                  |
E
ester.zhou 已提交
3670 3671 3672 3673 3674 3675


## NotificationPictureContent

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

E
ester.zhou 已提交
3676 3677 3678 3679 3680 3681 3682 3683
| Name          | Readable| Writable| Type          | Description                            |
| -------------- | ---- | --- | -------------- | -------------------------------- |
| title          | Yes | Yes | string         | Notification title.                        |
| text           | Yes | Yes | string         | Notification content.                        |
| additionalText | Yes | Yes | string         | Additional information of the notification.|
| briefText      | Yes | Yes | string         | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string         | Title of the notification in the expanded state.                |
| picture        | Yes | Yes | image.PixelMap | Picture attached to the notification.                  |
E
ester.zhou 已提交
3684 3685 3686 3687 3688 3689


## NotificationContent

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

E
ester.zhou 已提交
3690 3691 3692 3693 3694 3695 3696
| Name       | Readable| Writable| Type                                                        | Description              |
| ----------- | ---- | --- | ------------------------------------------------------------ | ------------------ |
| contentType | Yes | Yes | [ContentType](#contenttype)                                  | Notification content type.      |
| normal      | Yes | Yes | [NotificationBasicContent](#notificationbasiccontent)        | Normal text.  |
| longText    | Yes | Yes | [NotificationLongTextContent](#notificationlongtextcontent)  | Long text.|
| multiLine   | Yes | Yes | [NotificationMultiLineContent](#notificationmultilinecontent) | Multi-line text.  |
| picture     | Yes | Yes | [NotificationPictureContent](#notificationpicturecontent)    | Picture-attached.  |
E
ester.zhou 已提交
3697 3698 3699 3700 3701 3702


## NotificationFlagStatus<sup>8+</sup>

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

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

E
ester.zhou 已提交
3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715
| 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

E
ester.zhou 已提交
3716 3717 3718 3719
| Name            | Readable| Writable| Type                   | Description                              |
| ---------------- | ---- | ---- | ---------------------- | --------------------------------- |
| soundEnabled     | Yes  | No  | NotificationFlagStatus | Whether to enable the sound alert for the notification.                 |
| vibrationEnabled | Yes  | No  | NotificationFlagStatus | Whether to enable vibration for the notification.              |
E
ester.zhou 已提交
3720 3721 3722 3723 3724 3725


## NotificationRequest

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

E
ester.zhou 已提交
3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764
| Name                 | Readable| Writable| Type                                         | Description                      |
| --------------------- | ---- | --- | --------------------------------------------- | -------------------------- |
| content               | Yes | Yes | [NotificationContent](#notificationcontent)   | Notification content.                  |
| id                    | Yes | Yes | number                                        | Notification ID.                    |
| slotType              | Yes | Yes | [SlotType](#slottype)                         | Slot type.                  |
| isOngoing             | Yes | Yes | boolean                                       | Whether the notification is an ongoing notification.            |
| isUnremovable         | Yes | Yes | boolean                                       | Whether the notification can be removed.                |
| deliveryTime          | Yes | Yes | number                                        | Time when the notification is sent.              |
| tapDismissed          | Yes | Yes | boolean                                       | Whether the notification is automatically cleared.          |
| autoDeletedTime       | Yes | Yes | number                                        | Time when the notification is automatically cleared.            |
| wantAgent             | Yes | Yes | WantAgent                                     | **WantAgent** instance to which the notification will be redirected after being clicked.       |
| extraInfo             | Yes | Yes | {[key: string]: any}                          | Extended parameters.                  |
| color                 | Yes | Yes | number                                        | Background color of the notification.              |
| colorEnabled          | Yes | Yes | boolean                                       | Whether the notification background color is enabled.      |
| isAlertOnce           | Yes | Yes | boolean                                       | Whether the notification triggers an alert only once.|
| isStopwatch           | Yes | Yes | boolean                                       | Whether to display the stopwatch.          |
| isCountDown           | Yes | Yes | boolean                                       | Whether to display the countdown time.        |
| isFloatingIcon        | Yes | Yes | boolean                                       | Whether the notification is displayed as a floating icon.        |
| label                 | Yes | Yes | string                                        | Notification label.                  |
| badgeIconStyle        | Yes | Yes | number                                        | Notification badge type.              |
| showDeliveryTime      | Yes | Yes | boolean                                       | Whether to display the time when the notification is delivered.          |
| actionButtons         | Yes | Yes | Array\<[NotificationActionButton](#notificationactionbutton)\>             | Buttons in the notification. Up to two buttons are allowed.    |
| smallIcon             | Yes | Yes | PixelMap                                      | Small notification icon.                |
| largeIcon             | Yes | Yes | PixelMap                                      | Large notification icon.                |
| creatorBundleName     | Yes | No | string                                        | Name of the bundle that creates the notification.            |
| creatorUid            | Yes | No | number                                        | UID used for creating the notification.             |
| creatorPid            | Yes | No | number                                        | PID used for creating the notification.             |
| creatorUserId<sup>8+</sup>| Yes | No | number                                    | ID of the user who creates the notification.          |
| hashCode              | Yes | No | string                                        | Unique ID of the notification.              |
| classification        | Yes | Yes | string                                        | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| groupName<sup>8+</sup>| Yes | Yes | string                                        | Group notification name.                |
| template<sup>8+</sup> | Yes | Yes | [NotificationTemplate](#notificationtemplate8) | Notification template.                  |
| isRemoveAllowed<sup>8+</sup> | Yes | No | boolean                                | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| source<sup>8+</sup>   | Yes | No | number                                        | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| distributedOption<sup>8+</sup>   | Yes | Yes | [DistributedOptions](#distributedoptions8)                 | Option of distributed notification.         |
| deviceId<sup>8+</sup> | Yes | No | string                                        | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.         |
| notificationFlags<sup>8+</sup> | Yes | No | [NotificationFlags](#notificationflags8)                    | Notification flags.         |
| removalWantAgent<sup>9+</sup> | Yes | Yes | WantAgent                    | **WantAgent** instance to which the notification will be redirected when it is removed.         |
| badgeNumber<sup>9+</sup> | Yes | Yes | number                    | Number of notifications displayed on the application icon.         |
E
ester.zhou 已提交
3765 3766 3767 3768 3769 3770


## DistributedOptions<sup>8+</sup>

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

E
ester.zhou 已提交
3771 3772 3773 3774 3775 3776
| Name                  | Readable| Writable| Type           | Description                              |
| ---------------------- | ---- | ---- | -------------- | ---------------------------------- |
| isDistributed          | Yes  | Yes  | boolean        | Whether the notification is a distributed notification.                 |
| supportDisplayDevices  | Yes  | Yes  | Array\<string> | Types of the devices to which the notification can be synchronized.          |
| supportOperateDevices  | Yes  | Yes  | Array\<string> | Devices on which notification can be enabled.               |
| remindType             | Yes  | No  | number         | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications.                   |
E
ester.zhou 已提交
3777 3778 3779 3780 3781 3782


## NotificationSlot

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

E
ester.zhou 已提交
3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796
| Name                | Readable| Writable| Type                 | Description                                      |
| -------------------- | ---- | --- | --------------------- | ------------------------------------------ |
| type                 | Yes | Yes | [SlotType](#slottype) | Slot type.                                  |
| level                | Yes | Yes | number                | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc                 | Yes | Yes | string                | Notification slot description.                          |
| badgeFlag            | Yes | Yes | boolean               | Whether to display the badge.                              |
| bypassDnd            | Yes | Yes | boolean               | Whether to bypass the DND mode in the system.              |
| lockscreenVisibility | Yes | Yes | number                | Mode for displaying the notification on the lock screen.                |
| vibrationEnabled     | Yes | Yes | boolean               | Whether vibration is supported for the notification.                                |
| sound                | Yes | Yes | string                | Notification alert tone.                                |
| lightEnabled         | Yes | Yes | boolean               | Whether the indicator blinks for the notification.                                  |
| lightColor           | Yes | Yes | number                | Indicator color of the notification.                                |
| vibrationValues      | Yes | Yes | Array\<number\>       | Vibration mode of the notification.                              |
| enabled<sup>9+</sup> | Yes | No | boolean               | Enabled status of the notification slot.                     |
E
ester.zhou 已提交
3797 3798 3799 3800 3801 3802


## NotificationSorting

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

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

E
ester.zhou 已提交
3805 3806 3807 3808 3809
| Name    | Readable| Writable| Type                                 | Description        |
| -------- | ---- | --- | ------------------------------------- | ------------ |
| slot     | Yes | No | [NotificationSlot](#notificationslot) | Notification slot content.|
| hashCode | Yes | No | string                                | Unique ID of the notification.|
| ranking  | Yes | No | number                                | Notification sequence number.|
E
ester.zhou 已提交
3810 3811 3812 3813 3814 3815


## NotificationSortingMap

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

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

E
ester.zhou 已提交
3818 3819 3820 3821
| Name          | Readable| Writable| Type                                                        | Description            |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---------------- |
| sortings       | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Array of notification sorting information.|
| sortedHashCode | Yes | No | Array\<string\>                                              | Array of unique notification IDs.|
E
ester.zhou 已提交
3822 3823 3824 3825 3826 3827


## NotificationSubscribeInfo

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

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

E
ester.zhou 已提交
3830 3831 3832 3833
| Name       | Readable| Writable| Type           | Description                           |
| ----------- | --- | ---- | --------------- | ------------------------------- |
| bundleNames | Yes | Yes | Array\<string\> | Bundle names of the applications whose notifications are to be subscribed to.|
| userId      | Yes | Yes | number          | User whose notifications are to be subscribed to.   |
E
ester.zhou 已提交
3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849


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

E
ester.zhou 已提交
3850 3851 3852
| Name    | Readable| Writable| Type  | Description                         |
| -------- | --- | ---- | ------ | ----------------------------- |
| inputKey | Yes | Yes | string | Key to identify the user input.|
E
ester.zhou 已提交
3853

W
wusongqing 已提交
3854

E
ester.zhou 已提交
3855
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
3856

E
ester.zhou 已提交
3857
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3858

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

E
ester.zhou 已提交
3861 3862 3863 3864 3865 3866
| Name                | Value | Description                              |
| -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND    | 0   | The device is not in use. No notification is required.           |
| IDLE_REMIND          | 1   | The device is not in use.                |
| ACTIVE_DONOT_REMIND  | 2   | The device is in use. No notification is required.           |
| ACTIVE_REMIND        | 3   | The device is in use.                |
E
ester.zhou 已提交
3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879


## SourceType<sup>8+</sup>

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

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

| Name                | Value | Description                 |
| -------------------- | --- | -------------------- |
| TYPE_NORMAL          | 0   | Normal notification.           |
| TYPE_CONTINUOUS      | 1   | Continuous notification.           |
| TYPE_TIMER           | 2   | Timed notification.           |