js-apis-notification.md 137.6 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**<br>
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
| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
| -------- | ---- | ---- | ------------------------------------------- | ---- | ------------------------------------------- |
E
ester.zhou 已提交
29
| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
30
| callback | Yes  | No  |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
**Example**
W
wusongqing 已提交
65 66 67 68 69 70

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

```

E
ester.zhou 已提交
85 86 87 88 89 90 91 92
## 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 已提交
93 94
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
97 98 99 100
**Parameters**

| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
E
ester.zhou 已提交
101
| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
102 103 104 105 106 107 108 109 110 111
| userId   | Yes  | No  |number                                      | Yes  | ID of the user who receives the notification.                          |
| callback | Yes  | No  |AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |

**Example**

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

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

E
ester.zhou 已提交
141 142 143 144
**Parameters**

| Name    | Readable| Writable| Type                                       | Mandatory| Description                                       |
| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
E
ester.zhou 已提交
145
| request  | Yes  | No  |[NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| userId   | Yes  | No  |number                                      | Yes  | ID of the user who receives the notification.                          |

**Example**

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

var userId = 1
W
wusongqing 已提交
164

E
ester.zhou 已提交
165 166 167 168
Notification.publish(notificationRequest, userId).then(() => {
	console.info("==========================>publishCallback=======================>");
});
```
W
wusongqing 已提交
169 170


E
ester.zhou 已提交
171
## Notification.cancel
W
wusongqing 已提交
172

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

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

E
ester.zhou 已提交
177
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
178

E
ester.zhou 已提交
179
**Parameters**
W
wusongqing 已提交
180

E
ester.zhou 已提交
181 182 183 184 185
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | --- | ---- | --------------------- | ---- | -------------------- |
| id       | Yes  | No  | number                | Yes  | Notification ID.              |
| label    | Yes  | No  | string                | Yes  | Notification label.            |
| callback | Yes  | No  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
186

E
ester.zhou 已提交
187
**Example**
W
wusongqing 已提交
188 189 190 191 192 193 194 195 196 197 198

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



E
ester.zhou 已提交
199
## Notification.cancel
W
wusongqing 已提交
200

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

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

E
ester.zhou 已提交
205
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
206

E
ester.zhou 已提交
207
**Parameters**
W
wusongqing 已提交
208

E
ester.zhou 已提交
209 210 211 212
| Name | Readable| Writable| Type  | Mandatory| Description    |
| ----- | --- | ---- | ------ | ---- | -------- |
| id    | Yes  | No  | number | Yes  | Notification ID.  |
| label | Yes  | No  | string | No  | Notification label.|
W
wusongqing 已提交
213

E
ester.zhou 已提交
214
**Example**
W
wusongqing 已提交
215 216

```js
E
ester.zhou 已提交
217
Notification.cancel(0).then(() => {
W
wusongqing 已提交
218 219 220 221 222 223
	console.info("==========================>cancelCallback=======================>");
});
```



E
ester.zhou 已提交
224
## Notification.cancel
W
wusongqing 已提交
225

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

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

E
ester.zhou 已提交
230
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
231

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

E
ester.zhou 已提交
234 235 236 237
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| id       | Yes  | No | number                | Yes  | Notification ID.              |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
238

E
ester.zhou 已提交
239
**Example**
W
wusongqing 已提交
240 241 242 243 244 245 246 247 248 249 250

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



E
ester.zhou 已提交
251
## Notification.cancelAll
W
wusongqing 已提交
252

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

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

E
ester.zhou 已提交
257
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
258

E
ester.zhou 已提交
259
**Parameters**
W
wusongqing 已提交
260

E
ester.zhou 已提交
261 262 263
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
264

E
ester.zhou 已提交
265
**Example**
W
wusongqing 已提交
266 267 268

```js
// cancel callback
E
ester.zhou 已提交
269 270
function cancelAllCallback(err) {
	console.info("==========================>cancelAllCallback=======================>");
W
wusongqing 已提交
271
}
E
ester.zhou 已提交
272
Notification.cancelAll(cancelAllCallback)
W
wusongqing 已提交
273 274 275 276
```



E
ester.zhou 已提交
277
## Notification.cancelAll
W
wusongqing 已提交
278

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

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

E
ester.zhou 已提交
283
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
284

E
ester.zhou 已提交
285
**Example**
W
wusongqing 已提交
286 287

```js
E
ester.zhou 已提交
288 289
Notification.cancelAll().then(() => {
	console.info("==========================>cancelAllCallback=======================>");
W
wusongqing 已提交
290 291 292 293 294
});
```



E
ester.zhou 已提交
295
## Notification.addSlot
W
wusongqing 已提交
296

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

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

E
ester.zhou 已提交
301
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
302

E
ester.zhou 已提交
303 304
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
307
**Parameters**
W
wusongqing 已提交
308

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

E
ester.zhou 已提交
314
**Example**
W
wusongqing 已提交
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329

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

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

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

E
ester.zhou 已提交
336
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
337

E
ester.zhou 已提交
338 339
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
342
**Parameters**
W
wusongqing 已提交
343

E
ester.zhou 已提交
344 345 346
| Name| Readable| Writable| Type            | Mandatory| Description                |
| ---- | ---- | --- | ---------------- | ---- | -------------------- |
| slot | Yes  | No | [NotificationSlot](#notificationslot) | Yes  | Notification slot to add.|
W
wusongqing 已提交
347

E
ester.zhou 已提交
348
**Example**
W
wusongqing 已提交
349 350 351 352 353 354

```js
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
355
Notification.addSlot(notificationSlot).then(() => {
W
wusongqing 已提交
356 357 358 359 360 361
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
362
## Notification.addSlot
W
wusongqing 已提交
363

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

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

E
ester.zhou 已提交
368
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
369

E
ester.zhou 已提交
370
**Parameters**
W
wusongqing 已提交
371

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

E
ester.zhou 已提交
377
**Example**
W
wusongqing 已提交
378 379 380 381 382 383 384 385 386 387 388

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



E
ester.zhou 已提交
389
## Notification.addSlot
W
wusongqing 已提交
390

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

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

E
ester.zhou 已提交
395
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
396

E
ester.zhou 已提交
397
**Parameters**
W
wusongqing 已提交
398

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

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

```js
E
ester.zhou 已提交
406
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
W
wusongqing 已提交
407 408 409 410 411 412
	console.info("==========================>addSlotCallback=======================>");
});
```



E
ester.zhou 已提交
413
## Notification.addSlots
W
wusongqing 已提交
414

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

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

E
ester.zhou 已提交
419
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
420

E
ester.zhou 已提交
421 422
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
425
**Parameters**
W
wusongqing 已提交
426

E
ester.zhou 已提交
427 428 429 430
| Name    | Readable| Writable| Type                     | Mandatory| Description                    |
| -------- | ---- | --- | ------------------------- | ---- | ------------------------ |
| slots    | Yes  | No | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
| callback | Yes  | No | AsyncCallback\<void\>     | Yes  | Callback used to return the result.    |
W
wusongqing 已提交
431

E
ester.zhou 已提交
432
**Example**
W
wusongqing 已提交
433 434 435 436 437 438 439 440 441 442 443

```js
// addSlots callback
function addSlotsCallBack(err) {
	console.info("==========================>addSlotsCallBack=======================>");
}
// NotificationSlot object
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
// NotificationSlotArray object
E
ester.zhou 已提交
444 445
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
446 447 448 449 450 451

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



E
ester.zhou 已提交
452
## Notification.addSlots
W
wusongqing 已提交
453

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

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

E
ester.zhou 已提交
458
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
459

E
ester.zhou 已提交
460 461
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
464
**Parameters**
W
wusongqing 已提交
465

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

E
ester.zhou 已提交
470
**Example**
W
wusongqing 已提交
471 472 473 474 475 476 477

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

E
ester.zhou 已提交
481
Notification.addSlots(notificationSlotArray).then(() => {
W
wusongqing 已提交
482 483 484 485 486 487
	console.info("==========================>addSlotCallback=======================>");
});
```



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

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

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

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

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

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

E
ester.zhou 已提交
503
**Example**
W
wusongqing 已提交
504 505 506 507 508 509 510 511 512 513 514 515

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



E
ester.zhou 已提交
516
## Notification.getSlot
W
wusongqing 已提交
517

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

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

E
ester.zhou 已提交
522
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
523

E
ester.zhou 已提交
524
**Parameters**
W
wusongqing 已提交
525

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

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

E
ester.zhou 已提交
532 533 534 535 536
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
537 538 539 540 541 542 543 544 545 546

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



E
ester.zhou 已提交
547
## Notification.getSlots
W
wusongqing 已提交
548

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

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

E
ester.zhou 已提交
553
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
554

E
ester.zhou 已提交
555
**Parameters**
W
wusongqing 已提交
556

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

E
ester.zhou 已提交
561
**Example**
W
wusongqing 已提交
562 563 564 565 566 567 568 569 570 571 572

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



E
ester.zhou 已提交
573
## Notification.getSlots
W
wusongqing 已提交
574

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

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

E
ester.zhou 已提交
579
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
580

E
ester.zhou 已提交
581
**Return value**
W
wusongqing 已提交
582

E
ester.zhou 已提交
583 584 585
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.|
W
wusongqing 已提交
586

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

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



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

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

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

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

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

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

E
ester.zhou 已提交
612
**Example**
W
wusongqing 已提交
613 614 615 616 617 618 619 620 621 622 623 624

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



E
ester.zhou 已提交
625
## Notification.removeSlot
W
wusongqing 已提交
626

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

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

E
ester.zhou 已提交
631
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
632

E
ester.zhou 已提交
633
**Parameters**
W
wusongqing 已提交
634

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

E
ester.zhou 已提交
639
**Example**
W
wusongqing 已提交
640 641 642

```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
643
Notification.removeSlot(slotType).then(() => {
W
wusongqing 已提交
644 645 646 647 648 649
	console.info("==========================>removeSlotCallback=======================>");
});
```



E
ester.zhou 已提交
650
## Notification.removeAllSlots
W
wusongqing 已提交
651

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

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

E
ester.zhou 已提交
656
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
657

E
ester.zhou 已提交
658
**Parameters**
W
wusongqing 已提交
659

E
ester.zhou 已提交
660 661 662
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
663

E
ester.zhou 已提交
664
**Example**
W
wusongqing 已提交
665 666 667 668 669 670 671 672 673 674

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



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

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

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

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

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

```js
E
ester.zhou 已提交
686
Notification.removeAllSlots().then(() => {
W
wusongqing 已提交
687 688 689 690 691 692
	console.info("==========================>removeAllCallBack=======================>");
});
```



E
ester.zhou 已提交
693
## Notification.subscribe
W
wusongqing 已提交
694

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

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

E
ester.zhou 已提交
699
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
700

E
ester.zhou 已提交
701 702
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
705
**Parameters**
W
wusongqing 已提交
706

E
ester.zhou 已提交
707 708 709 710 711
| Name      | Readable| Writable| Type                     | Mandatory| Description            |
| ---------- | ---- | --- | ------------------------- | ---- | ---------------- |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.    |
| info       | Yes  | No | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes  | Subscription information.        |
| callback   | Yes  | No | AsyncCallback\<void\>     | Yes  | Callback used to return the result.|
W
wusongqing 已提交
712

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

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



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

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

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

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

E
ester.zhou 已提交
742 743
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
746
**Parameters**
W
wusongqing 已提交
747

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

E
ester.zhou 已提交
753
**Example**
W
wusongqing 已提交
754 755 756 757 758

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



E
ester.zhou 已提交
770
## Notification.subscribe
W
wusongqing 已提交
771

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

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

E
ester.zhou 已提交
776
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
777

E
ester.zhou 已提交
778 779
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
782
**Parameters**
W
wusongqing 已提交
783

E
ester.zhou 已提交
784 785 786 787
| Name      | Readable| Writable| Type                     | Mandatory| Description        |
| ---------- | ---- | --- | ------------------------- | ---- | ------------ |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.|
| info       | Yes  | No | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No  | Subscription information.    |
W
wusongqing 已提交
788

E
ester.zhou 已提交
789
**Example**
W
wusongqing 已提交
790 791

```js
E
ester.zhou 已提交
792
function onConsumeCallback(data) {
W
wusongqing 已提交
793 794 795 796 797
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
798
Notification.subscribe(subscriber).then(() => {
W
wusongqing 已提交
799 800 801 802 803 804
	console.info("==========================>subscribeCallback=======================>");
});
```



E
ester.zhou 已提交
805
## Notification.unsubscribe
W
wusongqing 已提交
806

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

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

E
ester.zhou 已提交
811
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
812

E
ester.zhou 已提交
813 814
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
817
**Parameters**
W
wusongqing 已提交
818

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

E
ester.zhou 已提交
824
**Example**
W
wusongqing 已提交
825 826 827 828 829

```js
function unsubscribeCallback(err) {
	console.info("==========================>unsubscribeCallback=======================>");
}
E
ester.zhou 已提交
830
function onConsumeCallback(data) {
W
wusongqing 已提交
831 832 833 834 835 836 837 838 839 840
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
}
Notification.unsubscribe(subscriber, unsubscribeCallback);
```



E
ester.zhou 已提交
841
## Notification.unsubscribe
W
wusongqing 已提交
842

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

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

E
ester.zhou 已提交
847
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
848

E
ester.zhou 已提交
849 850
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
853
**Parameters**
W
wusongqing 已提交
854

E
ester.zhou 已提交
855 856 857
| Name      | Readable| Writable| Type                  | Mandatory| Description        |
| ---------- | ---- | --- | ---------------------- | ---- | ------------ |
| subscriber | Yes  | No | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
W
wusongqing 已提交
858

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

```js
E
ester.zhou 已提交
862
function onConsumeCallback(data) {
W
wusongqing 已提交
863 864 865 866 867
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
868
Notification.unsubscribe(subscriber).then(() => {
W
wusongqing 已提交
869 870 871 872 873 874
	console.info("==========================>unsubscribeCallback=======================>");
});
```



E
ester.zhou 已提交
875
## Notification.enableNotification
W
wusongqing 已提交
876

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

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

E
ester.zhou 已提交
881
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
882

E
ester.zhou 已提交
883 884
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
887
**Parameters**
W
wusongqing 已提交
888

E
ester.zhou 已提交
889 890 891 892 893
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| enable   | Yes  | No | boolean               | Yes  | Whether to enable notification.            |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
894

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

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



E
ester.zhou 已提交
909
## Notification.enableNotification
W
wusongqing 已提交
910

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

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

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

E
ester.zhou 已提交
917 918
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

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

```js
var bundle = {
E
ester.zhou 已提交
932
    bundle: "bundleName1",
W
wusongqing 已提交
933
}
E
ester.zhou 已提交
934
Notification.enableNotification(bundle, false).then(() => {
W
wusongqing 已提交
935 936 937 938 939 940
	console.info("==========================>enableNotificationCallback=======================>");
});
```



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

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

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

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

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

E
ester.zhou 已提交
951 952
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

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



E
ester.zhou 已提交
974 975 976
## Notification.isNotificationEnabled

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

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

E
ester.zhou 已提交
980
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
981

E
ester.zhou 已提交
982 983
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
988 989 990
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
991

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

E
ester.zhou 已提交
994 995 996
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
997

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

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



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

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

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

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

E
ester.zhou 已提交
1019 1020
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1025 1026 1027
| Name    | Readable| Writable| Type                 | Mandatory| Description                    |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1028

E
ester.zhou 已提交
1029
**Example**
W
wusongqing 已提交
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



E
ester.zhou 已提交
1041
## Notification.isNotificationEnabled
W
wusongqing 已提交
1042

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

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

E
ester.zhou 已提交
1047
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1048

E
ester.zhou 已提交
1049 1050
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1053
**Parameters**
W
wusongqing 已提交
1054

E
ester.zhou 已提交
1055 1056 1057
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1058

E
ester.zhou 已提交
1059 1060 1061 1062 1063
**Return value**

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

E
ester.zhou 已提交
1065
**Example**
W
wusongqing 已提交
1066 1067 1068 1069 1070 1071 1072 1073 1074

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



E
ester.zhou 已提交
1075
## Notification.displayBadge
W
wusongqing 已提交
1076

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

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

E
ester.zhou 已提交
1081
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1082

E
ester.zhou 已提交
1083 1084
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1087
**Parameters**
W
wusongqing 已提交
1088

E
ester.zhou 已提交
1089 1090 1091 1092 1093
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| enable   | Yes  | No | boolean               | Yes  | Whether to enable notification.            |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1094

E
ester.zhou 已提交
1095
**Example**
W
wusongqing 已提交
1096 1097 1098 1099 1100 1101

```js
function displayBadgeCallback(err) {
	console.info("==========================>displayBadgeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1102
    bundle: "bundleName1",
W
wusongqing 已提交
1103 1104 1105 1106 1107 1108
}
Notification.displayBadge(bundle, false, displayBadgeCallback);
```



E
ester.zhou 已提交
1109
## Notification.displayBadge
W
wusongqing 已提交
1110

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

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

E
ester.zhou 已提交
1115
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1116

E
ester.zhou 已提交
1117 1118
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1121
**Parameters**
W
wusongqing 已提交
1122

E
ester.zhou 已提交
1123 1124 1125 1126
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| enable | Yes  | No | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1127

E
ester.zhou 已提交
1128
**Example**
W
wusongqing 已提交
1129 1130 1131

```js
var bundle = {
E
ester.zhou 已提交
1132
    bundle: "bundleName1",
W
wusongqing 已提交
1133
}
E
ester.zhou 已提交
1134
Notification.displayBadge(bundle, false).then(() => {
W
wusongqing 已提交
1135 1136 1137 1138 1139 1140
	console.info("==========================>displayBadgeCallback=======================>");
});
```



E
ester.zhou 已提交
1141
## Notification.isBadgeDisplayed
W
wusongqing 已提交
1142

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

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

E
ester.zhou 已提交
1147
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1148

E
ester.zhou 已提交
1149 1150
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1153
**Parameters**
W
wusongqing 已提交
1154

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

E
ester.zhou 已提交
1160
**Example**
W
wusongqing 已提交
1161 1162 1163 1164 1165 1166

```js
function isBadgeDisplayedCallback(err, data) {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1167
    bundle: "bundleName1",
W
wusongqing 已提交
1168 1169 1170 1171 1172 1173
}
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```



E
ester.zhou 已提交
1174 1175 1176
## Notification.isBadgeDisplayed

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

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

E
ester.zhou 已提交
1180
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1181

E
ester.zhou 已提交
1182 1183
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1186
**Parameters**
W
wusongqing 已提交
1187

E
ester.zhou 已提交
1188 1189 1190
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1191

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

E
ester.zhou 已提交
1194 1195 1196
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1197

E
ester.zhou 已提交
1198
**Example**
W
wusongqing 已提交
1199 1200 1201

```js
var bundle = {
E
ester.zhou 已提交
1202
    bundle: "bundleName1",
W
wusongqing 已提交
1203 1204 1205 1206 1207 1208 1209 1210
}
Notification.isBadgeDisplayed(bundle).then((data) => {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
});
```



E
ester.zhou 已提交
1211
## Notification.setSlotByBundle
W
wusongqing 已提交
1212

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

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

E
ester.zhou 已提交
1217
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1218

E
ester.zhou 已提交
1219 1220
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1225 1226 1227 1228 1229
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.          |
| slot     | Yes  | No | [NotificationSlot](#notificationslot)      | Yes  | Notification slot.            |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1230

E
ester.zhou 已提交
1231
**Example**
W
wusongqing 已提交
1232 1233 1234 1235 1236 1237

```js
function setSlotByBundleCallback(err) {
	console.info("==========================>setSlotByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1238
    bundle: "bundleName1",
W
wusongqing 已提交
1239 1240 1241 1242 1243 1244 1245 1246 1247
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```



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

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

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

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

E
ester.zhou 已提交
1256 1257
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1260
**Parameters**
W
wusongqing 已提交
1261

E
ester.zhou 已提交
1262 1263 1264 1265
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
| slot   | Yes  | No | [NotificationSlot](#notificationslot) | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1266

E
ester.zhou 已提交
1267
**Example**
W
wusongqing 已提交
1268 1269 1270

```js
var bundle = {
E
ester.zhou 已提交
1271
    bundle: "bundleName1",
W
wusongqing 已提交
1272 1273 1274 1275
}
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
E
ester.zhou 已提交
1276
Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
W
wusongqing 已提交
1277 1278 1279 1280 1281 1282
	console.info("==========================>setSlotByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1283
## Notification.getSlotsByBundle
W
wusongqing 已提交
1284

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

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

E
ester.zhou 已提交
1289
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1290

E
ester.zhou 已提交
1291 1292
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1295
**Parameters**
W
wusongqing 已提交
1296

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

E
ester.zhou 已提交
1302
**Example**
W
wusongqing 已提交
1303 1304 1305 1306 1307 1308

```js
function getSlotsByBundleCallback(err, data) {
	console.info("==========================>getSlotsByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1309
    bundle: "bundleName1",
W
wusongqing 已提交
1310 1311 1312 1313 1314 1315
}
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```



E
ester.zhou 已提交
1316
## Notification.getSlotsByBundle
W
wusongqing 已提交
1317

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

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

E
ester.zhou 已提交
1322
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1323

E
ester.zhou 已提交
1324 1325
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1328
**Parameters**
W
wusongqing 已提交
1329

E
ester.zhou 已提交
1330 1331 1332
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1333

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

E
ester.zhou 已提交
1336 1337 1338 1339 1340
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1341 1342 1343

```js
var bundle = {
E
ester.zhou 已提交
1344
    bundle: "bundleName1",
W
wusongqing 已提交
1345 1346 1347 1348 1349 1350 1351 1352
}
Notification.getSlotsByBundle(bundle).then((data) => {
	console.info("==========================>getSlotsByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1353
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1354

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

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

E
ester.zhou 已提交
1359
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1360

E
ester.zhou 已提交
1361 1362
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1365
**Parameters**
W
wusongqing 已提交
1366

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

E
ester.zhou 已提交
1372
**Example**
W
wusongqing 已提交
1373 1374

```js
E
ester.zhou 已提交
1375
function getSlotNumByBundleCallback(err, data) {
W
wusongqing 已提交
1376 1377 1378
	console.info("==========================>getSlotNumByBundleCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1379
    bundle: "bundleName1",
W
wusongqing 已提交
1380 1381 1382 1383 1384 1385
}
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
```



E
ester.zhou 已提交
1386
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1387

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

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

E
ester.zhou 已提交
1392
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1393

E
ester.zhou 已提交
1394 1395
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1398
**Parameters**
W
wusongqing 已提交
1399

E
ester.zhou 已提交
1400 1401 1402
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1403

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

E
ester.zhou 已提交
1406 1407 1408 1409 1410
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1411 1412 1413

```js
var bundle = {
E
ester.zhou 已提交
1414
    bundle: "bundleName1",
W
wusongqing 已提交
1415 1416 1417 1418 1419 1420 1421 1422
}
Notification.getSlotNumByBundle(bundle).then((data) => {
	console.info("==========================>getSlotNumByBundleCallback=======================>");
});
```



E
ester.zhou 已提交
1423
## Notification.remove
W
wusongqing 已提交
1424

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

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

E
ester.zhou 已提交
1429
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1430

E
ester.zhou 已提交
1431 1432
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

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

```js
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1450
    bundle: "bundleName1",
W
wusongqing 已提交
1451 1452
}
var notificationKey = {
E
ester.zhou 已提交
1453 1454
    id: 0,
    label: "label",
W
wusongqing 已提交
1455 1456 1457 1458 1459 1460
}
Notification.remove(bundle, notificationKey, removeCallback);
```



E
ester.zhou 已提交
1461
## Notification.remove
W
wusongqing 已提交
1462

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

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

E
ester.zhou 已提交
1467
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1468

E
ester.zhou 已提交
1469 1470
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1473
**Parameters**
W
wusongqing 已提交
1474

E
ester.zhou 已提交
1475 1476 1477 1478
| Name           | Readable| Writable| Type           | Mandatory| Description      |
| --------------- | ---- | --- | --------------- | ---- | ---------- |
| bundle          | Yes  | No | [BundleOption](#bundleoption)    | Yes  | Bundle information.|
| notificationKey | Yes  | No | [NotificationKey](#notificationkey) | Yes  | Notification key.  |
W
wusongqing 已提交
1479

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

```js
var bundle = {
E
ester.zhou 已提交
1484
    bundle: "bundleName1",
W
wusongqing 已提交
1485 1486
}
var notificationKey = {
E
ester.zhou 已提交
1487 1488
    id: 0,
    label: "label",
W
wusongqing 已提交
1489
}
E
ester.zhou 已提交
1490
Notification.remove(bundle, notificationKey).then(() => {
W
wusongqing 已提交
1491 1492 1493 1494 1495 1496
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1497
## Notification.remove
W
wusongqing 已提交
1498

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

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

E
ester.zhou 已提交
1503
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1504

E
ester.zhou 已提交
1505 1506
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1509
**Parameters**
W
wusongqing 已提交
1510

E
ester.zhou 已提交
1511 1512 1513 1514
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| hashCode | Yes  | No | string                | Yes  | Unique notification ID.          |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1515

E
ester.zhou 已提交
1516
**Example**
W
wusongqing 已提交
1517 1518

```js
E
ester.zhou 已提交
1519 1520
var hashCode = 'hashCode'

W
wusongqing 已提交
1521 1522 1523 1524 1525 1526 1527 1528 1529
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}

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



E
ester.zhou 已提交
1530
## Notification.remove
W
wusongqing 已提交
1531

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

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

E
ester.zhou 已提交
1536
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1537

E
ester.zhou 已提交
1538 1539
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1542
**Parameters**
W
wusongqing 已提交
1543

E
ester.zhou 已提交
1544 1545 1546
| Name    | Readable| Writable| Type      | Mandatory| Description      |
| -------- | ---- | --- | ---------- | ---- | ---------- |
| hashCode | Yes  | No | string | Yes  | Unique notification ID.|
W
wusongqing 已提交
1547

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

```js
E
ester.zhou 已提交
1551 1552
var hashCode = 'hashCode'

E
ester.zhou 已提交
1553
Notification.remove(hashCode).then(() => {
W
wusongqing 已提交
1554 1555 1556 1557 1558 1559
	console.info("==========================>removeCallback=======================>");
});
```



E
ester.zhou 已提交
1560
## Notification.removeAll
W
wusongqing 已提交
1561

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

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

E
ester.zhou 已提交
1566
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1567

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

E
ester.zhou 已提交
1570 1571
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1572
**Parameters**
W
wusongqing 已提交
1573

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

E
ester.zhou 已提交
1579
**Example**
W
wusongqing 已提交
1580 1581 1582 1583 1584 1585

```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}
var bundle = {
E
ester.zhou 已提交
1586
    bundle: "bundleName1",
W
wusongqing 已提交
1587 1588 1589 1590 1591 1592
}
Notification.removeAll(bundle, removeAllCallback);
```



E
ester.zhou 已提交
1593
## Notification.removeAll
W
wusongqing 已提交
1594

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

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

E
ester.zhou 已提交
1599
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1600

E
ester.zhou 已提交
1601 1602
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1605
**Parameters**
W
wusongqing 已提交
1606

E
ester.zhou 已提交
1607 1608 1609
| Name    | Readable| Writable| Type                 | Mandatory| Description                |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1610

E
ester.zhou 已提交
1611
**Example**
W
wusongqing 已提交
1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622

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

Notification.removeAll(removeAllCallback);
```



E
ester.zhou 已提交
1623
## Notification.removeAll
W
wusongqing 已提交
1624

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

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

E
ester.zhou 已提交
1629
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1630

E
ester.zhou 已提交
1631 1632
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1635
**Parameters**
W
wusongqing 已提交
1636

E
ester.zhou 已提交
1637 1638 1639
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | Yes  | No | [BundleOption](#bundleoption) | No  | Bundle information.|
W
wusongqing 已提交
1640

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

```js
E
ester.zhou 已提交
1644
Notification.removeAll().then(() => {
W
wusongqing 已提交
1645 1646 1647 1648
	console.info("==========================>removeAllCallback=======================>");
});
```

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

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

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

E
ester.zhou 已提交
1655
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1656

E
ester.zhou 已提交
1657 1658
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1663 1664 1665 1666
| Name  | Readable| Writable| Type        | Mandatory| Description      |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| userId | Yes  | No | number | Yes  | ID of the user who receives the notification.|
| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1667

E
ester.zhou 已提交
1668
**Example**
W
wusongqing 已提交
1669

E
ester.zhou 已提交
1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687
```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 已提交
1688 1689
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711
**Parameters**

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

**Example**

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

var userId = 1

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


## Notification.getAllActiveNotifications
W
wusongqing 已提交
1712

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

E
ester.zhou 已提交
1715 1716 1717 1718
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

E
ester.zhou 已提交
1719 1720
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1723 1724 1725 1726 1727 1728 1729
**Parameters**

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

**Example**
W
wusongqing 已提交
1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740

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

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



E
ester.zhou 已提交
1741
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1742

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

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

E
ester.zhou 已提交
1747
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1748

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

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

E
ester.zhou 已提交
1753
**Return value**
W
wusongqing 已提交
1754

E
ester.zhou 已提交
1755 1756 1757
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1758

E
ester.zhou 已提交
1759
**Example**
W
wusongqing 已提交
1760 1761 1762 1763 1764 1765 1766 1767 1768

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



E
ester.zhou 已提交
1769
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1770

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

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

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

E
ester.zhou 已提交
1777
**Parameters**
W
wusongqing 已提交
1778

E
ester.zhou 已提交
1779 1780 1781
| Name    | Readable| Writable| Type                  | Mandatory| Description                  |
| -------- | ---- | --- | ---------------------- | ---- | ---------------------- |
| callback | Yes  | No | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1782

E
ester.zhou 已提交
1783
**Example**
W
wusongqing 已提交
1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794

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

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



E
ester.zhou 已提交
1795
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1796

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

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

E
ester.zhou 已提交
1801
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1802

E
ester.zhou 已提交
1803
**Return value**
W
wusongqing 已提交
1804

E
ester.zhou 已提交
1805 1806 1807
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1808

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

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



E
ester.zhou 已提交
1819
## Notification.getActiveNotifications
W
wusongqing 已提交
1820

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

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

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

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

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

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

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

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



E
ester.zhou 已提交
1845
## Notification.getActiveNotifications
W
wusongqing 已提交
1846

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

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

E
ester.zhou 已提交
1851
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1852

E
ester.zhou 已提交
1853
**Return value**
W
wusongqing 已提交
1854

E
ester.zhou 已提交
1855 1856 1857
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1858

E
ester.zhou 已提交
1859
**Example**
W
wusongqing 已提交
1860 1861 1862 1863 1864 1865 1866 1867 1868

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



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

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

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

E
ester.zhou 已提交
1875
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1876

E
ester.zhou 已提交
1877
**Parameters**
W
wusongqing 已提交
1878

E
ester.zhou 已提交
1879 1880 1881 1882
| Name     | Readable| Writable| Type                 | Mandatory| Description                        |
| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| groupName | Yes  | No | string                | Yes  | Name of the notification group.              |
| callback  | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1883

E
ester.zhou 已提交
1884
**Example**
W
wusongqing 已提交
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897

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

var groupName = "GroupName";

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



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

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

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

E
ester.zhou 已提交
1904
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1905

E
ester.zhou 已提交
1906
**Parameters**
W
wusongqing 已提交
1907

E
ester.zhou 已提交
1908 1909 1910
| Name     | Readable| Writable| Type  | Mandatory| Description          |
| --------- | ---- | --- | ------ | ---- | -------------- |
| groupName | Yes  | No | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
1911

E
ester.zhou 已提交
1912
**Example**
W
wusongqing 已提交
1913 1914 1915 1916 1917 1918 1919 1920 1921 1922

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



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

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

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

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

E
ester.zhou 已提交
1931 1932
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1935
**Parameters**
W
wusongqing 已提交
1936

E
ester.zhou 已提交
1937 1938 1939 1940 1941
| Name     | Readable| Writable| Type                 | Mandatory| Description                        |
| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| bundle    | Yes  | No | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
| groupName | Yes  | No | string                | Yes  | Name of the notification group.              |
| callback  | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1942

E
ester.zhou 已提交
1943
**Example**
W
wusongqing 已提交
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957

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

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

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



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

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

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

E
ester.zhou 已提交
1964
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1965

E
ester.zhou 已提交
1966 1967
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1970
**Parameters**
W
wusongqing 已提交
1971

E
ester.zhou 已提交
1972 1973 1974 1975
| Name     | Readable| Writable| Type        | Mandatory| Description          |
| --------- | ---- | --- | ------------ | ---- | -------------- |
| bundle    | Yes  | No | [BundleOption](#bundleoption) | Yes  | Bundle information.    |
| groupName | Yes  | No | string       | Yes  | Name of the notification group.|
W
wusongqing 已提交
1976

E
ester.zhou 已提交
1977
**Example**
W
wusongqing 已提交
1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988

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



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

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

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

E
ester.zhou 已提交
1995
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1996

E
ester.zhou 已提交
1997 1998
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2001
**Parameters**
W
wusongqing 已提交
2002

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

E
ester.zhou 已提交
2008
**Example**
W
wusongqing 已提交
2009 2010 2011 2012 2013 2014 2015

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

var doNotDisturbDate = {
E
ester.zhou 已提交
2016
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2017 2018 2019 2020 2021 2022 2023 2024 2025
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

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



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

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

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

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

E
ester.zhou 已提交
2034 2035
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2038
**Parameters**
W
wusongqing 已提交
2039

E
ester.zhou 已提交
2040 2041 2042
| Name| Readable| Writable| Type            | Mandatory| Description          |
| ---- | ---- | --- | ---------------- | ---- | -------------- |
| date | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
2043

E
ester.zhou 已提交
2044
**Example**
W
wusongqing 已提交
2045 2046 2047

```js
var doNotDisturbDate = {
E
ester.zhou 已提交
2048
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2049 2050 2051 2052 2053 2054 2055 2056 2057
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
	console.info("==========================>setDoNotDisturbDatePromise=======================>");
});
```


E
ester.zhou 已提交
2058 2059 2060 2061 2062 2063 2064 2065
## 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 已提交
2066 2067
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104
**Parameters**

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

**Example**

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

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

var userId = 1

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



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

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

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

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

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

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

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

E
ester.zhou 已提交
2112 2113 2114 2115
| Name  | Readable| Writable| Type            | Mandatory| Description          |
| ------ | ---- | --- | ---------------- | ---- | -------------- |
| date   | Yes  | No | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
| userId | Yes  | No | number           | Yes  | User ID.|
W
wusongqing 已提交
2116

E
ester.zhou 已提交
2117
**Example**
W
wusongqing 已提交
2118

E
ester.zhou 已提交
2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134
```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 已提交
2135

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

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

E
ester.zhou 已提交
2140
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2141

E
ester.zhou 已提交
2142 2143
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2146 2147 2148 2149 2150 2151 2152
**Parameters**

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

**Example**
W
wusongqing 已提交
2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163

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

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



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

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

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

E
ester.zhou 已提交
2170
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2171

E
ester.zhou 已提交
2172 2173
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
2178 2179 2180
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2181

E
ester.zhou 已提交
2182
**Example**
W
wusongqing 已提交
2183 2184 2185 2186 2187 2188 2189 2190

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


E
ester.zhou 已提交
2191 2192 2193 2194 2195 2196 2197 2198
## 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 已提交
2199 2200 2201 2202
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224
**Parameters**

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

**Example**

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

var userId = 1

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



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

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

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

E
ester.zhou 已提交
2230
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2231

E
ester.zhou 已提交
2232 2233 2234 2235
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2236
**Parameters**
W
wusongqing 已提交
2237

E
ester.zhou 已提交
2238 2239 2240
| Name    | Readable| Writable| Type                             | Mandatory| Description                  |
| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
| userId   | Yes  | No | number                            | Yes  | User ID.|
W
wusongqing 已提交
2241

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

E
ester.zhou 已提交
2244 2245 2246
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2247

E
ester.zhou 已提交
2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266
**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 已提交
2267 2268
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2271 2272 2273 2274 2275 2276 2277
**Parameters**

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

**Example**
W
wusongqing 已提交
2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288

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

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



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

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

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

E
ester.zhou 已提交
2295
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2296

E
ester.zhou 已提交
2297 2298
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
2303 2304 2305
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2306

E
ester.zhou 已提交
2307
**Example**
W
wusongqing 已提交
2308 2309 2310 2311 2312 2313 2314 2315 2316

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



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

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

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

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

E
ester.zhou 已提交
2325 2326 2327
**Parameters**

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

E
ester.zhou 已提交
2332
**Example**
W
wusongqing 已提交
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344

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

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



E
ester.zhou 已提交
2345
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2346 2347 2348

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

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

E
ester.zhou 已提交
2351
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2352

E
ester.zhou 已提交
2353 2354 2355
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2356
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2357
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2358

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

E
ester.zhou 已提交
2361
| Type              | Description           |
W
wusongqing 已提交
2362 2363 2364
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2365
**Example**
W
wusongqing 已提交
2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376

```javascript
var templateName = 'process';

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



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

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

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

E
ester.zhou 已提交
2383
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2384

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

E
ester.zhou 已提交
2387 2388 2389
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2390

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

E
ester.zhou 已提交
2393
```javascript
E
ester.zhou 已提交
2394
function requestEnableNotificationCallback() {
E
ester.zhou 已提交
2395 2396 2397
    console.log('------------- requestEnabledNotification --------------');
};

E
ester.zhou 已提交
2398
Notification.requestEnableNotification(requestEnableNotificationCallback);
W
wusongqing 已提交
2399 2400 2401 2402
```



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

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

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

E
ester.zhou 已提交
2409
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2410

E
ester.zhou 已提交
2411
**Example**
W
wusongqing 已提交
2412

E
ester.zhou 已提交
2413 2414 2415 2416 2417 2418
```javascript
Notification.requestEnableNotification()
    .then(() => {
        console.info("requestEnableNotification ");
	});
```
W
wusongqing 已提交
2419 2420


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

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

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

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

E
ester.zhou 已提交
2429 2430
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2433
**Parameters**
W
wusongqing 已提交
2434

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

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

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

E
ester.zhou 已提交
2447
var enable = true
W
wusongqing 已提交
2448

E
ester.zhou 已提交
2449
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2450 2451 2452 2453
```



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

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

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

E
ester.zhou 已提交
2460
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2461

E
ester.zhou 已提交
2462 2463
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2466
**Parameters**
W
wusongqing 已提交
2467

E
ester.zhou 已提交
2468 2469 2470
| 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 已提交
2471

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

E
ester.zhou 已提交
2474 2475
```javascript
var enable = true
W
wusongqing 已提交
2476

E
ester.zhou 已提交
2477 2478 2479 2480 2481
Notification.enableDistributed(enable)
    .then(() => {
        console.log('-------- enableDistributed ----------');
    });
```
W
wusongqing 已提交
2482 2483


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

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

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

E
ester.zhou 已提交
2490
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2491

E
ester.zhou 已提交
2492
**Parameters**
W
wusongqing 已提交
2493

E
ester.zhou 已提交
2494 2495 2496
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2497

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

E
ester.zhou 已提交
2500 2501 2502 2503
```javascript
function isDistributedEnabledCallback() {
    console.log('----------- isDistributedEnabled ------------');
};
W
wusongqing 已提交
2504

E
ester.zhou 已提交
2505
Notification.isDistributedEnabled(isDistributedEnabledCallback);
E
ester.zhou 已提交
2506
```
W
wusongqing 已提交
2507 2508 2509



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

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

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

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

E
ester.zhou 已提交
2518
**Return value**
W
wusongqing 已提交
2519

E
ester.zhou 已提交
2520 2521 2522
| 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 已提交
2523

E
ester.zhou 已提交
2524 2525 2526 2527 2528 2529 2530
**Example**

```javascript
Notification.isDistributedEnabled()
    .then((data) => {
        console.log('-------- isDistributedEnabled ----------');
    });
W
wusongqing 已提交
2531 2532 2533
```


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

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

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

E
ester.zhou 已提交
2540
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2541

E
ester.zhou 已提交
2542 2543
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2546
**Parameters**
W
wusongqing 已提交
2547

E
ester.zhou 已提交
2548 2549 2550 2551 2552
| 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 已提交
2553

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

E
ester.zhou 已提交
2556 2557 2558 2559
```javascript
function enableDistributedByBundleCallback() {
    console.log('----------- enableDistributedByBundle ------------');
};
W
wusongqing 已提交
2560

E
ester.zhou 已提交
2561 2562 2563
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2564

E
ester.zhou 已提交
2565
var enable = true
W
wusongqing 已提交
2566

E
ester.zhou 已提交
2567 2568
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2569 2570


E
ester.zhou 已提交
2571 2572 2573

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

E
ester.zhou 已提交
2574
enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
E
ester.zhou 已提交
2575 2576 2577 2578 2579

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

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

E
ester.zhou 已提交
2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595
**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 已提交
2596 2597
}

E
ester.zhou 已提交
2598
var enable = true
W
wusongqing 已提交
2599

E
ester.zhou 已提交
2600 2601 2602 2603
Notification.enableDistributedByBundle(bundle, enable)
    .then(() => {
        console.log('-------- enableDistributedByBundle ----------');
    });
W
wusongqing 已提交
2604 2605
```

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

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

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

E
ester.zhou 已提交
2612
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2613

E
ester.zhou 已提交
2614 2615
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2618
**Parameters**
W
wusongqing 已提交
2619

E
ester.zhou 已提交
2620 2621 2622 2623
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2624

E
ester.zhou 已提交
2625
**Example**
W
wusongqing 已提交
2626

E
ester.zhou 已提交
2627 2628 2629 2630
```javascript
function isDistributedEnabledByBundleCallback(data) {
    console.log('----------- isDistributedEnabledByBundle ------------', data);
};
W
wusongqing 已提交
2631

E
ester.zhou 已提交
2632 2633 2634
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2635

E
ester.zhou 已提交
2636
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
ester.zhou 已提交
2637
```
W
wusongqing 已提交
2638 2639 2640



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

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

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

E
ester.zhou 已提交
2647 2648
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2649 2650
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669
**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 已提交
2670
}
E
ester.zhou 已提交
2671 2672 2673 2674 2675

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


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

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

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

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

E
ester.zhou 已提交
2687 2688
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

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

E
ester.zhou 已提交
2699 2700 2701 2702
```javascript
function getDeviceRemindTypeCallback(data) {
    console.log('----------- getDeviceRemindType ------------', data);
};
W
wusongqing 已提交
2703

E
ester.zhou 已提交
2704 2705
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2706 2707 2708



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

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

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

E
ester.zhou 已提交
2715 2716
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2717 2718
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733
**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 已提交
2734 2735
```

E
ester.zhou 已提交
2736

E
ester.zhou 已提交
2737 2738 2739 2740 2741 2742 2743 2744
## 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 已提交
2745 2746
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2747 2748 2749 2750 2751 2752
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
2753
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792
| 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 已提交
2793 2794
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2795 2796 2797 2798 2799 2800 2801
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
2802
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838
| 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 已提交
2839 2840
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873
**Parameters**


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

**Example**

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

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

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

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

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

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

E
ester.zhou 已提交
2874 2875
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897
**Parameters**


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

**Example**

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

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

E
ester.zhou 已提交
2898
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
2899

E
ester.zhou 已提交
2900
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
2901 2902 2903 2904 2905 2906 2907

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

E
ester.zhou 已提交
2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928
**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 已提交
2929
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
2930 2931 2932 2933
    true,
    enableSlotCallback);
```

E
ester.zhou 已提交
2934
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
2935

E
ester.zhou 已提交
2936
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> 
E
ester.zhou 已提交
2937 2938 2939 2940 2941 2942 2943

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

E
ester.zhou 已提交
2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959
**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 已提交
2960
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
2961 2962 2963 2964 2965
    true).then(() => {
        console.log('====================>enableNotificationSlot====================>');
    });
```

E
ester.zhou 已提交
2966
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
2967

E
ester.zhou 已提交
2968
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
E
ester.zhou 已提交
2969

E
ester.zhou 已提交
2970
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 已提交
2971 2972 2973 2974 2975

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

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

E
ester.zhou 已提交
2976 2977
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2978 2979 2980 2981 2982 2983
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information.          |
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
2984
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995

**Example**

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

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
2996
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
2997 2998 2999
    getEnableSlotCallback);
```

E
ester.zhou 已提交
3000
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3001

E
ester.zhou 已提交
3002
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>  
E
ester.zhou 已提交
3003

E
ester.zhou 已提交
3004
Obtains the enabled status of the notification slot of a specified type. This API uses a promise to return the result.
E
ester.zhou 已提交
3005 3006 3007 3008 3009

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

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

E
ester.zhou 已提交
3010 3011
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3012 3013 3014 3015 3016 3017 3018
**Parameters**

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

E
ester.zhou 已提交
3019 3020 3021 3022 3023 3024
**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the enabled status of the notification slot of the specified type.|

E
ester.zhou 已提交
3025 3026 3027 3028 3029 3030
**Example**

```js
//isNotificationSlotEnabled
Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3031 3032
    Notification.SlotType.SOCIAL_COMMUNICATION
    ).then((data) => {
E
ester.zhou 已提交
3033 3034 3035 3036
      console.log('====================>isNotificationSlotEnabled====================>');
    });
```

E
ester.zhou 已提交
3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178

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

setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void

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.  |
| enable   | boolean         | Yes  | Whether to sync notifications to devices where the application is not installed. The value **true** means to sync notifications to devices where the application is not installed, and **false** means the opposite.|
| callback | AsyncCallback\<void\>         | Yes  | Callback used to return the result.|

**Example**

```js
let userId = 100;
let enable = true;

function setSyncNotificationEnabledForUninstallAppCallback(err) {
    console.log('setSyncNotificationEnabledForUninstallAppCallback');
}

Notification.setSyncNotificationEnabledForUninstallApp(userId, enable, setSyncNotificationEnabledForUninstallAppCallback);
```


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

setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean): Promise\<void>

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.  |
| enable   | boolean         | Yes  | Whether to sync notifications to devices where the application is not installed. The value **true** means to sync notifications to devices where the application is not installed, and **false** means the opposite.|

**Example**

```js
let userId = 100;
let enable = true;

Notification.setSyncNotificationEnabledForUninstallApp(userId, enable)
    .then((data) => {
        console.log('setSyncNotificationEnabledForUninstallApp, data:', data);
    })
    .catch((err) => {
        console.log('setSyncNotificationEnabledForUninstallApp, err:', err);
    });
```


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

getSyncNotificationEnabledForUninstallApp(userId: number, callback: AsyncCallback\<boolean>): void

Checks whether notifications are synced 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.  |
| callback | AsyncCallback\<boolean\>    | Yes  | Callback used to return the result. The value **true** means that notifications are synced to devices where the application is not installed, and **false** means the opposite.|

**Example**

```js
let userId = 100;

function getSyncNotificationEnabledForUninstallAppCallback(err, data) {
    console.log('getSyncNotificationEnabledForUninstallAppCallback, data: ', data);
}

Notification.getSyncNotificationEnabledForUninstallApp(userId, getSyncNotificationEnabledForUninstallAppCallback);
```


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

getSyncNotificationEnabledForUninstallApp(userId: number): Promise\<boolean>

Checks whether notifications are synced 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.  |

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result. The value **true** means that notifications are synced to devices where the application is not installed, and **false** means the opposite.|

**Example**

```js
let userId = 100;

Notification.getSyncNotificationEnabledForUninstallApp(userId)
    .then((data) => {
        console.log('getSyncNotificationEnabledForUninstallApp, data: ', data);
    })
    .catch((err) => {
        console.log('getSyncNotificationEnabledForUninstallApp, err: ', err);
    });
```



E
ester.zhou 已提交
3179 3180
## NotificationSubscriber

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

E
ester.zhou 已提交
3183 3184
### onConsume

E
ester.zhou 已提交
3185
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3186

E
ester.zhou 已提交
3187
Callback for receiving notifications.
W
wusongqing 已提交
3188

E
ester.zhou 已提交
3189 3190
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208
**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 已提交
3209

E
ester.zhou 已提交
3210 3211 3212 3213 3214 3215 3216
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 已提交
3217
            console.log('===> getWant success want:' + JSON.stringify(data1));
E
ester.zhou 已提交
3218 3219
        })
        .catch((err) => {
E
ester.zhou 已提交
3220
            console.error('===> getWant failed because' + JSON.stringify(err));
E
ester.zhou 已提交
3221
        });
E
ester.zhou 已提交
3222
    console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
E
ester.zhou 已提交
3223
};
W
wusongqing 已提交
3224

E
ester.zhou 已提交
3225 3226 3227
var subscriber = {
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
3228

E
ester.zhou 已提交
3229 3230
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3231

E
ester.zhou 已提交
3232
### onCancel
W
wusongqing 已提交
3233

E
ester.zhou 已提交
3234
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3235

E
ester.zhou 已提交
3236
Callback for removing notifications.
W
wusongqing 已提交
3237

E
ester.zhou 已提交
3238
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3239

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

E
ester.zhou 已提交
3242
**Parameters**
W
wusongqing 已提交
3243

E
ester.zhou 已提交
3244 3245 3246
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|
W
wusongqing 已提交
3247

E
ester.zhou 已提交
3248
**Example**
W
wusongqing 已提交
3249

E
ester.zhou 已提交
3250 3251 3252 3253
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3254
    } else {
E
ester.zhou 已提交
3255
        console.info("subscribeCallback");
W
wusongqing 已提交
3256
    }
E
ester.zhou 已提交
3257 3258 3259 3260 3261 3262
};

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

E
ester.zhou 已提交
3265 3266 3267
var subscriber = {
    onCancel: onCancelCallback
};
W
wusongqing 已提交
3268

E
ester.zhou 已提交
3269
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3270 3271
```

E
ester.zhou 已提交
3272
### onUpdate
W
wusongqing 已提交
3273

E
ester.zhou 已提交
3274
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
W
wusongqing 已提交
3275

E
ester.zhou 已提交
3276
Callback for notification sorting updates.
W
wusongqing 已提交
3277

E
ester.zhou 已提交
3278
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3279

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

E
ester.zhou 已提交
3282
**Parameters**
W
wusongqing 已提交
3283

E
ester.zhou 已提交
3284 3285 3286
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.|
W
wusongqing 已提交
3287

E
ester.zhou 已提交
3288
**Example**
W
wusongqing 已提交
3289

E
ester.zhou 已提交
3290 3291 3292 3293 3294 3295 3296 3297
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3298

E
ester.zhou 已提交
3299 3300 3301
function onUpdateCallback() {
    console.info('===> onUpdate in test');
}
W
wusongqing 已提交
3302

E
ester.zhou 已提交
3303 3304 3305
var subscriber = {
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
3306

E
ester.zhou 已提交
3307 3308
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3309

E
ester.zhou 已提交
3310
### onConnect
W
wusongqing 已提交
3311

E
ester.zhou 已提交
3312
onConnect?:() => void
W
wusongqing 已提交
3313

E
ester.zhou 已提交
3314 3315 3316 3317
Callback for subscription.

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

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

E
ester.zhou 已提交
3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332
**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 已提交
3333 3334
}

E
ester.zhou 已提交
3335 3336 3337
var subscriber = {
    onConnect: onConnectCallback
};
W
wusongqing 已提交
3338

E
ester.zhou 已提交
3339
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3340 3341
```

E
ester.zhou 已提交
3342
### onDisconnect
W
wusongqing 已提交
3343

E
ester.zhou 已提交
3344
onDisconnect?:() => void
W
wusongqing 已提交
3345

E
ester.zhou 已提交
3346
Callback for unsubscription.
W
wusongqing 已提交
3347

E
ester.zhou 已提交
3348
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3349

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

E
ester.zhou 已提交
3352
**Example**
W
wusongqing 已提交
3353

E
ester.zhou 已提交
3354 3355 3356 3357 3358 3359 3360 3361
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3362

E
ester.zhou 已提交
3363 3364 3365
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
3366

E
ester.zhou 已提交
3367 3368 3369
var subscriber = {
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
3370

E
ester.zhou 已提交
3371 3372
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3373

E
ester.zhou 已提交
3374
### onDestroy
W
wusongqing 已提交
3375

E
ester.zhou 已提交
3376
onDestroy?:() => void
W
wusongqing 已提交
3377

E
ester.zhou 已提交
3378
Callback for service disconnection.
W
wusongqing 已提交
3379

E
ester.zhou 已提交
3380
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3381

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

E
ester.zhou 已提交
3384 3385 3386 3387 3388 3389
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3390
    } else {
E
ester.zhou 已提交
3391
        console.info("subscribeCallback");
W
wusongqing 已提交
3392
    }
E
ester.zhou 已提交
3393 3394 3395 3396
};

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

E
ester.zhou 已提交
3399 3400 3401
var subscriber = {
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
3402

E
ester.zhou 已提交
3403
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3404 3405
```

E
ester.zhou 已提交
3406 3407
### onDoNotDisturbDateChange<sup>8+</sup>

E
ester.zhou 已提交
3408
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
E
ester.zhou 已提交
3409 3410 3411 3412 3413

Callback for DND time setting updates.

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

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

E
ester.zhou 已提交
3416 3417 3418 3419
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3420
| mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
E
ester.zhou 已提交
3421 3422 3423 3424 3425 3426 3427 3428 3429 3430

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

E
ester.zhou 已提交
3432 3433 3434
function onDoNotDisturbDateChangeCallback() {
    console.info('===> onDoNotDisturbDateChange in test');
}
W
wusongqing 已提交
3435

E
ester.zhou 已提交
3436 3437 3438
var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
W
wusongqing 已提交
3439

E
ester.zhou 已提交
3440 3441
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3442 3443


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

E
ester.zhou 已提交
3446
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) => void
W
wusongqing 已提交
3447

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

E
ester.zhou 已提交
3450
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3451

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

E
ester.zhou 已提交
3454
**Parameters**
W
wusongqing 已提交
3455

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

E
ester.zhou 已提交
3460
**Example**
W
wusongqing 已提交
3461

E
ester.zhou 已提交
3462 3463 3464 3465 3466 3467 3468 3469
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3470

E
ester.zhou 已提交
3471 3472 3473 3474
function onEnabledNotificationChangedCallback(callbackData) {
    console.info("bundle: ", callbackData.bundle);
    console.info("uid: ", callbackData.uid);
    console.info("enable: ", callbackData.enable);
E
ester.zhou 已提交
3475
};
W
wusongqing 已提交
3476

E
ester.zhou 已提交
3477 3478 3479
var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
W
wusongqing 已提交
3480

E
ester.zhou 已提交
3481
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3482 3483
```

E
ester.zhou 已提交
3484
## SubscribeCallbackData
W
wusongqing 已提交
3485

E
ester.zhou 已提交
3486
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3487

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

E
ester.zhou 已提交
3490 3491 3492 3493 3494 3495 3496
| Name           | Readable| Writable| Type                                             | Mandatory| Description    |
| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- |
| request         | Yes | No | [NotificationRequest](#notificationrequest)       | Yes  | Notification content.|
| sortingMap      | Yes | No | [NotificationSortingMap](#notificationsortingmap) | No  | Notification sorting information.|
| reason          | Yes | No | number                                            | No  | Reason for deletion.|
| sound           | Yes | No | string                                            | No  | Sound used for notification.|
| vibrationValues | Yes | No | Array\<number\>                                   | No  | Vibration used for notification.|
W
wusongqing 已提交
3497 3498


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

E
ester.zhou 已提交
3501
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3502

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

E
ester.zhou 已提交
3505 3506 3507 3508
| Name  | Readable| Writable| Type   | Mandatory| Description            |
| ------ | ---- | --- | ------- | ---- | ---------------- |
| bundle | Yes | No | string  | Yes  | Bundle name of the application.      |
| uid    | Yes | No | number  | Yes  | UID of the application.       |
E
ester.zhou 已提交
3509
| enable | Yes | No | boolean | Yes  | Notification enabled status of the application.|
W
wusongqing 已提交
3510 3511


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

E
ester.zhou 已提交
3514
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3515

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

E
ester.zhou 已提交
3518 3519 3520 3521 3522
| 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 已提交
3523 3524 3525



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

E
ester.zhou 已提交
3528
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3529

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

E
ester.zhou 已提交
3532 3533
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
E
ester.zhou 已提交
3534 3535 3536 3537
| 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 已提交
3538 3539


E
ester.zhou 已提交
3540
## ContentType
W
wusongqing 已提交
3541

E
ester.zhou 已提交
3542
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3543

E
ester.zhou 已提交
3544 3545
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3546 3547 3548 3549 3550
| 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 已提交
3551

E
ester.zhou 已提交
3552
## SlotLevel
W
wusongqing 已提交
3553

E
ester.zhou 已提交
3554
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3555

E
ester.zhou 已提交
3556 3557
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3558 3559 3560
| 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 已提交
3561 3562
| 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 已提交
3563 3564


E
ester.zhou 已提交
3565
## BundleOption
W
wusongqing 已提交
3566

E
ester.zhou 已提交
3567
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3568

E
ester.zhou 已提交
3569 3570 3571 3572
| Name  | Readable| Writable| Type  | Mandatory| Description  |
| ------ | ---- | --- | ------ | ---- | ------ |
| bundle | Yes | Yes | string | Yes  | Bundle name.  |
| uid    | Yes | Yes | number | No  | User ID.|
W
wusongqing 已提交
3573 3574 3575



E
ester.zhou 已提交
3576
## NotificationKey
W
wusongqing 已提交
3577

E
ester.zhou 已提交
3578
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3579

E
ester.zhou 已提交
3580 3581 3582 3583
| Name | Readable| Writable| Type  | Mandatory| Description    |
| ----- | ---- | --- | ------ | ---- | -------- |
| id    | Yes | Yes | number | Yes  | Notification ID.  |
| label | Yes | Yes | string | No  | Notification label.|
W
wusongqing 已提交
3584 3585


E
ester.zhou 已提交
3586
## SlotType
W
wusongqing 已提交
3587

E
ester.zhou 已提交
3588
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3589

E
ester.zhou 已提交
3590 3591
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
E
ester.zhou 已提交
3592 3593 3594 3595 3596
| 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 已提交
3597 3598


E
ester.zhou 已提交
3599
## NotificationActionButton
W
wusongqing 已提交
3600

E
ester.zhou 已提交
3601
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3602

E
ester.zhou 已提交
3603 3604 3605 3606 3607
| Name     | Readable| Writable| Type                                           | Mandatory| Description                     |
| --------- | --- | ---- | ----------------------------------------------- | ---- | ------------------------- |
| title     | Yes | Yes | string                                          | Yes  | Button title.                 |
| wantAgent | Yes | Yes | WantAgent                                       | Yes  | **WantAgent** of the button.|
| extras    | Yes | Yes | { [key: string]: any }                          | No  | Extra information of the button.             |
E
ester.zhou 已提交
3608
| userInput<sup>8+</sup> | Yes | Yes | [NotificationUserInput](#notificationuserinput8) | No  | User input object.         |
W
wusongqing 已提交
3609 3610


E
ester.zhou 已提交
3611
## NotificationBasicContent
W
wusongqing 已提交
3612

E
ester.zhou 已提交
3613
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3614

E
ester.zhou 已提交
3615 3616 3617 3618 3619
| Name          | Readable| Writable| Type  | Mandatory| Description                              |
| -------------- | ---- | ---- | ------ | ---- | ---------------------------------- |
| title          | Yes  | Yes  | string | Yes  | Notification title.                        |
| text           | Yes  | Yes  | string | Yes  | Notification content.                        |
| additionalText | Yes  | Yes  | string | No  | Additional information of the notification.|
W
wusongqing 已提交
3620 3621


E
ester.zhou 已提交
3622
## NotificationLongTextContent
W
wusongqing 已提交
3623

E
ester.zhou 已提交
3624
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3625

E
ester.zhou 已提交
3626 3627 3628 3629 3630 3631 3632 3633
| Name          | Readable| Writable| Type  | Mandatory| Description                            |
| -------------- | ---- | --- | ------ | ---- | -------------------------------- |
| title          | Yes | Yes | string | Yes  | Notification title.                        |
| text           | Yes | Yes | string | Yes  | Notification content.                        |
| additionalText | Yes | Yes | string | No  | Additional information of the notification.|
| longText       | Yes | Yes | string | Yes  | Long text of the notification.                    |
| briefText      | Yes | Yes | string | Yes  | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string | Yes  | Title of the notification in the expanded state.                |
W
wusongqing 已提交
3634 3635


E
ester.zhou 已提交
3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680
## NotificationMultiLineContent

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

| Name          | Readable| Writable| Type           | Mandatory| Description                            |
| -------------- | --- | --- | --------------- | ---- | -------------------------------- |
| title          | Yes | Yes | string          | Yes  | Notification title.                        |
| text           | Yes | Yes | string          | Yes  | Notification content.                        |
| additionalText | Yes | Yes | string          | No  | Additional information of the notification.|
| briefText      | Yes | Yes | string          | Yes  | Brief text of the notification.|
| longTitle      | Yes | Yes | string          | Yes  | Title of the notification in the expanded state.                |
| lines          | Yes | Yes | Array\<string\> | Yes  | Multi-line text of the notification.                  |


## NotificationPictureContent

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

| Name          | Readable| Writable| Type          | Mandatory| Description                            |
| -------------- | ---- | --- | -------------- | ---- | -------------------------------- |
| title          | Yes | Yes | string         | Yes  | Notification title.                        |
| text           | Yes | Yes | string         | Yes  | Notification content.                        |
| additionalText | Yes | Yes | string         | No  | Additional information of the notification.|
| briefText      | Yes | Yes | string         | Yes  | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string         | Yes  | Title of the notification in the expanded state.                |
| picture        | Yes | Yes | image.PixelMap | Yes  | Picture attached to the notification.                  |


## NotificationContent

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

| Name       | Readable| Writable| Type                                                        | Mandatory| Description              |
| ----------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------ |
| contentType | Yes | Yes | [ContentType](#contenttype)                                  | Yes  | Notification content type.      |
| normal      | Yes | Yes | [NotificationBasicContent](#notificationbasiccontent)        | No  | Normal text.  |
| longText    | Yes | Yes | [NotificationLongTextContent](#notificationlongtextcontent)  | No  | Long text.|
| multiLine   | Yes | Yes | [NotificationMultiLineContent](#notificationmultilinecontent) | No  | Multi-line text.  |
| picture     | Yes | Yes | [NotificationPictureContent](#notificationpicturecontent)    | No  | Picture-attached.  |


## NotificationFlagStatus<sup>8+</sup>

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

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

E
ester.zhou 已提交
3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730
| Name          | Value | Description                              |
| -------------- | --- | --------------------------------- |
| TYPE_NONE      | 0   | The default flag is used.                        |
| TYPE_OPEN      | 1   | The notification flag is enabled.                    |
| TYPE_CLOSE     | 2   | The notification flag is disabled.                    |


## NotificationFlags<sup>8+</sup>

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

| Name            | Readable| Writable| Type                   | Mandatory| Description                              |
| ---------------- | ---- | ---- | ---------------------- | ---- | --------------------------------- |
| soundEnabled     | Yes  | No  | NotificationFlagStatus | No  | Whether to enable the sound alert for the notification.                 |
| vibrationEnabled | Yes  | No  | NotificationFlagStatus | No  | Whether to enable vibration for the notification.              |


## NotificationRequest

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

| Name                 | Readable| Writable| Type                                         | Mandatory| Description                      |
| --------------------- | ---- | --- | --------------------------------------------- | ---- | -------------------------- |
| content               | Yes | Yes | [NotificationContent](#notificationcontent)   | Yes  | Notification content.                  |
| id                    | Yes | Yes | number                                        | No  | Notification ID.                    |
| slotType              | Yes | Yes | [SlotType](#slottype)                                      | No  | Slot type.                  |
| isOngoing             | Yes | Yes | boolean                                       | No  | Whether the notification is an ongoing notification.            |
| isUnremovable         | Yes | Yes | boolean                                       | No  | Whether the notification can be removed.                |
| deliveryTime          | Yes | Yes | number                                        | No  | Time when the notification is sent.              |
| tapDismissed          | Yes | Yes | boolean                                       | No  | Whether the notification is automatically cleared.          |
| autoDeletedTime       | Yes | Yes | number                                        | No  | Time when the notification is automatically cleared.            |
| wantAgent             | Yes | Yes | WantAgent                                     | No  | **WantAgent** instance to which the notification will be redirected after being clicked.       |
| extraInfo             | Yes | Yes | {[key: string]: any}                          | No  | Extended parameters.                  |
| color                 | Yes | Yes | number                                        | No  | Background color of the notification.              |
| colorEnabled          | Yes | Yes | boolean                                       | No  | Whether the notification background color is enabled.      |
| isAlertOnce           | Yes | Yes | boolean                                       | No  | Whether the notification triggers an alert only once.|
| isStopwatch           | Yes | Yes | boolean                                       | No  | Whether to display the stopwatch.          |
| isCountDown           | Yes | Yes | boolean                                       | No  | Whether to display the countdown time.        |
| isFloatingIcon        | Yes | Yes | boolean                                       | No  | Whether the notification is displayed as a floating icon.        |
| label                 | Yes | Yes | string                                        | No  | Notification label.                  |
| badgeIconStyle        | Yes | Yes | number                                        | No  | Notification badge type.              |
| showDeliveryTime      | Yes | Yes | boolean                                       | No  | Whether to display the time when the notification is delivered.          |
| actionButtons         | Yes | Yes | Array\<[NotificationActionButton](#notificationactionbutton)\>             | No  | Buttons in the notification. Up to two buttons are allowed.    |
| smallIcon             | Yes | Yes | PixelMap                                      | No  | Small notification icon.                |
| largeIcon             | Yes | Yes | PixelMap                                      | No  | Large notification icon.                |
| creatorBundleName     | Yes | No | string                                        | No  | Name of the bundle that creates the notification.            |
| creatorUid            | Yes | No | number                                        | No  | UID used for creating the notification.             |
| creatorPid            | Yes | No | number                                        | No  | PID used for creating the notification.             |
E
ester.zhou 已提交
3731
| creatorUserId<sup>8+</sup>| Yes | No | number                                    | No  | ID of the user who creates the notification.          |
E
ester.zhou 已提交
3732
| hashCode              | Yes | No | string                                        | No  | Unique ID of the notification.              |
E
ester.zhou 已提交
3733
| classification        | Yes | Yes | string                                        | No  | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
E
ester.zhou 已提交
3734 3735
| groupName<sup>8+</sup>| Yes | Yes | string                                        | No  | Group notification name.                |
| template<sup>8+</sup> | Yes | Yes | [NotificationTemplate](#notificationtemplate8) | No  | Notification template.                  |
E
ester.zhou 已提交
3736 3737
| isRemoveAllowed<sup>8+</sup> | Yes | No | boolean                                | No  | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| source<sup>8+</sup>   | Yes | No | number                                        | No  | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
E
ester.zhou 已提交
3738
| distributedOption<sup>8+</sup>   | Yes | Yes | [DistributedOptions](#distributedoptions8)                 | No  | Option of distributed notification.         |
E
ester.zhou 已提交
3739
| deviceId<sup>8+</sup> | Yes | No | string                                        | No  | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.         |
E
ester.zhou 已提交
3740
| notificationFlags<sup>8+</sup> | Yes | No | [NotificationFlags](#notificationflags8)                    | No  | Notification flags.         |
E
ester.zhou 已提交
3741 3742
| removalWantAgent<sup>9+</sup> | Yes | Yes | WantAgent                    | No  | **WantAgent** instance to which the notification will be redirected when it is removed.         |
| badgeNumber<sup>9+</sup> | Yes | Yes | number                    | No  | Number of notifications displayed on the application icon.         |
E
ester.zhou 已提交
3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753


## DistributedOptions<sup>8+</sup>

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

| Name                  | Readable| Writable| Type           | Mandatory| Description                              |
| ---------------------- | ---- | ---- | -------------- | ---- | ---------------------------------- |
| isDistributed          | Yes  | Yes  | boolean        | No  | Whether the notification is a distributed notification.                 |
| supportDisplayDevices  | Yes  | Yes  | Array\<string> | Yes  | Types of the devices to which the notification can be synchronized.          |
| supportOperateDevices  | Yes  | Yes  | Array\<string> | No  | Devices on which notification can be enabled.               |
E
ester.zhou 已提交
3754
| remindType             | Yes  | No  | number         | No  | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications.                   |
E
ester.zhou 已提交
3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773


## NotificationSlot

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

| Name                | Readable| Writable| Type                 | Mandatory| Description                                      |
| -------------------- | ---- | --- | --------------------- | ---- | ------------------------------------------ |
| type                 | Yes | Yes | [SlotType](#slottype) | Yes  | Slot type.                                  |
| level                | Yes | Yes | number                | No  | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc                 | Yes | Yes | string                | No  | Notification slot description.                          |
| badgeFlag            | Yes | Yes | boolean               | No  | Whether to display the badge.                              |
| bypassDnd            | Yes | Yes | boolean               | No  | Whether to bypass the DND mode in the system.              |
| lockscreenVisibility | Yes | Yes | boolean               | No  | Mode for displaying the notification on the lock screen.                |
| vibrationEnabled     | Yes | Yes | boolean               | No  | Whether vibration is supported for the notification.                                |
| sound                | Yes | Yes | string                | No  | Notification alert tone.                                |
| lightEnabled         | Yes | Yes | boolean               | No  | Whether the indicator blinks for the notification.                                  |
| lightColor           | Yes | Yes | number                | No  | Indicator color of the notification.                                |
| vibrationValues      | Yes | Yes | Array\<number\>       | No  | Vibration mode of the notification.                              |
E
ester.zhou 已提交
3774
| enabled<sup>9+</sup> | Yes | No | boolean               | No  | Enabled status of the notification slot.                     |
E
ester.zhou 已提交
3775 3776 3777 3778 3779 3780


## NotificationSorting

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

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

E
ester.zhou 已提交
3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793
| Name    | Readable| Writable| Type                                 | Mandatory| Description        |
| -------- | ---- | --- | ------------------------------------- | ---- | ------------ |
| slot     | Yes | No | [NotificationSlot](#notificationslot) | Yes  | Notification slot content.|
| hashCode | Yes | No | string                                | Yes  | Unique ID of the notification.|
| ranking  | Yes | No | number                                | Yes  | Notification sequence number.|


## NotificationSortingMap

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

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

E
ester.zhou 已提交
3796 3797 3798 3799 3800 3801 3802 3803 3804 3805
| Name          | Readable| Writable| Type                                                        | Mandatory| Description            |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- |
| sortings       | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes  | Array of notification sorting information.|
| sortedHashCode | Yes | No | Array\<string\>                                              | Yes  | Array of unique notification IDs.|


## NotificationSubscribeInfo

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

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

E
ester.zhou 已提交
3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831
| Name       | Readable| Writable| Type           | Mandatory| Description                           |
| ----------- | --- | ---- | --------------- | ---- | ------------------------------- |
| bundleNames | Yes | Yes | Array\<string\> | No  | Bundle names of the applications whose notifications are to be subscribed to.|
| userId      | Yes | Yes | number          | No  | User whose notifications are to be subscribed to.   |


## NotificationTemplate<sup>8+</sup>

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

| Name| Type              | Readable| Writable| Description      |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | Yes  | Yes  | Template name.|
| data | {[key:string]: Object} | Yes  | Yes  | Template data.|


## NotificationUserInput<sup>8+</sup>

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

| Name    | Readable| Writable| Type  | Mandatory| Description                         |
| -------- | --- | ---- | ------ | ---- | ----------------------------- |
| inputKey | Yes | Yes | string | Yes  | Key to identify the user input.|

W
wusongqing 已提交
3832

E
ester.zhou 已提交
3833
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
3834

E
ester.zhou 已提交
3835
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3836

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

E
ester.zhou 已提交
3839 3840 3841 3842 3843 3844
| 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 已提交
3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857


## 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.           |