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

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

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

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

## Modules to Import

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

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

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

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

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

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

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

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

```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 856 857 858 859
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribe success");
    }
W
wusongqing 已提交
860 861 862 863
}
var subscriber = {
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
864
Notification.subscribe(subscriber).then(() => {
E
esterzhou 已提交
865
	console.info("subscribe sucess");
W
wusongqing 已提交
866 867 868 869 870
});
```



E
ester.zhou 已提交
871
## Notification.unsubscribe
W
wusongqing 已提交
872

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

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

E
ester.zhou 已提交
877
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
878

E
ester.zhou 已提交
879 880
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
883
**Parameters**
W
wusongqing 已提交
884

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

E
ester.zhou 已提交
890
**Example**
W
wusongqing 已提交
891 892 893

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



E
ester.zhou 已提交
911
## Notification.unsubscribe
W
wusongqing 已提交
912

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

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

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

E
ester.zhou 已提交
919 920
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
923
**Parameters**
W
wusongqing 已提交
924

E
ester.zhou 已提交
925 926 927
| Name      | Type                  | Mandatory| Description        |
| ---------- | ---------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
W
wusongqing 已提交
928

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

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



E
ester.zhou 已提交
945
## Notification.enableNotification
W
wusongqing 已提交
946

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

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

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

E
ester.zhou 已提交
953 954
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
959 960 961 962 963
| 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 已提交
964

E
ester.zhou 已提交
965
**Example**
W
wusongqing 已提交
966 967 968

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



E
ester.zhou 已提交
983
## Notification.enableNotification
W
wusongqing 已提交
984

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

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

E
ester.zhou 已提交
989
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
990

E
ester.zhou 已提交
991 992
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
995
**Parameters**
W
wusongqing 已提交
996

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

E
ester.zhou 已提交
1002
**Example**
W
wusongqing 已提交
1003 1004 1005

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



E
ester.zhou 已提交
1015
## Notification.isNotificationEnabled
W
wusongqing 已提交
1016

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

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

E
ester.zhou 已提交
1021
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1022

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

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

E
ester.zhou 已提交
1027
**Parameters**
W
wusongqing 已提交
1028

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

E
ester.zhou 已提交
1034
**Example**
W
wusongqing 已提交
1035 1036 1037

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



E
ester.zhou 已提交
1052 1053 1054
## Notification.isNotificationEnabled

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

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

E
ester.zhou 已提交
1058
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1059

E
ester.zhou 已提交
1060 1061
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1064
**Parameters**
W
wusongqing 已提交
1065

E
ester.zhou 已提交
1066 1067 1068
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1069

E
ester.zhou 已提交
1070
**Return value**
W
wusongqing 已提交
1071

E
ester.zhou 已提交
1072 1073 1074
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1075

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

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



E
ester.zhou 已提交
1089
## Notification.isNotificationEnabled
W
wusongqing 已提交
1090

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

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

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

E
ester.zhou 已提交
1097 1098
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1101
**Parameters**
W
wusongqing 已提交
1102

E
ester.zhou 已提交
1103 1104 1105
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1106

E
ester.zhou 已提交
1107
**Example**
W
wusongqing 已提交
1108 1109 1110

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



E
ester.zhou 已提交
1123
## Notification.isNotificationEnabled
W
wusongqing 已提交
1124

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

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

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

E
ester.zhou 已提交
1131 1132
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1135
**Parameters**
W
wusongqing 已提交
1136

E
ester.zhou 已提交
1137 1138 1139
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1140

E
ester.zhou 已提交
1141 1142 1143 1144 1145
**Return value**

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

E
ester.zhou 已提交
1147
**Example**
W
wusongqing 已提交
1148 1149 1150

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



E
ester.zhou 已提交
1157
## Notification.displayBadge
W
wusongqing 已提交
1158

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

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

E
ester.zhou 已提交
1163
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1164

E
ester.zhou 已提交
1165 1166
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1169
**Parameters**
W
wusongqing 已提交
1170

E
ester.zhou 已提交
1171 1172 1173 1174 1175
| 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 已提交
1176

E
ester.zhou 已提交
1177
**Example**
W
wusongqing 已提交
1178 1179 1180

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



E
ester.zhou 已提交
1195
## Notification.displayBadge
W
wusongqing 已提交
1196

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

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

E
ester.zhou 已提交
1201
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1202

E
ester.zhou 已提交
1203 1204
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1207
**Parameters**
W
wusongqing 已提交
1208

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

E
ester.zhou 已提交
1214
**Example**
W
wusongqing 已提交
1215 1216 1217

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



E
ester.zhou 已提交
1227
## Notification.isBadgeDisplayed
W
wusongqing 已提交
1228

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

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

E
ester.zhou 已提交
1233
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1234

E
ester.zhou 已提交
1235 1236
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1239
**Parameters**
W
wusongqing 已提交
1240

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

E
ester.zhou 已提交
1246
**Example**
W
wusongqing 已提交
1247 1248 1249

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



E
ester.zhou 已提交
1264 1265 1266
## Notification.isBadgeDisplayed

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

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

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

E
ester.zhou 已提交
1272 1273
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1276
**Parameters**
W
wusongqing 已提交
1277

E
ester.zhou 已提交
1278 1279 1280
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1281

E
ester.zhou 已提交
1282
**Return value**
W
wusongqing 已提交
1283

E
ester.zhou 已提交
1284 1285 1286
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1287

E
ester.zhou 已提交
1288
**Example**
W
wusongqing 已提交
1289 1290 1291

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



E
ester.zhou 已提交
1301
## Notification.setSlotByBundle
W
wusongqing 已提交
1302

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

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

E
ester.zhou 已提交
1307
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1308

E
ester.zhou 已提交
1309 1310
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1313
**Parameters**
W
wusongqing 已提交
1314

E
ester.zhou 已提交
1315 1316 1317 1318 1319
| 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 已提交
1320

E
ester.zhou 已提交
1321
**Example**
W
wusongqing 已提交
1322 1323 1324

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



E
ester.zhou 已提交
1342
## Notification.setSlotByBundle
W
wusongqing 已提交
1343

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

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

E
ester.zhou 已提交
1348
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1349

E
ester.zhou 已提交
1350 1351
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1354
**Parameters**
W
wusongqing 已提交
1355

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

E
ester.zhou 已提交
1361
**Example**
W
wusongqing 已提交
1362 1363 1364

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



E
ester.zhou 已提交
1377
## Notification.getSlotsByBundle
W
wusongqing 已提交
1378

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

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

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

E
ester.zhou 已提交
1385 1386
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1389
**Parameters**
W
wusongqing 已提交
1390

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

E
ester.zhou 已提交
1396
**Example**
W
wusongqing 已提交
1397 1398 1399

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



E
ester.zhou 已提交
1414
## Notification.getSlotsByBundle
W
wusongqing 已提交
1415

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

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

E
ester.zhou 已提交
1420
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1421

E
ester.zhou 已提交
1422 1423
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1426
**Parameters**
W
wusongqing 已提交
1427

E
ester.zhou 已提交
1428 1429 1430
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1431

E
ester.zhou 已提交
1432
**Return value**
W
wusongqing 已提交
1433

E
ester.zhou 已提交
1434 1435 1436 1437 1438
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1439 1440 1441

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



E
ester.zhou 已提交
1451
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1452

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

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

E
ester.zhou 已提交
1457
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1458

E
ester.zhou 已提交
1459 1460
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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

E
ester.zhou 已提交
1470
**Example**
W
wusongqing 已提交
1471 1472

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



E
ester.zhou 已提交
1488
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1489

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

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

E
ester.zhou 已提交
1494
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1495

E
ester.zhou 已提交
1496 1497
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1500
**Parameters**
W
wusongqing 已提交
1501

E
ester.zhou 已提交
1502 1503 1504
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information.|
W
wusongqing 已提交
1505

E
ester.zhou 已提交
1506
**Return value**
W
wusongqing 已提交
1507

E
ester.zhou 已提交
1508 1509 1510 1511 1512
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1513 1514 1515

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



E
ester.zhou 已提交
1525
## Notification.remove
W
wusongqing 已提交
1526

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

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

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

E
ester.zhou 已提交
1533 1534
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1537
**Parameters**
W
wusongqing 已提交
1538

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

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

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



E
ester.zhou 已提交
1569
## Notification.remove
W
wusongqing 已提交
1570

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

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

E
ester.zhou 已提交
1575
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1576

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

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

E
ester.zhou 已提交
1581
**Parameters**
W
wusongqing 已提交
1582

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

E
ester.zhou 已提交
1589
**Example**
W
wusongqing 已提交
1590 1591 1592

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



E
ester.zhou 已提交
1607
## Notification.remove
W
wusongqing 已提交
1608

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

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

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

E
ester.zhou 已提交
1615 1616
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1619
**Parameters**
W
wusongqing 已提交
1620

E
ester.zhou 已提交
1621 1622 1623
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| hashCode | string                | Yes  | Unique notification ID.          |
E
esterzhou 已提交
1624
| reason   | [RemoveReason](#removereason9) | Yes  | Reason for removing the notification.        |
E
ester.zhou 已提交
1625
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1626

E
ester.zhou 已提交
1627
**Example**
W
wusongqing 已提交
1628 1629

```js
E
ester.zhou 已提交
1630 1631
var hashCode = 'hashCode'

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



E
ester.zhou 已提交
1645
## Notification.remove
W
wusongqing 已提交
1646

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

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

E
ester.zhou 已提交
1651
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1652

E
ester.zhou 已提交
1653 1654
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1657
**Parameters**
W
wusongqing 已提交
1658

E
ester.zhou 已提交
1659 1660 1661
| Name    | Type      | Mandatory| Description      |
| -------- | ---------- | ---- | ---------- |
| hashCode | string | Yes  | Unique notification ID.|
E
esterzhou 已提交
1662
| reason   | [RemoveReason](#removereason9) | Yes  | Reason for removing the notification.        |
W
wusongqing 已提交
1663

E
ester.zhou 已提交
1664
**Example**
W
wusongqing 已提交
1665 1666

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



E
ester.zhou 已提交
1676
## Notification.removeAll
W
wusongqing 已提交
1677

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

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

E
ester.zhou 已提交
1682
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1683

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

E
ester.zhou 已提交
1686 1687
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1688
**Parameters**
W
wusongqing 已提交
1689

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

E
ester.zhou 已提交
1695
**Example**
W
wusongqing 已提交
1696 1697 1698

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



E
ester.zhou 已提交
1713
## Notification.removeAll
W
wusongqing 已提交
1714

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

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

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

E
ester.zhou 已提交
1721 1722
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1725
**Parameters**
W
wusongqing 已提交
1726

E
ester.zhou 已提交
1727 1728 1729
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1730

E
ester.zhou 已提交
1731
**Example**
W
wusongqing 已提交
1732 1733 1734

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

Notification.removeAll(removeAllCallback);
```



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

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

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

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

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

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

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

E
ester.zhou 已提交
1761 1762 1763
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | No  | Bundle information.|
W
wusongqing 已提交
1764

E
ester.zhou 已提交
1765
**Example**
W
wusongqing 已提交
1766 1767

```js
E
ester.zhou 已提交
1768
Notification.removeAll().then(() => {
E
esterzhou 已提交
1769
	console.info("removeAll sucess");
W
wusongqing 已提交
1770 1771 1772
});
```

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

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

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

E
ester.zhou 已提交
1779
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1780

E
ester.zhou 已提交
1781 1782
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1785
**Parameters**
W
wusongqing 已提交
1786

E
ester.zhou 已提交
1787 1788 1789 1790
| 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 已提交
1791

E
ester.zhou 已提交
1792
**Example**
W
wusongqing 已提交
1793

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

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

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

E
ester.zhou 已提交
1820 1821
**Parameters**

E
ester.zhou 已提交
1822 1823 1824
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
| userId | number | Yes  | ID of the user who receives the notification.|
E
ester.zhou 已提交
1825 1826 1827 1828 1829

**Example**

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

var userId = 1

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


## Notification.getAllActiveNotifications
W
wusongqing 已提交
1844

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

E
ester.zhou 已提交
1847 1848 1849 1850
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

E
ester.zhou 已提交
1851 1852
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1855 1856
**Parameters**

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

**Example**
W
wusongqing 已提交
1862 1863 1864

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

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



E
ester.zhou 已提交
1877
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1878

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

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

E
ester.zhou 已提交
1883
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1884

E
ester.zhou 已提交
1885 1886
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1889
**Return value**
W
wusongqing 已提交
1890

E
ester.zhou 已提交
1891 1892 1893
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1894

E
ester.zhou 已提交
1895
**Example**
W
wusongqing 已提交
1896 1897 1898

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



E
ester.zhou 已提交
1905
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1906

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

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

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

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

E
ester.zhou 已提交
1915 1916 1917
| Name    | Type                  | Mandatory| Description                  |
| -------- | ---------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1918

E
ester.zhou 已提交
1919
**Example**
W
wusongqing 已提交
1920 1921 1922

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

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



E
ester.zhou 已提交
1935
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1936

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

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

E
ester.zhou 已提交
1941
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1942

E
ester.zhou 已提交
1943
**Return value**
W
wusongqing 已提交
1944

E
ester.zhou 已提交
1945 1946 1947
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1948

E
ester.zhou 已提交
1949
**Example**
W
wusongqing 已提交
1950 1951 1952

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



E
ester.zhou 已提交
1959
## Notification.getActiveNotifications
W
wusongqing 已提交
1960

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

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

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

E
ester.zhou 已提交
1967
**Parameters**
W
wusongqing 已提交
1968

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

E
ester.zhou 已提交
1973
**Example**
W
wusongqing 已提交
1974 1975 1976

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

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



E
ester.zhou 已提交
1989
## Notification.getActiveNotifications
W
wusongqing 已提交
1990

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

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

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

E
ester.zhou 已提交
1997
**Return value**
W
wusongqing 已提交
1998

E
ester.zhou 已提交
1999 2000 2001
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
2002

E
ester.zhou 已提交
2003
**Example**
W
wusongqing 已提交
2004 2005 2006

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



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

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

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

E
ester.zhou 已提交
2019
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2020

E
ester.zhou 已提交
2021
**Parameters**
W
wusongqing 已提交
2022

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

E
ester.zhou 已提交
2028
**Example**
W
wusongqing 已提交
2029 2030 2031

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

var groupName = "GroupName";

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



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

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

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

E
ester.zhou 已提交
2052
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2053

E
ester.zhou 已提交
2054
**Parameters**
W
wusongqing 已提交
2055

E
ester.zhou 已提交
2056 2057 2058
| Name     | Type  | Mandatory| Description          |
| --------- | ------ | ---- | -------------- |
| groupName | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
2059

E
ester.zhou 已提交
2060
**Example**
W
wusongqing 已提交
2061 2062 2063 2064

```js
var groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => {
E
esterzhou 已提交
2065
	console.info("cancelGroup sucess");
W
wusongqing 已提交
2066 2067 2068 2069 2070
});
```



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

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

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

E
ester.zhou 已提交
2077
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2078

E
ester.zhou 已提交
2079 2080
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2083
**Parameters**
W
wusongqing 已提交
2084

E
ester.zhou 已提交
2085 2086 2087 2088 2089
| 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 已提交
2090

E
ester.zhou 已提交
2091
**Example**
W
wusongqing 已提交
2092 2093 2094

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

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

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



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

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

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

E
ester.zhou 已提交
2116
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2117

E
ester.zhou 已提交
2118 2119
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2122
**Parameters**
W
wusongqing 已提交
2123

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

E
ester.zhou 已提交
2129
**Example**
W
wusongqing 已提交
2130 2131 2132 2133 2134

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



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

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

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

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

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

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

E
ester.zhou 已提交
2153
**Parameters**
W
wusongqing 已提交
2154

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

E
ester.zhou 已提交
2160
**Example**
W
wusongqing 已提交
2161 2162 2163

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

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

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



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

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

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

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

E
ester.zhou 已提交
2190 2191
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2194
**Parameters**
W
wusongqing 已提交
2195

E
ester.zhou 已提交
2196 2197 2198
| Name| Type            | Mandatory| Description          |
| ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
2199

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

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


E
ester.zhou 已提交
2214 2215 2216 2217 2218 2219 2220 2221
## 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 已提交
2222 2223
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2226 2227
**Parameters**

E
ester.zhou 已提交
2228 2229 2230 2231 2232
| 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 已提交
2233 2234 2235 2236 2237

**Example**

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

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

E
ester.zhou 已提交
2266 2267
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2270
**Parameters**
W
wusongqing 已提交
2271

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

E
ester.zhou 已提交
2277
**Example**
W
wusongqing 已提交
2278

E
ester.zhou 已提交
2279 2280 2281 2282 2283 2284 2285 2286 2287 2288
```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 已提交
2289
	console.info("setDoNotDisturbDate sucess");
E
ester.zhou 已提交
2290 2291 2292 2293 2294
});
```


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

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

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

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

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

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

E
ester.zhou 已提交
2306 2307
**Parameters**

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

**Example**
W
wusongqing 已提交
2313 2314 2315

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

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



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

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

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

E
ester.zhou 已提交
2334
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2335

E
ester.zhou 已提交
2336 2337
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2340
**Return value**
W
wusongqing 已提交
2341

E
ester.zhou 已提交
2342 2343 2344
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2345

E
ester.zhou 已提交
2346
**Example**
W
wusongqing 已提交
2347 2348 2349

```js
Notification.getDoNotDisturbDate().then((data) => {
E
esterzhou 已提交
2350
	console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data));
W
wusongqing 已提交
2351 2352 2353 2354
});
```


E
ester.zhou 已提交
2355 2356 2357 2358 2359 2360 2361 2362
## 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 已提交
2363 2364 2365 2366
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2367 2368
**Parameters**

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

**Example**

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

var userId = 1

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



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

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

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

E
ester.zhou 已提交
2398
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2399

E
ester.zhou 已提交
2400 2401 2402 2403
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2404
**Parameters**
W
wusongqing 已提交
2405

E
ester.zhou 已提交
2406 2407 2408
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| userId   | number                            | Yes  | User ID.|
W
wusongqing 已提交
2409

E
ester.zhou 已提交
2410
**Return value**
W
wusongqing 已提交
2411

E
ester.zhou 已提交
2412 2413 2414
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2415

E
ester.zhou 已提交
2416 2417 2418 2419 2420 2421
**Example**

```js
var userId = 1

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


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

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

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

E
ester.zhou 已提交
2441 2442 2443
| Name    | Type                    | Mandatory| Description                            |
| -------- | ------------------------ | ---- | -------------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2444 2445

**Example**
W
wusongqing 已提交
2446 2447 2448

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

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



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

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

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

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

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

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

E
ester.zhou 已提交
2473
**Return value**
W
wusongqing 已提交
2474

E
ester.zhou 已提交
2475 2476 2477
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2478

E
ester.zhou 已提交
2479
**Example**
W
wusongqing 已提交
2480 2481 2482

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



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

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

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

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

E
ester.zhou 已提交
2497 2498 2499
**Parameters**

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

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

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

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



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

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

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

E
ester.zhou 已提交
2527
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2528

E
ester.zhou 已提交
2529 2530 2531
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2532
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2533
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2534

E
ester.zhou 已提交
2535
**Return value**
W
wusongqing 已提交
2536

E
ester.zhou 已提交
2537
| Type              | Description           |
W
wusongqing 已提交
2538 2539 2540
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2541
**Example**
W
wusongqing 已提交
2542 2543 2544 2545 2546

```javascript
var templateName = 'process';

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



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

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

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

E
ester.zhou 已提交
2559
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2560

E
ester.zhou 已提交
2561
**Parameters**
W
wusongqing 已提交
2562

E
ester.zhou 已提交
2563 2564 2565
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2566

E
ester.zhou 已提交
2567
**Example**
W
wusongqing 已提交
2568

E
ester.zhou 已提交
2569
```javascript
E
ester.zhou 已提交
2570
function requestEnableNotificationCallback() {
E
esterzhou 已提交
2571 2572 2573 2574 2575
    if (err.code) {
        console.info("requestEnableNotification failed " + JSON.stringify(err));
    } else {
        console.info("requestEnableNotification success");
    }
E
ester.zhou 已提交
2576 2577
};

E
ester.zhou 已提交
2578
Notification.requestEnableNotification(requestEnableNotificationCallback);
W
wusongqing 已提交
2579 2580 2581 2582
```



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

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

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

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

E
ester.zhou 已提交
2591
**Example**
W
wusongqing 已提交
2592

E
ester.zhou 已提交
2593 2594 2595
```javascript
Notification.requestEnableNotification()
    .then(() => {
E
esterzhou 已提交
2596
        console.info("requestEnableNotification sucess");
E
ester.zhou 已提交
2597 2598
	});
```
W
wusongqing 已提交
2599 2600


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

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

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

E
ester.zhou 已提交
2607
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2608

E
ester.zhou 已提交
2609 2610
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2613
**Parameters**
W
wusongqing 已提交
2614

E
ester.zhou 已提交
2615 2616 2617 2618
| 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 已提交
2619

E
ester.zhou 已提交
2620
**Example**
W
wusongqing 已提交
2621

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

E
ester.zhou 已提交
2631
var enable = true
W
wusongqing 已提交
2632

E
ester.zhou 已提交
2633
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2634 2635 2636 2637
```



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

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

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

E
ester.zhou 已提交
2644
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2645

E
ester.zhou 已提交
2646 2647
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2650
**Parameters**
W
wusongqing 已提交
2651

E
ester.zhou 已提交
2652 2653 2654
| 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 已提交
2655

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

E
ester.zhou 已提交
2658 2659
```javascript
var enable = true
W
wusongqing 已提交
2660

E
ester.zhou 已提交
2661 2662
Notification.enableDistributed(enable)
    .then(() => {
E
esterzhou 已提交
2663
        console.info("enableDistributed sucess");
E
ester.zhou 已提交
2664 2665
    });
```
W
wusongqing 已提交
2666 2667


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

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

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

E
ester.zhou 已提交
2674
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2675

E
ester.zhou 已提交
2676
**Parameters**
W
wusongqing 已提交
2677

E
ester.zhou 已提交
2678 2679 2680
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2681

E
ester.zhou 已提交
2682
**Example**
W
wusongqing 已提交
2683

E
ester.zhou 已提交
2684 2685
```javascript
function isDistributedEnabledCallback() {
E
esterzhou 已提交
2686 2687 2688 2689 2690
    if (err.code) {
        console.info("isDistributedEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isDistributedEnabled success");
    }
E
ester.zhou 已提交
2691
};
W
wusongqing 已提交
2692

E
ester.zhou 已提交
2693
Notification.isDistributedEnabled(isDistributedEnabledCallback);
E
ester.zhou 已提交
2694
```
W
wusongqing 已提交
2695 2696 2697



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

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

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

E
ester.zhou 已提交
2704
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2705

E
ester.zhou 已提交
2706
**Return value**
W
wusongqing 已提交
2707

E
ester.zhou 已提交
2708 2709 2710
| 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 已提交
2711

E
ester.zhou 已提交
2712 2713 2714 2715 2716
**Example**

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


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

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

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

E
ester.zhou 已提交
2728
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2729

E
ester.zhou 已提交
2730 2731
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2734
**Parameters**
W
wusongqing 已提交
2735

E
ester.zhou 已提交
2736 2737 2738 2739 2740
| 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 已提交
2741

E
ester.zhou 已提交
2742
**Example**
W
wusongqing 已提交
2743

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

E
ester.zhou 已提交
2753 2754 2755
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2756

E
ester.zhou 已提交
2757
var enable = true
W
wusongqing 已提交
2758

E
ester.zhou 已提交
2759 2760
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2761 2762


E
ester.zhou 已提交
2763 2764 2765

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

E
ester.zhou 已提交
2766
enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
E
ester.zhou 已提交
2767 2768 2769 2770 2771

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

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

E
ester.zhou 已提交
2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787
**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 已提交
2788 2789
}

E
ester.zhou 已提交
2790
var enable = true
W
wusongqing 已提交
2791

E
ester.zhou 已提交
2792 2793
Notification.enableDistributedByBundle(bundle, enable)
    .then(() => {
E
esterzhou 已提交
2794
        console.info("enableDistributedByBundle sucess");
E
ester.zhou 已提交
2795
    });
W
wusongqing 已提交
2796 2797
```

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

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

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

E
ester.zhou 已提交
2804
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2805

E
ester.zhou 已提交
2806 2807
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2810
**Parameters**
W
wusongqing 已提交
2811

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

E
ester.zhou 已提交
2817
**Example**
W
wusongqing 已提交
2818

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

E
ester.zhou 已提交
2828 2829 2830
var bundle = {
    bundle: "bundleName1",
}
W
wusongqing 已提交
2831

E
ester.zhou 已提交
2832
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
ester.zhou 已提交
2833
```
W
wusongqing 已提交
2834 2835 2836



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

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

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

E
ester.zhou 已提交
2843 2844
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2845 2846
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

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


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

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

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

E
ester.zhou 已提交
2881
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2882

E
ester.zhou 已提交
2883 2884
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2887
**Parameters**
W
wusongqing 已提交
2888

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

E
ester.zhou 已提交
2893
**Example**
W
wusongqing 已提交
2894

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

E
ester.zhou 已提交
2904 2905
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2906 2907 2908



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

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

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

E
ester.zhou 已提交
2915 2916
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2917 2918
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931
**Return value**

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

**Example**

```javascript
Notification.getDeviceRemindType()
    .then((data) => {
E
esterzhou 已提交
2932
        console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data));
E
ester.zhou 已提交
2933
    });
W
wusongqing 已提交
2934 2935
```

E
ester.zhou 已提交
2936

E
ester.zhou 已提交
2937 2938 2939 2940 2941 2942 2943 2944
## 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 已提交
2945 2946
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2947 2948 2949 2950 2951 2952
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**

| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
2953
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
2954 2955 2956 2957 2958 2959 2960 2961 2962
| 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 已提交
2963 2964 2965 2966 2967
    if (err.code) {
        console.info("publishAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("publishAsBundle success");
    }
E
ester.zhou 已提交
2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996
}
// 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 已提交
2997 2998
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

E
ester.zhou 已提交
2999 3000 3001 3002 3003 3004 3005
**System API**: This is a system API and cannot be called by third-party applications.

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
ester.zhou 已提交
3006
| request              | [NotificationRequest](#notificationrequest) | Yes  | **NotificationRequest** object.|
E
ester.zhou 已提交
3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030
| 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 已提交
3031
	console.info("publishAsBundle sucess");
E
ester.zhou 已提交
3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042
});
```

## 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 已提交
3043 3044
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3045 3046
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

E
ester.zhou 已提交
3049
**Parameters**
E
ester.zhou 已提交
3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062

| 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 已提交
3063 3064 3065 3066 3067
    if (err.code) {
        console.info("cancelAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("cancelAsBundle success");
    }
E
ester.zhou 已提交
3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084
}
// 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 已提交
3085 3086
**System API**: This is a system API and cannot be called by third-party applications.

E
ester.zhou 已提交
3087 3088
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

E
ester.zhou 已提交
3091
**Parameters**
E
ester.zhou 已提交
3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107

| 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 已提交
3108
	console.info("cancelAsBundle success");
E
ester.zhou 已提交
3109 3110 3111
});
```

E
ester.zhou 已提交
3112
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
3113

E
ester.zhou 已提交
3114
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
3115 3116 3117 3118 3119 3120 3121

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

E
ester.zhou 已提交
3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137
**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 已提交
3138 3139 3140 3141 3142
    if (err.code) {
        console.info("enableNotificationSlot failed " + JSON.stringify(err));
    } else {
        console.info("enableNotificationSlot success");
    }
E
ester.zhou 已提交
3143 3144 3145 3146
};

Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3147
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3148 3149 3150 3151
    true,
    enableSlotCallback);
```

E
ester.zhou 已提交
3152
## Notification.enableNotificationSlot <sup>9+</sup>
E
ester.zhou 已提交
3153

E
ester.zhou 已提交
3154
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> 
E
ester.zhou 已提交
3155 3156 3157 3158 3159 3160 3161

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

E
ester.zhou 已提交
3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177
**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 已提交
3178
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3179
    true).then(() => {
E
esterzhou 已提交
3180
        console.info("enableNotificationSlot sucess");
E
ester.zhou 已提交
3181 3182 3183
    });
```

E
ester.zhou 已提交
3184
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3185

E
ester.zhou 已提交
3186
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
E
ester.zhou 已提交
3187

E
ester.zhou 已提交
3188
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 已提交
3189 3190 3191 3192 3193

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

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

E
ester.zhou 已提交
3194 3195
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3196 3197 3198 3199 3200 3201
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information.          |
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
3202
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3203 3204 3205 3206 3207 3208

**Example**

```js
//isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
E
esterzhou 已提交
3209 3210 3211 3212 3213
    if (err.code) {
        console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationSlotEnabled success");
    }
E
ester.zhou 已提交
3214 3215 3216 3217
};

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3218
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3219 3220 3221
    getEnableSlotCallback);
```

E
ester.zhou 已提交
3222
## Notification.isNotificationSlotEnabled <sup>9+</sup>
E
ester.zhou 已提交
3223

E
ester.zhou 已提交
3224
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>  
E
ester.zhou 已提交
3225

E
ester.zhou 已提交
3226
Obtains the enabled status of the notification slot of a specified type. This API uses a promise to return the result.
E
ester.zhou 已提交
3227 3228 3229 3230 3231

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

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

E
ester.zhou 已提交
3232 3233
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3234 3235 3236 3237 3238 3239 3240
**Parameters**

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

E
ester.zhou 已提交
3241 3242 3243 3244 3245 3246
**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the enabled status of the notification slot of the specified type.|

E
ester.zhou 已提交
3247 3248 3249 3250 3251 3252
**Example**

```js
//isNotificationSlotEnabled
Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3253 3254
    Notification.SlotType.SOCIAL_COMMUNICATION
    ).then((data) => {
E
esterzhou 已提交
3255
      console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
E
ester.zhou 已提交
3256 3257 3258
    });
```

E
ester.zhou 已提交
3259

E
ester.zhou 已提交
3260
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3261

E
ester.zhou 已提交
3262
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
E
ester.zhou 已提交
3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276

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 已提交
3277 3278
| 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 已提交
3279 3280 3281 3282 3283 3284 3285

**Example**

```js
let userId = 100;
let enable = true;

E
ester.zhou 已提交
3286
function setSyncNotificationEnabledWithoutAppCallback(err) {
E
esterzhou 已提交
3287 3288 3289 3290 3291
    if (err.code) {
        console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
    } else {
        console.info("setSyncNotificationEnabledWithoutApp success");
    }
E
ester.zhou 已提交
3292 3293
}

E
ester.zhou 已提交
3294
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3295 3296 3297
```


E
ester.zhou 已提交
3298
## Notification.setSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3299

E
ester.zhou 已提交
3300
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
E
ester.zhou 已提交
3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314

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 已提交
3315 3316 3317 3318 3319 3320 3321
| 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 已提交
3322 3323 3324 3325 3326 3327 3328

**Example**

```js
let userId = 100;
let enable = true;

E
ester.zhou 已提交
3329
Notification.setSyncNotificationEnabledWithoutApp(userId, enable)
E
esterzhou 已提交
3330 3331
    .then(() => {
        console.info('setSyncNotificationEnabledWithoutApp');
E
ester.zhou 已提交
3332 3333
    })
    .catch((err) => {
E
esterzhou 已提交
3334
        console.info('setSyncNotificationEnabledWithoutApp, err:', err);
E
ester.zhou 已提交
3335 3336 3337 3338
    });
```


E
ester.zhou 已提交
3339
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3340

E
ester.zhou 已提交
3341
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
E
ester.zhou 已提交
3342

E
ester.zhou 已提交
3343
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 已提交
3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355

**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 已提交
3356
| 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 已提交
3357 3358 3359 3360 3361 3362

**Example**

```js
let userId = 100;

E
ester.zhou 已提交
3363 3364
function getSyncNotificationEnabledWithoutAppCallback(data, err) {
    if (err) {
E
esterzhou 已提交
3365
        console.info('getSyncNotificationEnabledWithoutAppCallback, err' + err);
E
ester.zhou 已提交
3366
    } else {
E
esterzhou 已提交
3367
        console.info('getSyncNotificationEnabledWithoutAppCallback, data' + data);
E
ester.zhou 已提交
3368
    }
E
ester.zhou 已提交
3369 3370
}

E
ester.zhou 已提交
3371
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3372 3373 3374
```


E
ester.zhou 已提交
3375
## Notification.getSyncNotificationEnabledWithoutApp<sup>9+</sup>
E
ester.zhou 已提交
3376

E
ester.zhou 已提交
3377
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
E
ester.zhou 已提交
3378

E
ester.zhou 已提交
3379
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 已提交
3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396

**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 已提交
3397
| 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 已提交
3398 3399 3400 3401 3402 3403

**Example**

```js
let userId = 100;

E
ester.zhou 已提交
3404
Notification.getSyncNotificationEnabledWithoutApp(userId)
E
ester.zhou 已提交
3405
    .then((data) => {
E
esterzhou 已提交
3406
        console.info('getSyncNotificationEnabledWithoutApp, data:', data);
E
ester.zhou 已提交
3407 3408
    })
    .catch((err) => {
E
esterzhou 已提交
3409
        console.info('getSyncNotificationEnabledWithoutApp, err:', err);
E
ester.zhou 已提交
3410 3411 3412 3413 3414
    });
```



E
ester.zhou 已提交
3415 3416
## NotificationSubscriber

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

E
ester.zhou 已提交
3419 3420
### onConsume

E
ester.zhou 已提交
3421
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3422

E
ester.zhou 已提交
3423
Callback for receiving notifications.
W
wusongqing 已提交
3424

E
ester.zhou 已提交
3425 3426
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444
**Parameters**

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

**Example**

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

E
ester.zhou 已提交
3446 3447 3448 3449 3450 3451 3452
function onConsumeCallback(data) {
    console.info('===> onConsume in test');
    let req = data.request;
    console.info('===> onConsume callback req.id:' + req.id);
    let wantAgent = data.wantAgent;
    wantAgent .getWant(wantAgent)
        .then((data1) => {
E
esterzhou 已提交
3453
            console.info('===> getWant success want:' + JSON.stringify(data1));
E
ester.zhou 已提交
3454 3455
        })
        .catch((err) => {
E
ester.zhou 已提交
3456
            console.error('===> getWant failed because' + JSON.stringify(err));
E
ester.zhou 已提交
3457
        });
E
ester.zhou 已提交
3458
    console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
E
ester.zhou 已提交
3459
};
W
wusongqing 已提交
3460

E
ester.zhou 已提交
3461 3462 3463
var subscriber = {
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
3464

E
ester.zhou 已提交
3465 3466
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3467

E
ester.zhou 已提交
3468
### onCancel
W
wusongqing 已提交
3469

E
ester.zhou 已提交
3470
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
W
wusongqing 已提交
3471

E
ester.zhou 已提交
3472
Callback for removing notifications.
W
wusongqing 已提交
3473

E
ester.zhou 已提交
3474
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3475

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

E
ester.zhou 已提交
3478
**Parameters**
W
wusongqing 已提交
3479

E
ester.zhou 已提交
3480 3481 3482
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.|
W
wusongqing 已提交
3483

E
ester.zhou 已提交
3484
**Example**
W
wusongqing 已提交
3485

E
ester.zhou 已提交
3486 3487 3488 3489
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3490
    } else {
E
ester.zhou 已提交
3491
        console.info("subscribeCallback");
W
wusongqing 已提交
3492
    }
E
ester.zhou 已提交
3493 3494 3495 3496 3497 3498
};

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

E
ester.zhou 已提交
3501 3502 3503
var subscriber = {
    onCancel: onCancelCallback
};
W
wusongqing 已提交
3504

E
ester.zhou 已提交
3505
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3506 3507
```

E
ester.zhou 已提交
3508
### onUpdate
W
wusongqing 已提交
3509

E
ester.zhou 已提交
3510
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
W
wusongqing 已提交
3511

E
ester.zhou 已提交
3512
Callback for notification sorting updates.
W
wusongqing 已提交
3513

E
ester.zhou 已提交
3514
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3515

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

E
ester.zhou 已提交
3518
**Parameters**
W
wusongqing 已提交
3519

E
ester.zhou 已提交
3520 3521 3522
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.|
W
wusongqing 已提交
3523

E
ester.zhou 已提交
3524
**Example**
W
wusongqing 已提交
3525

E
ester.zhou 已提交
3526 3527 3528 3529 3530 3531 3532 3533
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3534

E
ester.zhou 已提交
3535 3536 3537
function onUpdateCallback() {
    console.info('===> onUpdate in test');
}
W
wusongqing 已提交
3538

E
ester.zhou 已提交
3539 3540 3541
var subscriber = {
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
3542

E
ester.zhou 已提交
3543 3544
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3545

E
ester.zhou 已提交
3546
### onConnect
W
wusongqing 已提交
3547

E
ester.zhou 已提交
3548
onConnect?:() => void
W
wusongqing 已提交
3549

E
ester.zhou 已提交
3550 3551 3552 3553
Callback for subscription.

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

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

E
ester.zhou 已提交
3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568
**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 已提交
3569 3570
}

E
ester.zhou 已提交
3571 3572 3573
var subscriber = {
    onConnect: onConnectCallback
};
W
wusongqing 已提交
3574

E
ester.zhou 已提交
3575
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3576 3577
```

E
ester.zhou 已提交
3578
### onDisconnect
W
wusongqing 已提交
3579

E
ester.zhou 已提交
3580
onDisconnect?:() => void
W
wusongqing 已提交
3581

E
ester.zhou 已提交
3582
Callback for unsubscription.
W
wusongqing 已提交
3583

E
ester.zhou 已提交
3584
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3585

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

E
ester.zhou 已提交
3588
**Example**
W
wusongqing 已提交
3589

E
ester.zhou 已提交
3590 3591 3592 3593 3594 3595 3596 3597
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3598

E
ester.zhou 已提交
3599 3600 3601
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
3602

E
ester.zhou 已提交
3603 3604 3605
var subscriber = {
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
3606

E
ester.zhou 已提交
3607 3608
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3609

E
ester.zhou 已提交
3610
### onDestroy
W
wusongqing 已提交
3611

E
ester.zhou 已提交
3612
onDestroy?:() => void
W
wusongqing 已提交
3613

E
ester.zhou 已提交
3614
Callback for service disconnection.
W
wusongqing 已提交
3615

E
ester.zhou 已提交
3616
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3617

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

E
ester.zhou 已提交
3620 3621 3622 3623 3624 3625
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3626
    } else {
E
ester.zhou 已提交
3627
        console.info("subscribeCallback");
W
wusongqing 已提交
3628
    }
E
ester.zhou 已提交
3629 3630 3631 3632
};

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

E
ester.zhou 已提交
3635 3636 3637
var subscriber = {
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
3638

E
ester.zhou 已提交
3639
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3640 3641
```

E
ester.zhou 已提交
3642 3643
### onDoNotDisturbDateChange<sup>8+</sup>

E
ester.zhou 已提交
3644
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
E
ester.zhou 已提交
3645 3646 3647 3648 3649

Callback for DND time setting updates.

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

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

E
ester.zhou 已提交
3652 3653 3654 3655
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3656
| mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
E
ester.zhou 已提交
3657 3658 3659 3660 3661 3662 3663 3664 3665 3666

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

E
ester.zhou 已提交
3668 3669 3670
function onDoNotDisturbDateChangeCallback() {
    console.info('===> onDoNotDisturbDateChange in test');
}
W
wusongqing 已提交
3671

E
ester.zhou 已提交
3672 3673 3674
var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
W
wusongqing 已提交
3675

E
ester.zhou 已提交
3676 3677
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3678 3679


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

E
ester.zhou 已提交
3682
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) => void
W
wusongqing 已提交
3683

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

E
ester.zhou 已提交
3686
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3687

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

E
ester.zhou 已提交
3690
**Parameters**
W
wusongqing 已提交
3691

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

E
ester.zhou 已提交
3696
**Example**
W
wusongqing 已提交
3697

E
ester.zhou 已提交
3698 3699 3700 3701 3702 3703 3704 3705
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3706

E
ester.zhou 已提交
3707 3708 3709 3710
function onEnabledNotificationChangedCallback(callbackData) {
    console.info("bundle: ", callbackData.bundle);
    console.info("uid: ", callbackData.uid);
    console.info("enable: ", callbackData.enable);
E
ester.zhou 已提交
3711
};
W
wusongqing 已提交
3712

E
ester.zhou 已提交
3713 3714 3715
var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
W
wusongqing 已提交
3716

E
ester.zhou 已提交
3717
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3718 3719
```

E
ester.zhou 已提交
3720
## SubscribeCallbackData
W
wusongqing 已提交
3721

E
ester.zhou 已提交
3722
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3723

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

E
ester.zhou 已提交
3726 3727 3728 3729 3730 3731 3732
| Name           | Readable| Writable| Type                                             | Description    |
| --------------- | ---- | --- | ------------------------------------------------- | -------- |
| request         | Yes | No | [NotificationRequest](#notificationrequest)       | Notification content.|
| sortingMap      | Yes | No | [NotificationSortingMap](#notificationsortingmap) | Notification sorting information.|
| reason          | Yes | No | number                                            | Reason for deletion.|
| sound           | Yes | No | string                                            | Sound used for notification.|
| vibrationValues | Yes | No | Array\<number\>                                   | Vibration used for notification.|
W
wusongqing 已提交
3733 3734


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

E
ester.zhou 已提交
3737
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3738

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

E
ester.zhou 已提交
3741 3742 3743 3744 3745
| Name  | Readable| Writable| Type   | Description            |
| ------ | ---- | --- | ------- | ---------------- |
| bundle | Yes | No | string  | Bundle name of the application.      |
| uid    | Yes | No | number  | UID of the application.       |
| enable | Yes | No | boolean | Notification enabled status of the application.|
W
wusongqing 已提交
3746 3747


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

E
ester.zhou 已提交
3750
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3751

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

E
ester.zhou 已提交
3754 3755 3756 3757 3758
| Name | Readable| Writable| Type                                 | Description                    |
| ----- | ---- | --- | ------------------------------------- | ------------------------ |
| type  | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.|
| begin | Yes | No | Date                                  | DND start time.|
| end   | Yes | No | Date                                  | DND end time.|
W
wusongqing 已提交
3759 3760 3761



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

E
ester.zhou 已提交
3764
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3765

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

E
ester.zhou 已提交
3768 3769
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
E
ester.zhou 已提交
3770 3771 3772 3773
| 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 已提交
3774 3775


E
ester.zhou 已提交
3776
## ContentType
W
wusongqing 已提交
3777

E
ester.zhou 已提交
3778
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3779

E
ester.zhou 已提交
3780 3781
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3782 3783 3784 3785 3786
| 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 已提交
3787

E
ester.zhou 已提交
3788
## SlotLevel
W
wusongqing 已提交
3789

E
ester.zhou 已提交
3790
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3791

E
ester.zhou 已提交
3792 3793
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3794 3795 3796
| 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 已提交
3797 3798
| 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 已提交
3799 3800


E
ester.zhou 已提交
3801
## BundleOption
W
wusongqing 已提交
3802

E
ester.zhou 已提交
3803
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3804

E
ester.zhou 已提交
3805 3806 3807 3808
| Name  | Readable| Writable| Type  | Description  |
| ------ | ---- | --- | ------ | ------ |
| bundle | Yes | Yes | string | Bundle name.  |
| uid    | Yes | Yes | number | User ID.|
W
wusongqing 已提交
3809 3810 3811



E
ester.zhou 已提交
3812
## NotificationKey
W
wusongqing 已提交
3813

E
ester.zhou 已提交
3814
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3815

E
ester.zhou 已提交
3816 3817 3818 3819
| Name | Readable| Writable| Type  | Description    |
| ----- | ---- | --- | ------ | -------- |
| id    | Yes | Yes | number | Notification ID.  |
| label | Yes | Yes | string | Notification label.|
W
wusongqing 已提交
3820 3821


E
ester.zhou 已提交
3822
## SlotType
W
wusongqing 已提交
3823

E
ester.zhou 已提交
3824
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3825

E
ester.zhou 已提交
3826 3827
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
E
ester.zhou 已提交
3828 3829 3830 3831 3832
| 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 已提交
3833 3834


E
ester.zhou 已提交
3835
## NotificationActionButton
W
wusongqing 已提交
3836

E
ester.zhou 已提交
3837
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3838

E
ester.zhou 已提交
3839 3840 3841 3842 3843 3844
| Name     | Readable| Writable| Type                                           | Description                     |
| --------- | --- | ---- | ----------------------------------------------- | ------------------------- |
| title     | Yes | Yes | string                                          | Button title.                 |
| wantAgent | Yes | Yes | WantAgent                                       | **WantAgent** of the button.|
| extras    | Yes | Yes | { [key: string]: any }                          | Extra information of the button.             |
| userInput<sup>8+</sup> | Yes | Yes | [NotificationUserInput](#notificationuserinput8) | User input object.         |
W
wusongqing 已提交
3845 3846


E
ester.zhou 已提交
3847
## NotificationBasicContent
W
wusongqing 已提交
3848

E
ester.zhou 已提交
3849
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3850

E
ester.zhou 已提交
3851 3852 3853 3854 3855
| Name          | Readable| Writable| Type  | Description                              |
| -------------- | ---- | ---- | ------ | ---------------------------------- |
| title          | Yes  | Yes  | string | Notification title.                        |
| text           | Yes  | Yes  | string | Notification content.                        |
| additionalText | Yes  | Yes  | string | Additional information of the notification.|
W
wusongqing 已提交
3856 3857


E
ester.zhou 已提交
3858
## NotificationLongTextContent
W
wusongqing 已提交
3859

E
ester.zhou 已提交
3860
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3861

E
ester.zhou 已提交
3862 3863 3864 3865 3866 3867 3868 3869
| Name          | Readable| Writable| Type  | Description                            |
| -------------- | ---- | --- | ------ | -------------------------------- |
| title          | Yes | Yes | string | Notification title.                        |
| text           | Yes | Yes | string | Notification content.                        |
| additionalText | Yes | Yes | string | Additional information of the notification.|
| longText       | Yes | Yes | string | Long text of the notification.                    |
| briefText      | Yes | Yes | string | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string | Title of the notification in the expanded state.                |
W
wusongqing 已提交
3870 3871


E
ester.zhou 已提交
3872 3873 3874 3875
## NotificationMultiLineContent

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

E
ester.zhou 已提交
3876 3877 3878 3879 3880 3881 3882 3883
| Name          | Readable| Writable| Type           | Description                            |
| -------------- | --- | --- | --------------- | -------------------------------- |
| title          | Yes | Yes | string          | Notification title.                        |
| text           | Yes | Yes | string          | Notification content.                        |
| additionalText | Yes | Yes | string          | Additional information of the notification.|
| briefText      | Yes | Yes | string          | Brief text of the notification.|
| longTitle      | Yes | Yes | string          | Title of the notification in the expanded state.                |
| lines          | Yes | Yes | Array\<string\> | Multi-line text of the notification.                  |
E
ester.zhou 已提交
3884 3885 3886 3887 3888 3889


## NotificationPictureContent

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

E
ester.zhou 已提交
3890 3891 3892 3893 3894 3895 3896 3897
| Name          | Readable| Writable| Type          | Description                            |
| -------------- | ---- | --- | -------------- | -------------------------------- |
| title          | Yes | Yes | string         | Notification title.                        |
| text           | Yes | Yes | string         | Notification content.                        |
| additionalText | Yes | Yes | string         | Additional information of the notification.|
| briefText      | Yes | Yes | string         | Brief text of the notification.|
| expandedTitle  | Yes | Yes | string         | Title of the notification in the expanded state.                |
| picture        | Yes | Yes | image.PixelMap | Picture attached to the notification.                  |
E
ester.zhou 已提交
3898 3899 3900 3901 3902 3903


## NotificationContent

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

E
ester.zhou 已提交
3904 3905 3906 3907 3908 3909 3910
| Name       | Readable| Writable| Type                                                        | Description              |
| ----------- | ---- | --- | ------------------------------------------------------------ | ------------------ |
| contentType | Yes | Yes | [ContentType](#contenttype)                                  | Notification content type.      |
| normal      | Yes | Yes | [NotificationBasicContent](#notificationbasiccontent)        | Normal text.  |
| longText    | Yes | Yes | [NotificationLongTextContent](#notificationlongtextcontent)  | Long text.|
| multiLine   | Yes | Yes | [NotificationMultiLineContent](#notificationmultilinecontent) | Multi-line text.  |
| picture     | Yes | Yes | [NotificationPictureContent](#notificationpicturecontent)    | Picture-attached.  |
E
ester.zhou 已提交
3911 3912 3913 3914 3915 3916


## NotificationFlagStatus<sup>8+</sup>

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

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

E
ester.zhou 已提交
3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929
| Name          | Value | Description                              |
| -------------- | --- | --------------------------------- |
| TYPE_NONE      | 0   | The default flag is used.                        |
| TYPE_OPEN      | 1   | The notification flag is enabled.                    |
| TYPE_CLOSE     | 2   | The notification flag is disabled.                    |


## NotificationFlags<sup>8+</sup>

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

E
ester.zhou 已提交
3930 3931 3932 3933
| Name            | Readable| Writable| Type                   | Description                              |
| ---------------- | ---- | ---- | ---------------------- | --------------------------------- |
| soundEnabled     | Yes  | No  | NotificationFlagStatus | Whether to enable the sound alert for the notification.                 |
| vibrationEnabled | Yes  | No  | NotificationFlagStatus | Whether to enable vibration for the notification.              |
E
ester.zhou 已提交
3934 3935 3936 3937 3938 3939


## NotificationRequest

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

E
ester.zhou 已提交
3940 3941 3942 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
| Name                 | Readable| Writable| Type                                         | Description                      |
| --------------------- | ---- | --- | --------------------------------------------- | -------------------------- |
| content               | Yes | Yes | [NotificationContent](#notificationcontent)   | Notification content.                  |
| id                    | Yes | Yes | number                                        | Notification ID.                    |
| slotType              | Yes | Yes | [SlotType](#slottype)                         | Slot type.                  |
| isOngoing             | Yes | Yes | boolean                                       | Whether the notification is an ongoing notification.            |
| isUnremovable         | Yes | Yes | boolean                                       | Whether the notification can be removed.                |
| deliveryTime          | Yes | Yes | number                                        | Time when the notification is sent.              |
| tapDismissed          | Yes | Yes | boolean                                       | Whether the notification is automatically cleared.          |
| autoDeletedTime       | Yes | Yes | number                                        | Time when the notification is automatically cleared.            |
| wantAgent             | Yes | Yes | WantAgent                                     | **WantAgent** instance to which the notification will be redirected after being clicked.       |
| extraInfo             | Yes | Yes | {[key: string]: any}                          | Extended parameters.                  |
| color                 | Yes | Yes | number                                        | Background color of the notification.              |
| colorEnabled          | Yes | Yes | boolean                                       | Whether the notification background color is enabled.      |
| isAlertOnce           | Yes | Yes | boolean                                       | Whether the notification triggers an alert only once.|
| isStopwatch           | Yes | Yes | boolean                                       | Whether to display the stopwatch.          |
| isCountDown           | Yes | Yes | boolean                                       | Whether to display the countdown time.        |
| isFloatingIcon        | Yes | Yes | boolean                                       | Whether the notification is displayed as a floating icon.        |
| label                 | Yes | Yes | string                                        | Notification label.                  |
| badgeIconStyle        | Yes | Yes | number                                        | Notification badge type.              |
| showDeliveryTime      | Yes | Yes | boolean                                       | Whether to display the time when the notification is delivered.          |
| actionButtons         | Yes | Yes | Array\<[NotificationActionButton](#notificationactionbutton)\>             | Buttons in the notification. Up to two buttons are allowed.    |
| smallIcon             | Yes | Yes | PixelMap                                      | Small notification icon.                |
| largeIcon             | Yes | Yes | PixelMap                                      | Large notification icon.                |
| creatorBundleName     | Yes | No | string                                        | Name of the bundle that creates the notification.            |
| creatorUid            | Yes | No | number                                        | UID used for creating the notification.             |
| creatorPid            | Yes | No | number                                        | PID used for creating the notification.             |
| creatorUserId<sup>8+</sup>| Yes | No | number                                    | ID of the user who creates the notification.          |
| hashCode              | Yes | No | string                                        | Unique ID of the notification.              |
| classification        | Yes | Yes | string                                        | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| groupName<sup>8+</sup>| Yes | Yes | string                                        | Group notification name.                |
| template<sup>8+</sup> | Yes | Yes | [NotificationTemplate](#notificationtemplate8) | Notification template.                  |
| isRemoveAllowed<sup>8+</sup> | Yes | No | boolean                                | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| source<sup>8+</sup>   | Yes | No | number                                        | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| distributedOption<sup>8+</sup>   | Yes | Yes | [DistributedOptions](#distributedoptions8)                 | Option of distributed notification.         |
| deviceId<sup>8+</sup> | Yes | No | string                                        | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.         |
| notificationFlags<sup>8+</sup> | Yes | No | [NotificationFlags](#notificationflags8)                    | Notification flags.         |
| removalWantAgent<sup>9+</sup> | Yes | Yes | WantAgent                    | **WantAgent** instance to which the notification will be redirected when it is removed.         |
| badgeNumber<sup>9+</sup> | Yes | Yes | number                    | Number of notifications displayed on the application icon.         |
E
ester.zhou 已提交
3979 3980 3981 3982 3983 3984


## DistributedOptions<sup>8+</sup>

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

E
ester.zhou 已提交
3985 3986 3987 3988 3989 3990
| Name                  | Readable| Writable| Type           | Description                              |
| ---------------------- | ---- | ---- | -------------- | ---------------------------------- |
| isDistributed          | Yes  | Yes  | boolean        | Whether the notification is a distributed notification.                 |
| supportDisplayDevices  | Yes  | Yes  | Array\<string> | Types of the devices to which the notification can be synchronized.          |
| supportOperateDevices  | Yes  | Yes  | Array\<string> | Devices on which notification can be enabled.               |
| remindType             | Yes  | No  | number         | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications.                   |
E
ester.zhou 已提交
3991 3992 3993 3994 3995 3996


## NotificationSlot

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

E
ester.zhou 已提交
3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010
| Name                | Readable| Writable| Type                 | Description                                      |
| -------------------- | ---- | --- | --------------------- | ------------------------------------------ |
| type                 | Yes | Yes | [SlotType](#slottype) | Slot type.                                  |
| level                | Yes | Yes | number                | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc                 | Yes | Yes | string                | Notification slot description.                          |
| badgeFlag            | Yes | Yes | boolean               | Whether to display the badge.                              |
| bypassDnd            | Yes | Yes | boolean               | Whether to bypass the DND mode in the system.              |
| lockscreenVisibility | Yes | Yes | number                | Mode for displaying the notification on the lock screen.                |
| vibrationEnabled     | Yes | Yes | boolean               | Whether vibration is supported for the notification.                                |
| sound                | Yes | Yes | string                | Notification alert tone.                                |
| lightEnabled         | Yes | Yes | boolean               | Whether the indicator blinks for the notification.                                  |
| lightColor           | Yes | Yes | number                | Indicator color of the notification.                                |
| vibrationValues      | Yes | Yes | Array\<number\>       | Vibration mode of the notification.                              |
| enabled<sup>9+</sup> | Yes | No | boolean               | Enabled status of the notification slot.                     |
E
ester.zhou 已提交
4011 4012 4013 4014 4015 4016


## NotificationSorting

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

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

E
ester.zhou 已提交
4019 4020 4021 4022 4023
| Name    | Readable| Writable| Type                                 | Description        |
| -------- | ---- | --- | ------------------------------------- | ------------ |
| slot     | Yes | No | [NotificationSlot](#notificationslot) | Notification slot content.|
| hashCode | Yes | No | string                                | Unique ID of the notification.|
| ranking  | Yes | No | number                                | Notification sequence number.|
E
ester.zhou 已提交
4024 4025 4026 4027 4028 4029


## NotificationSortingMap

**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
ester.zhou 已提交
4032 4033 4034 4035
| Name          | Readable| Writable| Type                                                        | Description            |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---------------- |
| sortings       | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Array of notification sorting information.|
| sortedHashCode | Yes | No | Array\<string\>                                              | Array of unique notification IDs.|
E
ester.zhou 已提交
4036 4037 4038 4039 4040 4041


## NotificationSubscribeInfo

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

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

E
ester.zhou 已提交
4044 4045 4046 4047
| Name       | Readable| Writable| Type           | Description                           |
| ----------- | --- | ---- | --------------- | ------------------------------- |
| bundleNames | Yes | Yes | Array\<string\> | Bundle names of the applications whose notifications are to be subscribed to.|
| userId      | Yes | Yes | number          | User whose notifications are to be subscribed to.   |
E
ester.zhou 已提交
4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063


## NotificationTemplate<sup>8+</sup>

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

| Name| Type              | Readable| Writable| Description      |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | Yes  | Yes  | Template name.|
| data | {[key:string]: Object} | Yes  | Yes  | Template data.|


## NotificationUserInput<sup>8+</sup>

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

E
ester.zhou 已提交
4064 4065 4066
| Name    | Readable| Writable| Type  | Description                         |
| -------- | --- | ---- | ------ | ----------------------------- |
| inputKey | Yes | Yes | string | Key to identify the user input.|
E
ester.zhou 已提交
4067

W
wusongqing 已提交
4068

E
ester.zhou 已提交
4069
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
4070

E
ester.zhou 已提交
4071
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
4072

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

E
ester.zhou 已提交
4075 4076 4077 4078 4079 4080
| 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 已提交
4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093


## 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 已提交
4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104

## 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.        |