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

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

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

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

## Modules to Import

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

```

E
ester.zhou 已提交
95 96 97 98 99 100 101 102
## 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 已提交
103 104
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

**Example**

```js
// publish callback
function publishCallback(err) {
E
esterzhou 已提交
120 121 122 123 124
    if (err.code) {
        console.info("publish failed " + JSON.stringify(err));
    } else {
        console.info("publish success");
    }
E
ester.zhou 已提交
125
}
E
ester.zhou 已提交
126
// ID of the user who receives the notification
E
ester.zhou 已提交
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
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 已提交
151 152
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

**Example**

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

var userId = 1
W
wusongqing 已提交
178

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


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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

E
ester.zhou 已提交
945
Sets whether to enable notification 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
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

E
ester.zhou 已提交
1015
Checks whether notification is enabled for a specified bundle. 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
**System API**: This is a system API and cannot be called by third-party applications.

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

E
ester.zhou 已提交
1617 1618 1619
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| hashCode | string                | Yes  | Unique notification ID.          |
E
esterzhou 已提交
1620
| reason   | [RemoveReason](#removereason9) | Yes  | Indicates the reason for deleting a notification.        |
E
ester.zhou 已提交
1621
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1622

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

Notification.removeAll(removeAllCallback);
```



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

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

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

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

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

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

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

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

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

```js
E
ester.zhou 已提交
1764
Notification.removeAll().then(() => {
E
esterzhou 已提交
1765
	console.info("removeAll sucess");
W
wusongqing 已提交
1766 1767 1768
});
```

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

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

E
ester.zhou 已提交
1773
Removes all notifications for a specified user. 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 1778
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

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

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

var userId = 1

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

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

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

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

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

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

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

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

E
ester.zhou 已提交
1818 1819 1820
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| userId | number | Yes  | ID of the user who receives the notification.|
E
ester.zhou 已提交
1821 1822 1823 1824 1825

**Example**

```js
function removeAllCallback(err) {
E
esterzhou 已提交
1826 1827 1828 1829 1830
    if (err.code) {
        console.info("removeAll failed " + JSON.stringify(err));
    } else {
        console.info("removeAll success");
    }
E
ester.zhou 已提交
1831 1832 1833 1834 1835 1836 1837 1838 1839
}

var userId = 1

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


## Notification.getAllActiveNotifications
W
wusongqing 已提交
1840

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

E
ester.zhou 已提交
1843 1844 1845 1846
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

E
ester.zhou 已提交
1847 1848
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1851 1852
**Parameters**

E
ester.zhou 已提交
1853 1854 1855
| Name    | Type                                                        | Mandatory| Description                |
| -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
1856 1857

**Example**
W
wusongqing 已提交
1858 1859 1860

```js
function getAllActiveNotificationsCallback(err, data) {
E
esterzhou 已提交
1861 1862 1863 1864 1865
    if (err.code) {
        console.info("getAllActiveNotifications failed " + JSON.stringify(err));
    } else {
        console.info("getAllActiveNotifications success");
    }
W
wusongqing 已提交
1866 1867 1868 1869 1870 1871 1872
}

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



E
ester.zhou 已提交
1873
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1874

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

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

E
ester.zhou 已提交
1879
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1880

E
ester.zhou 已提交
1881 1882
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1887 1888 1889
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1890

E
ester.zhou 已提交
1891
**Example**
W
wusongqing 已提交
1892 1893 1894

```js
Notification.getAllActiveNotifications().then((data) => {
E
esterzhou 已提交
1895
	console.info("getAllActiveNotifications sucess, data: " + JSON.stringify(data));
W
wusongqing 已提交
1896 1897 1898 1899 1900
});
```



E
ester.zhou 已提交
1901
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1902

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

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

E
ester.zhou 已提交
1907
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1908

E
ester.zhou 已提交
1909
**Parameters**
W
wusongqing 已提交
1910

E
ester.zhou 已提交
1911 1912 1913
| Name    | Type                  | Mandatory| Description                  |
| -------- | ---------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1914

E
ester.zhou 已提交
1915
**Example**
W
wusongqing 已提交
1916 1917 1918

```js
function getActiveNotificationCountCallback(err, data) {
E
esterzhou 已提交
1919 1920 1921 1922 1923
    if (err.code) {
        console.info("getActiveNotificationCount failed " + JSON.stringify(err));
    } else {
        console.info("getActiveNotificationCount success");
    }
W
wusongqing 已提交
1924 1925 1926 1927 1928 1929 1930
}

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



E
ester.zhou 已提交
1931
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1932

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

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

E
ester.zhou 已提交
1937
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1938

E
ester.zhou 已提交
1939
**Return value**
W
wusongqing 已提交
1940

E
ester.zhou 已提交
1941 1942 1943
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1944

E
ester.zhou 已提交
1945
**Example**
W
wusongqing 已提交
1946 1947 1948

```js
Notification.getActiveNotificationCount().then((data) => {
E
esterzhou 已提交
1949
	console.info("getActiveNotificationCount sucess, data: " + JSON.stringify(data));
W
wusongqing 已提交
1950 1951 1952 1953 1954
});
```



E
ester.zhou 已提交
1955
## Notification.getActiveNotifications
W
wusongqing 已提交
1956

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

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

E
ester.zhou 已提交
1961
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1962

E
ester.zhou 已提交
1963
**Parameters**
W
wusongqing 已提交
1964

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

E
ester.zhou 已提交
1969
**Example**
W
wusongqing 已提交
1970 1971 1972

```js
function getActiveNotificationsCallback(err, data) {
E
esterzhou 已提交
1973 1974 1975 1976 1977
    if (err.code) {
        console.info("getActiveNotifications failed " + JSON.stringify(err));
    } else {
        console.info("getActiveNotifications success");
    }
W
wusongqing 已提交
1978 1979 1980 1981 1982 1983 1984
}

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



E
ester.zhou 已提交
1985
## Notification.getActiveNotifications
W
wusongqing 已提交
1986

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

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

E
ester.zhou 已提交
1991
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1992

E
ester.zhou 已提交
1993
**Return value**
W
wusongqing 已提交
1994

E
ester.zhou 已提交
1995 1996 1997
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1998

E
ester.zhou 已提交
1999
**Example**
W
wusongqing 已提交
2000 2001 2002

```js
Notification.getActiveNotifications().then((data) => {
E
esterzhou 已提交
2003
	console.info("removeGroupByBundle sucess, data: " + JSON.stringify(data));
W
wusongqing 已提交
2004 2005 2006 2007 2008
});
```



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

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

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

E
ester.zhou 已提交
2015
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2016

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

E
ester.zhou 已提交
2019 2020 2021 2022
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
| groupName | string                | Yes  | Name of the notification group.              |
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2023

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

```js
function cancelGroupCallback(err) {
E
esterzhou 已提交
2028 2029 2030 2031 2032
    if (err.code) {
        console.info("cancelGroup failed " + JSON.stringify(err));
    } else {
        console.info("cancelGroup success");
    }
W
wusongqing 已提交
2033 2034 2035 2036 2037 2038 2039 2040 2041
}

var groupName = "GroupName";

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



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

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

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

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

E
ester.zhou 已提交
2050
**Parameters**
W
wusongqing 已提交
2051

E
ester.zhou 已提交
2052 2053 2054
| Name     | Type  | Mandatory| Description          |
| --------- | ------ | ---- | -------------- |
| groupName | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
2055

E
ester.zhou 已提交
2056
**Example**
W
wusongqing 已提交
2057 2058 2059 2060

```js
var groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => {
E
esterzhou 已提交
2061
	console.info("cancelGroup sucess");
W
wusongqing 已提交
2062 2063 2064 2065 2066
});
```



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

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

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

E
ester.zhou 已提交
2073
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2074

E
ester.zhou 已提交
2075 2076
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
2081 2082 2083 2084 2085
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
| bundle    | [BundleOption](#bundleoption)          | Yes  | Bundle information.                  |
| groupName | string                | Yes  | Name of the notification group.              |
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2086

E
ester.zhou 已提交
2087
**Example**
W
wusongqing 已提交
2088 2089 2090

```js
function removeGroupByBundleCallback(err) {
E
esterzhou 已提交
2091 2092 2093 2094 2095
    if (err.code) {
        console.info("removeGroupByBundle failed " + JSON.stringify(err));
    } else {
        console.info("removeGroupByBundle success");
    }
W
wusongqing 已提交
2096 2097 2098 2099 2100 2101 2102 2103 2104 2105
}

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

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



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

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

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

E
ester.zhou 已提交
2112
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2113

E
ester.zhou 已提交
2114 2115
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2118
**Parameters**
W
wusongqing 已提交
2119

E
ester.zhou 已提交
2120 2121 2122 2123
| Name     | Type        | Mandatory| Description          |
| --------- | ------------ | ---- | -------------- |
| bundle    | [BundleOption](#bundleoption) | Yes  | Bundle information.    |
| groupName | string       | Yes  | Name of the notification group.|
W
wusongqing 已提交
2124

E
ester.zhou 已提交
2125
**Example**
W
wusongqing 已提交
2126 2127 2128 2129 2130

```js
var bundleOption = {bundle: "Bundle"};
var groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
E
esterzhou 已提交
2131
	console.info("removeGroupByBundle sucess");
W
wusongqing 已提交
2132 2133 2134 2135 2136
});
```



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

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

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

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

E
ester.zhou 已提交
2145 2146
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2149
**Parameters**
W
wusongqing 已提交
2150

E
ester.zhou 已提交
2151 2152 2153 2154
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2155

E
ester.zhou 已提交
2156
**Example**
W
wusongqing 已提交
2157 2158 2159

```js
function setDoNotDisturbDateCallback(err) {
E
esterzhou 已提交
2160 2161 2162 2163 2164
    if (err.code) {
        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("setDoNotDisturbDate success");
    }
W
wusongqing 已提交
2165 2166 2167
}

var doNotDisturbDate = {
E
ester.zhou 已提交
2168
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2169 2170 2171 2172 2173 2174 2175 2176 2177
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}

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



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

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

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

E
ester.zhou 已提交
2184
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2185

E
ester.zhou 已提交
2186 2187
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2190
**Parameters**
W
wusongqing 已提交
2191

E
ester.zhou 已提交
2192 2193 2194
| Name| Type            | Mandatory| Description          |
| ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
2195

E
ester.zhou 已提交
2196
**Example**
W
wusongqing 已提交
2197 2198 2199

```js
var doNotDisturbDate = {
E
ester.zhou 已提交
2200
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2201 2202 2203 2204
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
E
esterzhou 已提交
2205
	console.info("setDoNotDisturbDate sucess");
W
wusongqing 已提交
2206 2207 2208 2209
});
```


E
ester.zhou 已提交
2210 2211 2212 2213 2214 2215 2216 2217
## 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 已提交
2218 2219
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2222 2223
**Parameters**

E
ester.zhou 已提交
2224 2225 2226 2227 2228
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| userId   | number                | Yes  | User ID.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2229 2230 2231 2232 2233

**Example**

```js
function setDoNotDisturbDateCallback(err) {
E
esterzhou 已提交
2234 2235 2236 2237 2238
    if (err.code) {
        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("setDoNotDisturbDate success");
    }
E
ester.zhou 已提交
2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260
}

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

E
ester.zhou 已提交
2262 2263
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2266
**Parameters**
W
wusongqing 已提交
2267

E
ester.zhou 已提交
2268 2269 2270 2271
| Name  | Type            | Mandatory| Description          |
| ------ | ---------------- | ---- | -------------- |
| date   | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
| userId | number           | Yes  | User ID.|
W
wusongqing 已提交
2272

E
ester.zhou 已提交
2273
**Example**
W
wusongqing 已提交
2274

E
ester.zhou 已提交
2275 2276 2277 2278 2279 2280 2281 2282 2283 2284
```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(() => {
E
esterzhou 已提交
2285
	console.info("setDoNotDisturbDate sucess");
E
ester.zhou 已提交
2286 2287 2288 2289 2290
});
```


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

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

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

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

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

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

E
ester.zhou 已提交
2302 2303
**Parameters**

E
ester.zhou 已提交
2304 2305 2306
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2307 2308

**Example**
W
wusongqing 已提交
2309 2310 2311

```js
function getDoNotDisturbDateCallback(err,data) {
E
esterzhou 已提交
2312 2313 2314 2315 2316
    if (err.code) {
        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("getDoNotDisturbDate success");
    }
W
wusongqing 已提交
2317 2318 2319 2320 2321 2322 2323
}

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



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

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

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

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

E
ester.zhou 已提交
2332 2333
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2336
**Return value**
W
wusongqing 已提交
2337

E
ester.zhou 已提交
2338 2339 2340
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2341

E
ester.zhou 已提交
2342
**Example**
W
wusongqing 已提交
2343 2344 2345

```js
Notification.getDoNotDisturbDate().then((data) => {
E
esterzhou 已提交
2346
	console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data));
W
wusongqing 已提交
2347 2348 2349 2350
});
```


E
ester.zhou 已提交
2351 2352 2353 2354 2355 2356 2357 2358
## 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 已提交
2359 2360 2361 2362
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2363 2364
**Parameters**

E
ester.zhou 已提交
2365 2366 2367 2368
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
| userId   | number                            | Yes  | User ID.|
E
ester.zhou 已提交
2369 2370 2371 2372 2373

**Example**

```js
function getDoNotDisturbDateCallback(err,data) {
E
esterzhou 已提交
2374 2375 2376 2377 2378
    if (err.code) {
        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("getDoNotDisturbDate success");
    }
E
ester.zhou 已提交
2379 2380 2381 2382 2383 2384 2385 2386 2387 2388
}

var userId = 1

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



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

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

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

E
ester.zhou 已提交
2394
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2395

E
ester.zhou 已提交
2396 2397 2398 2399
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2400
**Parameters**
W
wusongqing 已提交
2401

E
ester.zhou 已提交
2402 2403 2404
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| userId   | number                            | Yes  | User ID.|
W
wusongqing 已提交
2405

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

E
ester.zhou 已提交
2408 2409 2410
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2411

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

```js
var userId = 1

Notification.getDoNotDisturbDate(userId).then((data) => {
E
esterzhou 已提交
2418
	console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data));
E
ester.zhou 已提交
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430
});
```


## 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 已提交
2431 2432
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2435 2436
**Parameters**

E
ester.zhou 已提交
2437 2438 2439
| Name    | Type                    | Mandatory| Description                            |
| -------- | ------------------------ | ---- | -------------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2440 2441

**Example**
W
wusongqing 已提交
2442 2443 2444

```js
function supportDoNotDisturbModeCallback(err,data) {
E
esterzhou 已提交
2445 2446 2447 2448 2449
    if (err.code) {
        console.info("supportDoNotDisturbMode failed " + JSON.stringify(err));
    } else {
        console.info("supportDoNotDisturbMode success");
    }
W
wusongqing 已提交
2450 2451 2452 2453 2454 2455 2456
}

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



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

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

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

E
ester.zhou 已提交
2463
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2464

E
ester.zhou 已提交
2465 2466
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2469
**Return value**
W
wusongqing 已提交
2470

E
ester.zhou 已提交
2471 2472 2473
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2474

E
ester.zhou 已提交
2475
**Example**
W
wusongqing 已提交
2476 2477 2478

```js
Notification.supportDoNotDisturbMode().then((data) => {
E
esterzhou 已提交
2479
	console.info("supportDoNotDisturbMode sucess, data: " + JSON.stringify(data));
W
wusongqing 已提交
2480 2481 2482 2483 2484
});
```



E
ester.zhou 已提交
2485
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2486 2487 2488

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

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

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

E
ester.zhou 已提交
2493 2494 2495
**Parameters**

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

E
ester.zhou 已提交
2500
**Example**
W
wusongqing 已提交
2501 2502 2503 2504

```javascript
var templateName = 'process';
function isSupportTemplateCallback(err, data) {
E
esterzhou 已提交
2505 2506 2507 2508 2509
    if (err.code) {
        console.info("isSupportTemplate failed " + JSON.stringify(err));
    } else {
        console.info("isSupportTemplate success");
    }
W
wusongqing 已提交
2510 2511 2512 2513 2514 2515 2516
}

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



E
ester.zhou 已提交
2517
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2518 2519 2520

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

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

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

E
ester.zhou 已提交
2525 2526 2527
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2528
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2529
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2530

E
ester.zhou 已提交
2531
**Return value**
W
wusongqing 已提交
2532

E
ester.zhou 已提交
2533
| Type              | Description           |
W
wusongqing 已提交
2534 2535 2536
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2537
**Example**
W
wusongqing 已提交
2538 2539 2540 2541 2542

```javascript
var templateName = 'process';

Notification.isSupportTemplate(templateName).then((data) => {
E
esterzhou 已提交
2543
    console.info("isSupportTemplate success, data: " + JSON.stringify(data));
W
wusongqing 已提交
2544 2545 2546 2547 2548
});
```



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

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

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

E
ester.zhou 已提交
2555
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2556

E
ester.zhou 已提交
2557
**Parameters**
W
wusongqing 已提交
2558

E
ester.zhou 已提交
2559 2560 2561
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2562

E
ester.zhou 已提交
2563
**Example**
W
wusongqing 已提交
2564

E
ester.zhou 已提交
2565
```javascript
E
esterzhou 已提交
2566
function requestEnableNotificationCallback(err) {
E
esterzhou 已提交
2567 2568 2569
    if (err.code) {
        console.info("requestEnableNotification failed " + JSON.stringify(err));
    } else {
E
esterzhou 已提交
2570
        
E
esterzhou 已提交
2571
    }
E
ester.zhou 已提交
2572 2573
};

E
ester.zhou 已提交
2574
Notification.requestEnableNotification(requestEnableNotificationCallback);
W
wusongqing 已提交
2575 2576 2577 2578
```



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

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

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

E
ester.zhou 已提交
2585
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2586

E
ester.zhou 已提交
2587
**Example**
W
wusongqing 已提交
2588

E
ester.zhou 已提交
2589 2590 2591
```javascript
Notification.requestEnableNotification()
    .then(() => {
E
esterzhou 已提交
2592
        console.info("requestEnableNotification sucess");
E
ester.zhou 已提交
2593 2594
	});
```
W
wusongqing 已提交
2595 2596


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

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

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

E
ester.zhou 已提交
2603
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2604

E
ester.zhou 已提交
2605 2606
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2609
**Parameters**
W
wusongqing 已提交
2610

E
ester.zhou 已提交
2611 2612 2613 2614
| 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 已提交
2615

E
ester.zhou 已提交
2616
**Example**
W
wusongqing 已提交
2617

E
ester.zhou 已提交
2618
```javascript
E
esterzhou 已提交
2619
function enabledNotificationCallback(err) {
E
esterzhou 已提交
2620 2621 2622 2623 2624
    if (err.code) {
        console.info("enableDistributed failed " + JSON.stringify(err));
    } else {
        console.info("enableDistributed success");
    }
E
ester.zhou 已提交
2625
};
W
wusongqing 已提交
2626

E
ester.zhou 已提交
2627
var enable = true
W
wusongqing 已提交
2628

E
ester.zhou 已提交
2629
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2630 2631 2632 2633
```



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

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

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

E
ester.zhou 已提交
2640
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2641

E
ester.zhou 已提交
2642 2643
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2646
**Parameters**
W
wusongqing 已提交
2647

E
ester.zhou 已提交
2648 2649 2650
| 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 已提交
2651

E
ester.zhou 已提交
2652
**Example**
W
wusongqing 已提交
2653

E
ester.zhou 已提交
2654 2655
```javascript
var enable = true
W
wusongqing 已提交
2656

E
ester.zhou 已提交
2657 2658
Notification.enableDistributed(enable)
    .then(() => {
E
esterzhou 已提交
2659
        console.info("enableDistributed sucess");
E
ester.zhou 已提交
2660 2661
    });
```
W
wusongqing 已提交
2662 2663


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

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

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

E
ester.zhou 已提交
2670
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2671

E
ester.zhou 已提交
2672
**Parameters**
W
wusongqing 已提交
2673

E
ester.zhou 已提交
2674 2675 2676
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2677

E
ester.zhou 已提交
2678
**Example**
W
wusongqing 已提交
2679

E
ester.zhou 已提交
2680
```javascript
E
esterzhou 已提交
2681
function isDistributedEnabledCallback(err, data) {
E
esterzhou 已提交
2682 2683 2684
    if (err.code) {
        console.info("isDistributedEnabled failed " + JSON.stringify(err));
    } else {
E
esterzhou 已提交
2685
        console.info("isDistributedEnabled success " + JSON.stringify(data));
E
esterzhou 已提交
2686
    }
E
ester.zhou 已提交
2687
};
W
wusongqing 已提交
2688

E
ester.zhou 已提交
2689
Notification.isDistributedEnabled(isDistributedEnabledCallback);
E
ester.zhou 已提交
2690
```
W
wusongqing 已提交
2691 2692 2693



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

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

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

E
ester.zhou 已提交
2700
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2701

E
ester.zhou 已提交
2702
**Return value**
W
wusongqing 已提交
2703

E
ester.zhou 已提交
2704 2705 2706
| 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 已提交
2707

E
ester.zhou 已提交
2708 2709 2710 2711 2712
**Example**

```javascript
Notification.isDistributedEnabled()
    .then((data) => {
E
esterzhou 已提交
2713
        console.info("isDistributedEnabled sucess, data: " + JSON.stringify(data));
E
ester.zhou 已提交
2714
    });
W
wusongqing 已提交
2715 2716 2717
```


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

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

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

E
ester.zhou 已提交
2724
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2725

E
ester.zhou 已提交
2726 2727
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2730
**Parameters**
W
wusongqing 已提交
2731

E
ester.zhou 已提交
2732 2733 2734 2735 2736
| 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 已提交
2737

E
ester.zhou 已提交
2738
**Example**
W
wusongqing 已提交
2739

E
ester.zhou 已提交
2740
```javascript
E
esterzhou 已提交
2741
function enableDistributedByBundleCallback(err) {
E
esterzhou 已提交
2742 2743 2744 2745 2746
    if (err.code) {
        console.info("enableDistributedByBundle failed " + JSON.stringify(err));
    } else {
        console.info("enableDistributedByBundle success");
    }
E
ester.zhou 已提交
2747
};
W
wusongqing 已提交
2748

E
ester.zhou 已提交
2749 2750 2751
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2752

E
ester.zhou 已提交
2753
var enable = true
W
wusongqing 已提交
2754

E
ester.zhou 已提交
2755 2756
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2757 2758


E
ester.zhou 已提交
2759 2760 2761

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

E
ester.zhou 已提交
2762
enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
E
ester.zhou 已提交
2763 2764 2765 2766 2767

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

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

E
ester.zhou 已提交
2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783
**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 已提交
2784 2785
}

E
ester.zhou 已提交
2786
var enable = true
W
wusongqing 已提交
2787

E
ester.zhou 已提交
2788 2789
Notification.enableDistributedByBundle(bundle, enable)
    .then(() => {
E
esterzhou 已提交
2790
        console.info("enableDistributedByBundle sucess");
E
ester.zhou 已提交
2791
    });
W
wusongqing 已提交
2792 2793
```

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

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

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

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

E
ester.zhou 已提交
2802 2803
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2806
**Parameters**
W
wusongqing 已提交
2807

E
ester.zhou 已提交
2808 2809 2810 2811
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2812

E
ester.zhou 已提交
2813
**Example**
W
wusongqing 已提交
2814

E
ester.zhou 已提交
2815
```javascript
E
esterzhou 已提交
2816
function isDistributedEnabledByBundleCallback(err, data) {
E
esterzhou 已提交
2817 2818 2819
    if (err.code) {
        console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
    } else {
E
esterzhou 已提交
2820
        console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
E
esterzhou 已提交
2821
    }
E
ester.zhou 已提交
2822
};
W
wusongqing 已提交
2823

E
ester.zhou 已提交
2824 2825 2826
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2827

E
ester.zhou 已提交
2828
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
ester.zhou 已提交
2829
```
W
wusongqing 已提交
2830 2831 2832



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

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

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

E
ester.zhou 已提交
2839 2840
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2841 2842
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861
**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 已提交
2862
}
E
ester.zhou 已提交
2863 2864 2865

Notification.isDistributedEnabledByBundle(bundle)
    .then((data) => {
E
esterzhou 已提交
2866
        console.info("isDistributedEnabledByBundle sucess, data: " + JSON.stringify(data));
E
ester.zhou 已提交
2867
    });
W
wusongqing 已提交
2868 2869 2870
```


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

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

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

E
ester.zhou 已提交
2877
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2878

E
ester.zhou 已提交
2879 2880
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2883
**Parameters**
W
wusongqing 已提交
2884

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

E
ester.zhou 已提交
2889
**Example**
W
wusongqing 已提交
2890

E
ester.zhou 已提交
2891
```javascript
E
esterzhou 已提交
2892
function getDeviceRemindTypeCallback(err,data) {
E
esterzhou 已提交
2893 2894 2895 2896 2897
    if (err.code) {
        console.info("getDeviceRemindType failed " + JSON.stringify(err));
    } else {
        console.info("getDeviceRemindType success");
    }
E
ester.zhou 已提交
2898
};
W
wusongqing 已提交
2899

E
ester.zhou 已提交
2900 2901
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2902 2903 2904



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

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

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

E
ester.zhou 已提交
2911 2912
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2913 2914
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927
**Return value**

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

**Example**

```javascript
Notification.getDeviceRemindType()
    .then((data) => {
E
esterzhou 已提交
2928
        console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data));
E
ester.zhou 已提交
2929
    });
W
wusongqing 已提交
2930 2931
```

E
ester.zhou 已提交
2932

E
ester.zhou 已提交
2933 2934 2935 2936 2937 2938 2939 2940
## 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 已提交
2941 2942
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2943 2944 2945 2946 2947 2948
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
2949
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
2950 2951 2952 2953 2954 2955 2956 2957 2958
| 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) {
E
esterzhou 已提交
2959 2960 2961 2962 2963
    if (err.code) {
        console.info("publishAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("publishAsBundle success");
    }
E
ester.zhou 已提交
2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992
}
// 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 已提交
2993 2994
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2995 2996 2997 2998 2999 3000 3001
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
3002
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026
| 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(() => {
E
esterzhou 已提交
3027
	console.info("publishAsBundle sucess");
E
ester.zhou 已提交
3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038
});
```

## 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 已提交
3039 3040
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3041 3042
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

E
ester.zhou 已提交
3045
**Parameters**
E
ester.zhou 已提交
3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058

| 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) {
E
esterzhou 已提交
3059 3060 3061 3062 3063
    if (err.code) {
        console.info("cancelAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("cancelAsBundle success");
    }
E
ester.zhou 已提交
3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080
}
// 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 已提交
3081 3082
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3083 3084
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

E
ester.zhou 已提交
3087
**Parameters**
E
ester.zhou 已提交
3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103

| 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(() => {
E
esterzhou 已提交
3104
	console.info("cancelAsBundle success");
E
ester.zhou 已提交
3105 3106 3107
});
```

E
ester.zhou 已提交
3108
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
3109

E
ester.zhou 已提交
3110
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
3111 3112 3113 3114 3115 3116 3117

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

E
ester.zhou 已提交
3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133
**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) {
E
esterzhou 已提交
3134 3135 3136 3137 3138
    if (err.code) {
        console.info("enableNotificationSlot failed " + JSON.stringify(err));
    } else {
        console.info("enableNotificationSlot success");
    }
E
ester.zhou 已提交
3139 3140 3141 3142
};

Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3143
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3144 3145 3146 3147
    true,
    enableSlotCallback);
```

E
ester.zhou 已提交
3148
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
3149

E
ester.zhou 已提交
3150
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> 
E
ester.zhou 已提交
3151 3152 3153 3154 3155 3156 3157

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

E
ester.zhou 已提交
3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173
**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 已提交
3174
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3175
    true).then(() => {
E
esterzhou 已提交
3176
        console.info("enableNotificationSlot sucess");
E
ester.zhou 已提交
3177 3178 3179
    });
```

E
ester.zhou 已提交
3180
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3181

E
ester.zhou 已提交
3182
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
E
ester.zhou 已提交
3183

E
ester.zhou 已提交
3184
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 已提交
3185 3186 3187 3188 3189

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

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

E
ester.zhou 已提交
3190 3191
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3192 3193 3194 3195 3196 3197
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information.          |
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
3198
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3199 3200 3201 3202 3203 3204

**Example**

```js
//isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
E
esterzhou 已提交
3205 3206 3207 3208 3209
    if (err.code) {
        console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationSlotEnabled success");
    }
E
ester.zhou 已提交
3210 3211 3212 3213
};

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3214
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3215 3216 3217
    getEnableSlotCallback);
```

E
ester.zhou 已提交
3218
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3219

E
ester.zhou 已提交
3220
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>  
E
ester.zhou 已提交
3221

E
ester.zhou 已提交
3222
Obtains the enabled status of the notification slot of a specified type. This API uses a promise to return the result.
E
ester.zhou 已提交
3223 3224 3225 3226 3227

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

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

E
ester.zhou 已提交
3228 3229
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3230 3231 3232 3233 3234 3235 3236
**Parameters**

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

E
ester.zhou 已提交
3237 3238 3239 3240 3241 3242
**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the enabled status of the notification slot of the specified type.|

E
ester.zhou 已提交
3243 3244 3245 3246 3247 3248
**Example**

```js
//isNotificationSlotEnabled
Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3249 3250
    Notification.SlotType.SOCIAL_COMMUNICATION
    ).then((data) => {
E
esterzhou 已提交
3251
      console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
E
ester.zhou 已提交
3252 3253 3254
    });
```

E
ester.zhou 已提交
3255

E
ester.zhou 已提交
3256
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3257

E
ester.zhou 已提交
3258
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
E
ester.zhou 已提交
3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272

Sets whether to sync notifications to devices where the application is not installed. This API uses an asynchronous callback to return the result.

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
E
ester.zhou 已提交
3273 3274
| enable | boolean | Yes  | Whether the feature is enabled.<br>**true**: enabled<br>**false**: disabled  |
| callback | AsyncCallback\<void\>    | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3275 3276 3277 3278 3279 3280 3281

**Example**

```js
let userId = 100;
let enable = true;

E
ester.zhou 已提交
3282
function setSyncNotificationEnabledWithoutAppCallback(err) {
E
esterzhou 已提交
3283 3284 3285 3286 3287
    if (err.code) {
        console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
    } else {
        console.info("setSyncNotificationEnabledWithoutApp success");
    }
E
ester.zhou 已提交
3288 3289
}

E
ester.zhou 已提交
3290
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3291 3292 3293
```


E
ester.zhou 已提交
3294
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3295

E
ester.zhou 已提交
3296
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
E
ester.zhou 已提交
3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310

Sets whether to sync notifications to devices where the application is not installed. This API uses a promise to return the result.

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
E
ester.zhou 已提交
3311 3312 3313 3314 3315 3316 3317
| enable | boolean | Yes  | Whether the feature is enabled.<br>**true**: enabled<br>**false**: disabled  |

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|
E
ester.zhou 已提交
3318 3319 3320 3321 3322 3323 3324

**Example**

```js
let userId = 100;
let enable = true;

E
ester.zhou 已提交
3325
Notification.setSyncNotificationEnabledWithoutApp(userId, enable)
E
esterzhou 已提交
3326 3327
    .then(() => {
        console.info('setSyncNotificationEnabledWithoutApp');
E
ester.zhou 已提交
3328 3329
    })
    .catch((err) => {
E
esterzhou 已提交
3330
        console.info('setSyncNotificationEnabledWithoutApp, err:', err);
E
ester.zhou 已提交
3331 3332 3333 3334
    });
```


E
ester.zhou 已提交
3335
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3336

E
ester.zhou 已提交
3337
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
E
ester.zhou 已提交
3338

E
ester.zhou 已提交
3339
Obtains whether notifications are synced to devices where the application is not installed. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
E
ester.zhou 已提交
3352
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.<br>**true**: Notifications are synced to devices where the application is not installed.<br>**false**: Notifications are not synced to devices where the application is not installed.|
E
ester.zhou 已提交
3353 3354 3355 3356 3357 3358

**Example**

```js
let userId = 100;

E
ester.zhou 已提交
3359 3360
function getSyncNotificationEnabledWithoutAppCallback(data, err) {
    if (err) {
E
esterzhou 已提交
3361
        console.info('getSyncNotificationEnabledWithoutAppCallback, err' + err);
E
ester.zhou 已提交
3362
    } else {
E
esterzhou 已提交
3363
        console.info('getSyncNotificationEnabledWithoutAppCallback, data' + data);
E
ester.zhou 已提交
3364
    }
E
ester.zhou 已提交
3365 3366
}

E
ester.zhou 已提交
3367
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3368 3369 3370
```


E
ester.zhou 已提交
3371
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3372

E
ester.zhou 已提交
3373
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
E
ester.zhou 已提交
3374

E
ester.zhou 已提交
3375
Obtains whether notifications are synced to devices where the application is not installed. This API uses a promise to return the result.
E
ester.zhou 已提交
3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392

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

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

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
E
ester.zhou 已提交
3393
| Promise\<boolean\> | Promise used to return the result.<br>**true**: Notifications are synced to devices where the application is not installed.<br>**false**: Notifications are not synced to devices where the application is not installed.|
E
ester.zhou 已提交
3394 3395 3396 3397 3398 3399

**Example**

```js
let userId = 100;

E
ester.zhou 已提交
3400
Notification.getSyncNotificationEnabledWithoutApp(userId)
E
ester.zhou 已提交
3401
    .then((data) => {
E
esterzhou 已提交
3402
        console.info('getSyncNotificationEnabledWithoutApp, data:', data);
E
ester.zhou 已提交
3403 3404
    })
    .catch((err) => {
E
esterzhou 已提交
3405
        console.info('getSyncNotificationEnabledWithoutApp, err:', err);
E
ester.zhou 已提交
3406 3407 3408 3409 3410
    });
```



E
ester.zhou 已提交
3411 3412
## NotificationSubscriber

E
esterzhou 已提交
3413 3414
Provides callbacks for receiving or removing notifications.

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

E
ester.zhou 已提交
3417 3418
### onConsume

E
ester.zhou 已提交
3419
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3420

E
ester.zhou 已提交
3421
Callback for receiving notifications.
W
wusongqing 已提交
3422

E
ester.zhou 已提交
3423 3424
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
3427 3428 3429 3430
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
3431
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Notification information returned.|
E
ester.zhou 已提交
3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442

**Example**

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

E
ester.zhou 已提交
3444 3445 3446 3447 3448
function onConsumeCallback(data) {
    console.info('===> onConsume in test');
    let req = data.request;
    console.info('===> onConsume callback req.id:' + req.id);
};
W
wusongqing 已提交
3449

E
ester.zhou 已提交
3450 3451 3452
var subscriber = {
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
3453

E
ester.zhou 已提交
3454 3455
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3456

E
ester.zhou 已提交
3457
### onCancel
W
wusongqing 已提交
3458

E
ester.zhou 已提交
3459
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3460

E
ester.zhou 已提交
3461
Callback for removing notifications.
W
wusongqing 已提交
3462

E
ester.zhou 已提交
3463
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3464

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

E
ester.zhou 已提交
3467
**Parameters**
W
wusongqing 已提交
3468

E
ester.zhou 已提交
3469 3470
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
3471
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Notification information returned.|
W
wusongqing 已提交
3472

E
ester.zhou 已提交
3473
**Example**
W
wusongqing 已提交
3474

E
ester.zhou 已提交
3475 3476 3477 3478
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3479
    } else {
E
ester.zhou 已提交
3480
        console.info("subscribeCallback");
W
wusongqing 已提交
3481
    }
E
ester.zhou 已提交
3482 3483 3484 3485 3486 3487
};

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

E
ester.zhou 已提交
3490 3491 3492
var subscriber = {
    onCancel: onCancelCallback
};
W
wusongqing 已提交
3493

E
ester.zhou 已提交
3494
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3495 3496
```

E
ester.zhou 已提交
3497
### onUpdate
W
wusongqing 已提交
3498

E
ester.zhou 已提交
3499
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
W
wusongqing 已提交
3500

E
ester.zhou 已提交
3501
Callback for notification sorting updates.
W
wusongqing 已提交
3502

E
ester.zhou 已提交
3503
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3504

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

E
ester.zhou 已提交
3507
**Parameters**
W
wusongqing 已提交
3508

E
ester.zhou 已提交
3509 3510 3511
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.|
W
wusongqing 已提交
3512

E
ester.zhou 已提交
3513
**Example**
W
wusongqing 已提交
3514

E
ester.zhou 已提交
3515 3516 3517 3518 3519 3520 3521 3522
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3523

E
ester.zhou 已提交
3524 3525 3526
function onUpdateCallback() {
    console.info('===> onUpdate in test');
}
W
wusongqing 已提交
3527

E
ester.zhou 已提交
3528 3529 3530
var subscriber = {
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
3531

E
ester.zhou 已提交
3532 3533
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3534

E
ester.zhou 已提交
3535
### onConnect
W
wusongqing 已提交
3536

E
ester.zhou 已提交
3537
onConnect?:() => void
W
wusongqing 已提交
3538

E
ester.zhou 已提交
3539 3540 3541 3542
Callback for subscription.

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

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

E
ester.zhou 已提交
3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557
**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 已提交
3558 3559
}

E
ester.zhou 已提交
3560 3561 3562
var subscriber = {
    onConnect: onConnectCallback
};
W
wusongqing 已提交
3563

E
ester.zhou 已提交
3564
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3565 3566
```

E
ester.zhou 已提交
3567
### onDisconnect
W
wusongqing 已提交
3568

E
ester.zhou 已提交
3569
onDisconnect?:() => void
W
wusongqing 已提交
3570

E
ester.zhou 已提交
3571
Callback for unsubscription.
W
wusongqing 已提交
3572

E
ester.zhou 已提交
3573
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3574

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

E
ester.zhou 已提交
3577
**Example**
W
wusongqing 已提交
3578

E
ester.zhou 已提交
3579 3580 3581 3582 3583 3584 3585 3586
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3587

E
ester.zhou 已提交
3588 3589 3590
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
3591

E
ester.zhou 已提交
3592 3593 3594
var subscriber = {
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
3595

E
ester.zhou 已提交
3596 3597
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3598

E
ester.zhou 已提交
3599
### onDestroy
W
wusongqing 已提交
3600

E
ester.zhou 已提交
3601
onDestroy?:() => void
W
wusongqing 已提交
3602

E
ester.zhou 已提交
3603
Callback for service disconnection.
W
wusongqing 已提交
3604

E
ester.zhou 已提交
3605
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3606

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

E
ester.zhou 已提交
3609 3610 3611 3612 3613 3614
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3615
    } else {
E
ester.zhou 已提交
3616
        console.info("subscribeCallback");
W
wusongqing 已提交
3617
    }
E
ester.zhou 已提交
3618 3619 3620 3621
};

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

E
ester.zhou 已提交
3624 3625 3626
var subscriber = {
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
3627

E
ester.zhou 已提交
3628
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3629 3630
```

E
ester.zhou 已提交
3631 3632
### onDoNotDisturbDateChange<sup>8+</sup>

E
ester.zhou 已提交
3633
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
E
ester.zhou 已提交
3634 3635 3636 3637 3638

Callback for DND time setting updates.

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

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

E
ester.zhou 已提交
3641 3642 3643 3644
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3645
| mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
E
ester.zhou 已提交
3646 3647 3648 3649 3650 3651 3652 3653 3654 3655

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

E
ester.zhou 已提交
3657 3658 3659
function onDoNotDisturbDateChangeCallback() {
    console.info('===> onDoNotDisturbDateChange in test');
}
W
wusongqing 已提交
3660

E
ester.zhou 已提交
3661 3662 3663
var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
W
wusongqing 已提交
3664

E
ester.zhou 已提交
3665 3666
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3667 3668


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

E
ester.zhou 已提交
3671
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) => void
W
wusongqing 已提交
3672

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

E
ester.zhou 已提交
3675
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3676

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

E
ester.zhou 已提交
3679
**Parameters**
W
wusongqing 已提交
3680

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

E
ester.zhou 已提交
3685
**Example**
W
wusongqing 已提交
3686

E
ester.zhou 已提交
3687 3688 3689 3690 3691 3692 3693 3694
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3695

E
ester.zhou 已提交
3696 3697 3698 3699
function onEnabledNotificationChangedCallback(callbackData) {
    console.info("bundle: ", callbackData.bundle);
    console.info("uid: ", callbackData.uid);
    console.info("enable: ", callbackData.enable);
E
ester.zhou 已提交
3700
};
W
wusongqing 已提交
3701

E
ester.zhou 已提交
3702 3703 3704
var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
W
wusongqing 已提交
3705

E
ester.zhou 已提交
3706
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3707 3708
```

E
ester.zhou 已提交
3709
## SubscribeCallbackData
W
wusongqing 已提交
3710

E
ester.zhou 已提交
3711
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3712

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

E
esterzhou 已提交
3715 3716 3717 3718 3719 3720 3721
| Name           | Type                                             | Readable| Writable| Description    |
| --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request         | [NotificationRequest](#notificationrequest)       | Yes | No | Notification content.|
| sortingMap      | [NotificationSortingMap](#notificationsortingmap) | Yes | No | Notification sorting information.|
| reason          | number                                            | Yes | No | Reason for deletion.|
| sound           | string                                            | Yes | No | Sound used for notification.|
| vibrationValues | Array\<number\>                                   | Yes | No | Vibration used for notification.|
W
wusongqing 已提交
3722 3723


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

E
ester.zhou 已提交
3726
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3727

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

E
esterzhou 已提交
3730 3731 3732 3733 3734
| Name  | Type   | Readable| Writable| Description            |
| ------ | ------- | ---- | --- | ---------------- |
| bundle | string  | Yes | No | Bundle name of the application.      |
| uid    | number  | Yes | No | UID of the application.       |
| enable | boolean | Yes | No | Notification enabled status of the application.|
W
wusongqing 已提交
3735 3736


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

E
ester.zhou 已提交
3739
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3740

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

E
esterzhou 已提交
3743 3744 3745 3746 3747
| Name | Type                                 | Readable| Writable| Description                    |
| -----  ------------------------------------- || ---- | --- | ------------------------ |
| type  | [DoNotDisturbType](#donotdisturbtype8) | Yes | No | DND time type.|
| begin | Date                                  | Yes | No | DND start time.|
| end   | Date                                  | Yes | No | DND end time.|
W
wusongqing 已提交
3748 3749 3750



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

E
ester.zhou 已提交
3753
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3754

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

E
ester.zhou 已提交
3757 3758
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
E
ester.zhou 已提交
3759 3760 3761 3762
| 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 已提交
3763 3764


E
ester.zhou 已提交
3765
## ContentType
W
wusongqing 已提交
3766

E
ester.zhou 已提交
3767
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3768

E
ester.zhou 已提交
3769 3770
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3771 3772 3773 3774 3775
| 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 已提交
3776

E
ester.zhou 已提交
3777
## SlotLevel
W
wusongqing 已提交
3778

E
ester.zhou 已提交
3779
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3780

E
ester.zhou 已提交
3781 3782
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3783 3784 3785
| 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 已提交
3786 3787
| 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 已提交
3788 3789


E
ester.zhou 已提交
3790
## BundleOption
W
wusongqing 已提交
3791

E
ester.zhou 已提交
3792
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3793

E
esterzhou 已提交
3794 3795 3796 3797
| Name  | Type  | Readable| Writable| Description  |
| ------ | ------ |---- | --- |  ------ |
| bundle | string | Yes | Yes | Bundle name.  |
| uid    | number | Yes | Yes | User ID.|
W
wusongqing 已提交
3798 3799 3800



E
ester.zhou 已提交
3801
## NotificationKey
W
wusongqing 已提交
3802

E
ester.zhou 已提交
3803
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3804

E
esterzhou 已提交
3805 3806 3807 3808
| Name | Type  | Readable| Writable| Description    |
| ----- | ------ | ---- | --- | -------- |
| id    | number | Yes | Yes | Notification ID.  |
| label | string | Yes | Yes | Notification label.|
W
wusongqing 已提交
3809 3810


E
ester.zhou 已提交
3811
## SlotType
W
wusongqing 已提交
3812

E
ester.zhou 已提交
3813
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3814

E
ester.zhou 已提交
3815 3816
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
E
ester.zhou 已提交
3817 3818 3819 3820 3821
| 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 已提交
3822 3823


E
ester.zhou 已提交
3824
## NotificationActionButton
W
wusongqing 已提交
3825

E
esterzhou 已提交
3826 3827
Enumerates the buttons in the notification.

E
ester.zhou 已提交
3828
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3829

E
esterzhou 已提交
3830 3831 3832 3833 3834 3835
| Name     | Type                                           | Readable| Writable| Description                     |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title     | string                                          | Yes | Yes | Button title.                 |
| wantAgent | WantAgent                                       | Yes | Yes | **WantAgent** of the button.|
| extras    | { [key: string]: any }                          | Yes | Yes | Extra information of the button.             |
| userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | Yes | Yes | User input object.         |
W
wusongqing 已提交
3836 3837


E
ester.zhou 已提交
3838
## NotificationBasicContent
W
wusongqing 已提交
3839

E
esterzhou 已提交
3840 3841
Describes the normal text notification.

E
ester.zhou 已提交
3842
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3843

E
esterzhou 已提交
3844 3845 3846 3847 3848
| Name          | Type  | Readable| Writable| Description                              |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title          | string | Yes  | Yes  | Notification title.                        |
| text           | string | Yes  | Yes  | Notification content.                        |
| additionalText | string | Yes  | Yes  | Additional information of the notification.|
W
wusongqing 已提交
3849 3850


E
ester.zhou 已提交
3851
## NotificationLongTextContent
W
wusongqing 已提交
3852

E
esterzhou 已提交
3853 3854
Describes the long text notification.

E
ester.zhou 已提交
3855
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3856

E
esterzhou 已提交
3857 3858 3859 3860 3861 3862 3863 3864
| Name          | Type  | Readable| Writable| Description                            |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title          | string | Yes | Yes | Notification title.                        |
| text           | string | Yes | Yes | Notification content.                        |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| longText       | string | Yes | Yes | Long text of the notification.                    |
| briefText      | string | Yes | Yes | Brief text of the notification.|
| expandedTitle  | string | Yes | Yes | Title of the notification in the expanded state.                |
W
wusongqing 已提交
3865 3866


E
ester.zhou 已提交
3867 3868
## NotificationMultiLineContent

E
esterzhou 已提交
3869 3870
Describes the multi-line text notification.

E
ester.zhou 已提交
3871 3872
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3873 3874 3875 3876 3877 3878 3879 3880
| Name          | Type           | Readable| Writable| Description                            |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title          | string          | Yes | Yes | Notification title.                        |
| text           | string          | Yes | Yes | Notification content.                        |
| additionalText | string          | Yes | Yes | Additional information of the notification.|
| briefText      | string          | Yes | Yes | Brief text of the notification.|
| longTitle      | string          | Yes | Yes | Title of the notification in the expanded state.                |
| lines          | Array\<string\> | Yes | Yes | Multi-line text of the notification.                  |
E
ester.zhou 已提交
3881 3882 3883 3884


## NotificationPictureContent

E
esterzhou 已提交
3885 3886
Describes the picture-attached notification.

E
ester.zhou 已提交
3887 3888
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3889 3890 3891 3892 3893 3894 3895 3896
| Name          | Type          | Readable| Writable| Description                            |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title          | string         | Yes | Yes | Notification title.                        |
| text           | string         | Yes | Yes | Notification content.                        |
| additionalText | string         | Yes | Yes | Additional information of the notification.|
| briefText      | string         | Yes | Yes | Brief text of the notification.|
| expandedTitle  | string         | Yes | Yes | Title of the notification in the expanded state.                |
| picture        | image.PixelMap | Yes | Yes | Picture attached to the notification.                  |
E
ester.zhou 已提交
3897 3898 3899 3900


## NotificationContent

E
esterzhou 已提交
3901 3902
Describes the notification content.

E
ester.zhou 已提交
3903 3904
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3905 3906 3907 3908 3909 3910 3911
| Name       | Type                                                        | Readable| Writable| Description              |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](#contenttype)                                  | Yes | Yes | Notification content type.      |
| normal      | [NotificationBasicContent](#notificationbasiccontent)        | Yes | Yes | Normal text.  |
| longText    | [NotificationLongTextContent](#notificationlongtextcontent)  | Yes | Yes | Long text.|
| multiLine   | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text.  |
| picture     | [NotificationPictureContent](#notificationpicturecontent)    | Yes | Yes | Picture-attached.  |
E
ester.zhou 已提交
3912 3913 3914 3915


## NotificationFlagStatus<sup>8+</sup>

E
esterzhou 已提交
3916 3917
Describes the notification flag status.

E
ester.zhou 已提交
3918 3919
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
3922 3923 3924 3925 3926 3927 3928 3929 3930
| 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>

E
esterzhou 已提交
3931 3932
Enumerates notification flags.

E
ester.zhou 已提交
3933 3934
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3935 3936 3937 3938
| Name            | Type                   | Readable| Writable| Description                              |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled     | NotificationFlagStatus | Yes  | No  | Whether to enable the sound alert for the notification.                 |
| vibrationEnabled | NotificationFlagStatus | Yes  | No  | Whether to enable vibration for the notification.              |
E
ester.zhou 已提交
3939 3940 3941 3942


## NotificationRequest

E
esterzhou 已提交
3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985
Describes the notification request.

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

| Name                 | Type                                         | Readable| Writable| Description                      |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content               | [NotificationContent](#notificationcontent)   | Yes | Yes | Notification content.                  |
| id                    | number                                        | Yes | Yes | Notification ID.                    |
| slotType              | [SlotType](#slottype)                         | Yes | Yes | Slot type.                  |
| isOngoing             | boolean                                       | Yes | Yes | Whether the notification is an ongoing notification.            |
| isUnremovable         | boolean                                       | Yes | Yes | Whether the notification can be removed.                |
| deliveryTime          | number                                        | Yes | Yes | Time when the notification is sent.              |
| tapDismissed          | boolean                                       | Yes | Yes | Whether the notification is automatically cleared.          |
| autoDeletedTime       | number                                        | Yes | Yes | Time when the notification is automatically cleared.            |
| wantAgent             | WantAgent                                     | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked. |
| extraInfo             | {[key: string]: any}                          | Yes | Yes | Extended parameters.                  |
| color                 | number                                        | Yes | Yes | Background color of the notification. Not supported currently.      |
| colorEnabled          | boolean                                       | Yes | Yes | Whether the notification background color is enabled. Not supported currently. |
| isAlertOnce           | boolean                                       | Yes | Yes | Whether the notification triggers an alert only once.|
| isStopwatch           | boolean                                       | Yes | Yes | Whether to display the stopwatch.          |
| isCountDown           | boolean                                       | Yes | Yes | Whether to display the countdown time.        |
| isFloatingIcon        | boolean                                       | Yes | Yes | Whether the notification is displayed as a floating icon.        |
| label                 | string                                        | Yes | Yes | Notification label.                  |
| badgeIconStyle        | number                                        | Yes | Yes | Notification badge type.              |
| showDeliveryTime      | boolean                                       | Yes | Yes | Whether to display the time when the notification is delivered.          |
| actionButtons         | Array\<[NotificationActionButton](#notificationactionbutton)\>             | Yes | Yes | Buttons in the notification. Up to two buttons are allowed.    |
| smallIcon             | PixelMap                                      | Yes | Yes | Small notification icon.                |
| largeIcon             | PixelMap                                      | Yes | Yes | Large notification icon.                |
| creatorBundleName     | string                                        | Yes | No | Name of the bundle that creates the notification.            |
| creatorUid            | number                                        | Yes | No | UID used for creating the notification.             |
| creatorPid            | number                                        | Yes | No | PID used for creating the notification.             |
| creatorUserId<sup>8+</sup>| number                                    | Yes | No | ID of the user who creates the notification.          |
| hashCode              | string                                        | Yes | No | Unique ID of the notification.              |
| classification        | string                                        | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| groupName<sup>8+</sup>| string                                        | Yes | Yes | Group notification name.                |
| template<sup>8+</sup> | [NotificationTemplate](#notificationtemplate8) | Yes | Yes | Notification template.                  |
| isRemoveAllowed<sup>8+</sup> | boolean                                | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| source<sup>8+</sup>   | number                                        | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| distributedOption<sup>8+</sup>   | [DistributedOptions](#distributedoptions8)                 | Yes | Yes | Option of distributed notification.         |
| deviceId<sup>8+</sup> | string                                        | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.         |
| notificationFlags<sup>8+</sup> | [NotificationFlags](#notificationflags8)                    | Yes | No | Notification flags.         |
| removalWantAgent<sup>9+</sup> | WantAgent                    | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed.         |
| badgeNumber<sup>9+</sup> | number                    | Yes | Yes | Number of notifications displayed on the application icon.         |
E
ester.zhou 已提交
3986 3987 3988 3989


## DistributedOptions<sup>8+</sup>

E
esterzhou 已提交
3990 3991
Describes distributed options.

E
ester.zhou 已提交
3992 3993
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3994 3995 3996 3997 3998 3999
| Name                  | Type           | Readable| Writable| Description                              |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed          | boolean        | Yes  | Yes  | Whether the notification is a distributed notification.                 |
| supportDisplayDevices  | Array\<string> | Yes  | Yes  | Types of the devices to which the notification can be synchronized.          |
| supportOperateDevices  | Array\<string> | Yes  | Yes  | Devices on which notification can be enabled.               |
| remindType             | number         | Yes  | No  | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications.                   |
E
ester.zhou 已提交
4000 4001 4002 4003


## NotificationSlot

E
esterzhou 已提交
4004 4005
Describes the notification slot.

E
ester.zhou 已提交
4006 4007
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021
| Name                | Type                 | Readable| Writable| Description                                      |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type                 | [SlotType](#slottype) | Yes | Yes | Slot type.                                  |
| level                | number                | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc                 | string                | Yes | Yes | Notification slot description.                          |
| badgeFlag            | boolean               | Yes | Yes | Whether to display the badge.                              |
| bypassDnd            | boolean               | Yes | Yes | Whether to bypass the DND mode in the system.              |
| lockscreenVisibility | number                | Yes | Yes | Mode for displaying the notification on the lock screen.                |
| vibrationEnabled     | boolean               | Yes | Yes | Whether vibration is supported for the notification.                                |
| sound                | string                | Yes | Yes | Notification alert tone.                                |
| lightEnabled         | boolean               | Yes | Yes | Whether the indicator blinks for the notification.                                  |
| lightColor           | number                | Yes | Yes | Indicator color of the notification.                                |
| vibrationValues      | Array\<number\>       | Yes | Yes | Vibration mode of the notification.                              |
| enabled<sup>9+</sup> | boolean               | Yes | No | Enabled status of the notification slot.                     |
E
ester.zhou 已提交
4022 4023 4024 4025


## NotificationSorting

E
esterzhou 已提交
4026 4027
Provides sorting information of active notifications.

E
ester.zhou 已提交
4028 4029
**System capability**: SystemCapability.Notification.Notification

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

E
esterzhou 已提交
4032 4033 4034 4035 4036
| Name    | Type                                 | Readable| Writable| Description        |
| -------- | ------------------------------------- | ---- | --- | ------------ |
| slot     | [NotificationSlot](#notificationslot) | Yes | No | Notification slot content.|
| hashCode | string                                | Yes | No | Unique ID of the notification.|
| ranking  | number                                | Yes | No | Notification sequence number.|
E
ester.zhou 已提交
4037 4038 4039 4040


## NotificationSortingMap

E
esterzhou 已提交
4041 4042
Provides sorting information of active notifications in all subscribed notifications.

E
ester.zhou 已提交
4043 4044
**System capability**: SystemCapability.Notification.Notification

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

E
esterzhou 已提交
4047 4048 4049 4050
| Name          | Type                                                        | Readable| Writable| Description            |
| -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- |
| sortings       | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | No | Array of notification sorting information.|
| sortedHashCode | Array\<string\>                                              | Yes | No | Array of unique notification IDs.|
E
ester.zhou 已提交
4051 4052 4053 4054


## NotificationSubscribeInfo

E
esterzhou 已提交
4055 4056
Provides the information about the publisher for notification subscription.

E
ester.zhou 已提交
4057 4058
**System capability**: SystemCapability.Notification.Notification

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

E
esterzhou 已提交
4061 4062 4063 4064
| Name       | Type           | Readable| Writable| Description                           |
| ----------- | --------------- | --- | ---- | ------------------------------- |
| bundleNames | Array\<string\> | Yes | Yes | Bundle names of the applications whose notifications are to be subscribed to.|
| userId      | number          | Yes | Yes | User whose notifications are to be subscribed to.   |
E
ester.zhou 已提交
4065 4066 4067 4068


## NotificationTemplate<sup>8+</sup>

E
esterzhou 已提交
4069 4070
Notification template.

E
ester.zhou 已提交
4071 4072
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
4073
| Name| Type                   | Readable| Writable| Description      |
E
ester.zhou 已提交
4074 4075 4076 4077 4078 4079 4080
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | Yes  | Yes  | Template name.|
| data | {[key:string]: Object} | Yes  | Yes  | Template data.|


## NotificationUserInput<sup>8+</sup>

E
esterzhou 已提交
4081 4082
Provides the notification user input.

E
ester.zhou 已提交
4083 4084
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
4085 4086 4087
| Name    | Type  | Readable| Writable| Description                         |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.|
E
ester.zhou 已提交
4088

W
wusongqing 已提交
4089

E
ester.zhou 已提交
4090
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
4091

E
ester.zhou 已提交
4092
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
4093

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

E
ester.zhou 已提交
4096 4097 4098 4099 4100 4101
| Name                | Value | Description                              |
| -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND    | 0   | The device is not in use. No notification is required.           |
| IDLE_REMIND          | 1   | The device is not in use.                |
| ACTIVE_DONOT_REMIND  | 2   | The device is in use. No notification is required.           |
| ACTIVE_REMIND        | 3   | The device is in use.                |
E
ester.zhou 已提交
4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114


## SourceType<sup>8+</sup>

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

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

| Name                | Value | Description                 |
| -------------------- | --- | -------------------- |
| TYPE_NORMAL          | 0   | Normal notification.           |
| TYPE_CONTINUOUS      | 1   | Continuous notification.           |
| TYPE_TIMER           | 2   | Timed notification.           |
E
esterzhou 已提交
4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125

## RemoveReason<sup>9+</sup>

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

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

| Name                | Value | Description                 |
| -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE  | 1   | The notification is removed due to a click on it.   |
| CANCEL_REASON_REMOVE | 2   | The notification is removed by the user.        |