js-apis-notification.md 138.3 KB
Newer Older
E
ester.zhou 已提交
1
# @ohos.notification (Notification)
W
wusongqing 已提交
2

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

E
ester.zhou 已提交
5
> **NOTE**
E
ester.zhou 已提交
6
>
E
ester.zhou 已提交
7
> 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.
E
esterzhou 已提交
8 9
>
> Notification subscription and unsubscription APIs are available only to system applications.
W
wusongqing 已提交
10 11 12 13 14 15 16

## Modules to Import

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

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

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

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

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

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

E
ester.zhou 已提交
27 28
| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
E
esterzhou 已提交
29 30
| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
| 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
    if (err.code) {
E
ester.zhou 已提交
38
        console.error(`publish failed, code is ${err.code}`);
E
esterzhou 已提交
39 40 41
    } else {
        console.info("publish success");
    }
W
wusongqing 已提交
42 43
}
// NotificationRequest object
E
ester.zhou 已提交
44
let notificationRequest = {
W
wusongqing 已提交
45 46
    id: 1,
    content: {
E
ester.zhou 已提交
47
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
W
wusongqing 已提交
48 49 50 51 52 53
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
54 55
};
Notification.publish(notificationRequest, publishCallback);
W
wusongqing 已提交
56 57
```

E
ester.zhou 已提交
58
## Notification.publish
W
wusongqing 已提交
59

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

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

E
ester.zhou 已提交
64
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
65

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

| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
E
esterzhou 已提交
70
| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
ester.zhou 已提交
71

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

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

```

E
ester.zhou 已提交
93 94 95 96
## Notification.publish<sup>8+</sup>

publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void

E
esterzhou 已提交
97
Publishes a notification to a specified user. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
98 99 100

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

E
ester.zhou 已提交
101 102
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
105 106
**Parameters**

E
ester.zhou 已提交
107 108
| Name    | Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
E
esterzhou 已提交
109 110
| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
| userId   | number                                      | Yes  | User ID.                          |
E
ester.zhou 已提交
111
| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                          |
E
ester.zhou 已提交
112 113 114 115 116 117

**Example**

```js
// publish callback
function publishCallback(err) {
E
esterzhou 已提交
118
    if (err.code) {
E
ester.zhou 已提交
119
        console.error(`publish failed, code is ${err.code}`);
E
esterzhou 已提交
120 121 122
    } else {
        console.info("publish success");
    }
E
ester.zhou 已提交
123
}
E
esterzhou 已提交
124
// User ID
E
ester.zhou 已提交
125
let userId = 1;
E
ester.zhou 已提交
126
// NotificationRequest object
E
ester.zhou 已提交
127
let notificationRequest = {
E
ester.zhou 已提交
128 129 130 131 132 133 134 135 136
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
137
};
E
ester.zhou 已提交
138 139 140 141 142 143 144
Notification.publish(notificationRequest, userId, publishCallback);
```

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

publish(request: NotificationRequest, userId: number): Promise\<void\>

E
esterzhou 已提交
145
Publishes a notification to a specified user. This API uses a promise to return the result.
E
ester.zhou 已提交
146 147 148

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

E
ester.zhou 已提交
149 150
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
153 154
**Parameters**

E
ester.zhou 已提交
155 156
| Name    |  Type                                       | Mandatory| Description                                       |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- |
E
esterzhou 已提交
157 158
| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
| userId   | number                                      | Yes  | User ID.                          |
E
ester.zhou 已提交
159 160 161 162

**Example**

```js
E
ester.zhou 已提交
163
let notificationRequest = {
E
ester.zhou 已提交
164 165 166 167 168 169 170 171 172
    notificationId: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
173
};
E
ester.zhou 已提交
174

E
ester.zhou 已提交
175
let userId = 1;
W
wusongqing 已提交
176

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


E
ester.zhou 已提交
183
## Notification.cancel
W
wusongqing 已提交
184

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

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

E
ester.zhou 已提交
189
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
190

E
ester.zhou 已提交
191
**Parameters**
W
wusongqing 已提交
192

E
ester.zhou 已提交
193 194 195 196 197
| 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 已提交
198

E
ester.zhou 已提交
199
**Example**
W
wusongqing 已提交
200 201 202 203

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



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

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

E
esterzhou 已提交
219
Cancels a notification with the specified ID and optional label. This API uses a promise to return the result.
W
wusongqing 已提交
220

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

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

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

E
ester.zhou 已提交
230
**Example**
W
wusongqing 已提交
231 232

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



E
ester.zhou 已提交
240
## Notification.cancel
W
wusongqing 已提交
241

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

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

E
ester.zhou 已提交
246
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
247

E
ester.zhou 已提交
248
**Parameters**
W
wusongqing 已提交
249

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

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

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



E
ester.zhou 已提交
271
## Notification.cancelAll
W
wusongqing 已提交
272

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

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

E
ester.zhou 已提交
277
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
278

E
ester.zhou 已提交
279
**Parameters**
W
wusongqing 已提交
280

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

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

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

E
ester.zhou 已提交
299
## Notification.cancelAll
W
wusongqing 已提交
300

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

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

E
ester.zhou 已提交
305
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
306

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

```js
E
ester.zhou 已提交
310
Notification.cancelAll().then(() => {
E
esterzhou 已提交
311
	console.info("cancelAll success");
W
wusongqing 已提交
312 313 314
});
```

E
ester.zhou 已提交
315
## Notification.addSlot
W
wusongqing 已提交
316

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

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

E
ester.zhou 已提交
321
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
322

E
ester.zhou 已提交
323 324
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
327
**Parameters**
W
wusongqing 已提交
328

E
ester.zhou 已提交
329 330 331 332
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| slot     | [NotificationSlot](#notificationslot)       | Yes  | Notification slot to add.|
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
333

E
ester.zhou 已提交
334
**Example**
W
wusongqing 已提交
335 336 337 338

```js
// addSlot callback
function addSlotCallBack(err) {
E
esterzhou 已提交
339 340 341 342 343
    if (err.code) {
        console.info("addSlot failed " + JSON.stringify(err));
    } else {
        console.info("addSlot success");
    }
W
wusongqing 已提交
344 345
}
// NotificationSlot object
E
ester.zhou 已提交
346
let notificationSlot = {
W
wusongqing 已提交
347
    type: Notification.SlotType.SOCIAL_COMMUNICATION
E
ester.zhou 已提交
348 349
};
Notification.addSlot(notificationSlot, addSlotCallBack);
W
wusongqing 已提交
350 351
```

E
ester.zhou 已提交
352
## Notification.addSlot
W
wusongqing 已提交
353

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

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

E
ester.zhou 已提交
358
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
359

E
ester.zhou 已提交
360 361
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
364
**Parameters**
W
wusongqing 已提交
365

E
ester.zhou 已提交
366 367 368
| Name| Type            | Mandatory| Description                |
| ---- | ---------------- | ---- | -------------------- |
| slot | [NotificationSlot](#notificationslot) | Yes  | Notification slot to add.|
W
wusongqing 已提交
369

E
ester.zhou 已提交
370
**Example**
W
wusongqing 已提交
371 372 373

```js
// NotificationSlot object
E
ester.zhou 已提交
374
let notificationSlot = {
W
wusongqing 已提交
375
    type: Notification.SlotType.SOCIAL_COMMUNICATION
E
ester.zhou 已提交
376
};
E
ester.zhou 已提交
377
Notification.addSlot(notificationSlot).then(() => {
E
esterzhou 已提交
378
	console.info("addSlot success");
W
wusongqing 已提交
379 380 381
});
```

E
ester.zhou 已提交
382
## Notification.addSlot
W
wusongqing 已提交
383

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

E
esterzhou 已提交
386
Adds a notification slot of a specified type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
387

E
ester.zhou 已提交
388
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
389

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

E
ester.zhou 已提交
392 393 394 395
| 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 已提交
396

E
ester.zhou 已提交
397
**Example**
W
wusongqing 已提交
398 399 400 401

```js
// addSlot callback
function addSlotCallBack(err) {
E
esterzhou 已提交
402 403 404 405 406
    if (err.code) {
        console.info("addSlot failed " + JSON.stringify(err));
    } else {
        console.info("addSlot success");
    }
W
wusongqing 已提交
407
}
E
ester.zhou 已提交
408
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
W
wusongqing 已提交
409 410
```

E
ester.zhou 已提交
411
## Notification.addSlot
W
wusongqing 已提交
412

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

E
esterzhou 已提交
415
Adds a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
416

E
ester.zhou 已提交
417
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
418

E
ester.zhou 已提交
419
**Parameters**
W
wusongqing 已提交
420

E
ester.zhou 已提交
421 422 423
| Name| Type    | Mandatory| Description                  |
| ---- | -------- | ---- | ---------------------- |
| type | [SlotType](#slottype) | Yes  | Type of the notification slot to add.|
W
wusongqing 已提交
424

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

```js
E
ester.zhou 已提交
428
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
E
esterzhou 已提交
429
	console.info("addSlot success");
W
wusongqing 已提交
430 431 432
});
```

E
ester.zhou 已提交
433
## Notification.addSlots
W
wusongqing 已提交
434

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

E
esterzhou 已提交
437
Adds an array of notification slots. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
438

E
ester.zhou 已提交
439
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
440

E
ester.zhou 已提交
441 442
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
445
**Parameters**
W
wusongqing 已提交
446

E
ester.zhou 已提交
447 448 449 450
| 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 已提交
451

E
ester.zhou 已提交
452
**Example**
W
wusongqing 已提交
453 454 455 456

```js
// addSlots callback
function addSlotsCallBack(err) {
E
esterzhou 已提交
457 458 459 460 461
    if (err.code) {
        console.info("addSlots failed " + JSON.stringify(err));
    } else {
        console.info("addSlots success");
    }
W
wusongqing 已提交
462 463
}
// NotificationSlot object
E
ester.zhou 已提交
464
let notificationSlot = {
W
wusongqing 已提交
465
    type: Notification.SlotType.SOCIAL_COMMUNICATION
E
ester.zhou 已提交
466
};
W
wusongqing 已提交
467
// NotificationSlotArray object
E
ester.zhou 已提交
468
let notificationSlotArray = new Array();
E
ester.zhou 已提交
469
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
470

E
ester.zhou 已提交
471
Notification.addSlots(notificationSlotArray, addSlotsCallBack);
W
wusongqing 已提交
472 473
```

E
ester.zhou 已提交
474
## Notification.addSlots
W
wusongqing 已提交
475

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

E
esterzhou 已提交
478
Adds an array of notification slots. This API uses a promise to return the result.
W
wusongqing 已提交
479

E
ester.zhou 已提交
480
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
481

E
ester.zhou 已提交
482 483
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
486
**Parameters**
W
wusongqing 已提交
487

E
ester.zhou 已提交
488 489 490
| Name | Type                     | Mandatory| Description                    |
| ----- | ------------------------- | ---- | ------------------------ |
| slots | Array\<[NotificationSlot](#notificationslot)\> | Yes  | Notification slots to add.|
W
wusongqing 已提交
491

E
ester.zhou 已提交
492
**Example**
W
wusongqing 已提交
493 494 495

```js
// NotificationSlot object
E
ester.zhou 已提交
496
let notificationSlot = {
W
wusongqing 已提交
497
    type: Notification.SlotType.SOCIAL_COMMUNICATION
E
ester.zhou 已提交
498
};
W
wusongqing 已提交
499
// NotificationSlotArray object
E
ester.zhou 已提交
500
let notificationSlotArray = new Array();
E
ester.zhou 已提交
501
notificationSlotArray[0] = notificationSlot;
W
wusongqing 已提交
502

E
ester.zhou 已提交
503
Notification.addSlots(notificationSlotArray).then(() => {
E
esterzhou 已提交
504
	console.info("addSlots success");
W
wusongqing 已提交
505 506 507
});
```

E
ester.zhou 已提交
508
## Notification.getSlot
W
wusongqing 已提交
509

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

E
esterzhou 已提交
512
Obtains a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
513

E
ester.zhou 已提交
514
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
515

E
ester.zhou 已提交
516
**Parameters**
W
wusongqing 已提交
517

E
ester.zhou 已提交
518 519 520 521
| 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 已提交
522

E
ester.zhou 已提交
523
**Example**
W
wusongqing 已提交
524 525 526

```js
// getSlot callback
E
esterzhou 已提交
527
function getSlotCallback(err, data) {
E
esterzhou 已提交
528 529 530 531 532
    if (err.code) {
        console.info("getSlot failed " + JSON.stringify(err));
    } else {
        console.info("getSlot success");
    }
W
wusongqing 已提交
533
}
E
ester.zhou 已提交
534 535
let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback);
W
wusongqing 已提交
536 537
```

E
ester.zhou 已提交
538
## Notification.getSlot
W
wusongqing 已提交
539

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

E
esterzhou 已提交
542
Obtains a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
543

E
ester.zhou 已提交
544
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
545

E
ester.zhou 已提交
546
**Parameters**
W
wusongqing 已提交
547

E
ester.zhou 已提交
548 549 550
| 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 已提交
551

E
ester.zhou 已提交
552
**Return value**
W
wusongqing 已提交
553

E
ester.zhou 已提交
554 555 556 557 558
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
559 560

```js
E
ester.zhou 已提交
561
let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
W
wusongqing 已提交
562
Notification.getSlot(slotType).then((data) => {
E
esterzhou 已提交
563
	console.info("getSlot success, data: " + JSON.stringify(data));
W
wusongqing 已提交
564 565 566
});
```

E
ester.zhou 已提交
567
## Notification.getSlots
W
wusongqing 已提交
568

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

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

E
ester.zhou 已提交
573
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
574

E
ester.zhou 已提交
575
**Parameters**
W
wusongqing 已提交
576

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

E
ester.zhou 已提交
581
**Example**
W
wusongqing 已提交
582 583 584

```js
// getSlots callback
E
esterzhou 已提交
585
function getSlotsCallback(err, data) {
E
esterzhou 已提交
586 587 588 589 590
    if (err.code) {
        console.info("getSlots failed " + JSON.stringify(err));
    } else {
        console.info("getSlots success");
    }
W
wusongqing 已提交
591
}
E
ester.zhou 已提交
592
Notification.getSlots(getSlotsCallback);
W
wusongqing 已提交
593 594
```

E
ester.zhou 已提交
595
## Notification.getSlots
W
wusongqing 已提交
596

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

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

E
ester.zhou 已提交
601
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
602

E
ester.zhou 已提交
603
**Return value**
W
wusongqing 已提交
604

E
ester.zhou 已提交
605 606 607
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result.|
W
wusongqing 已提交
608

E
ester.zhou 已提交
609
**Example**
W
wusongqing 已提交
610 611 612

```js
Notification.getSlots().then((data) => {
E
esterzhou 已提交
613
	console.info("getSlots success, data: " + JSON.stringify(data));
W
wusongqing 已提交
614 615 616
});
```

E
ester.zhou 已提交
617
## Notification.removeSlot
W
wusongqing 已提交
618

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

E
esterzhou 已提交
621
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
622

E
ester.zhou 已提交
623
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
624

E
ester.zhou 已提交
625
**Parameters**
W
wusongqing 已提交
626

E
ester.zhou 已提交
627 628 629 630
| 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 已提交
631

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

```js
// removeSlot callback
function removeSlotCallback(err) {
E
esterzhou 已提交
637 638 639 640 641
    if (err.code) {
        console.info("removeSlot failed " + JSON.stringify(err));
    } else {
        console.info("removeSlot success");
    }
W
wusongqing 已提交
642
}
E
ester.zhou 已提交
643 644
let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback);
W
wusongqing 已提交
645 646
```

E
ester.zhou 已提交
647
## Notification.removeSlot
W
wusongqing 已提交
648

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

E
esterzhou 已提交
651
Removes a notification slot of a specified type. This API uses a promise to return the result.
W
wusongqing 已提交
652

E
ester.zhou 已提交
653
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
654

E
ester.zhou 已提交
655
**Parameters**
W
wusongqing 已提交
656

E
ester.zhou 已提交
657 658 659
| 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 已提交
660

E
ester.zhou 已提交
661
**Example**
W
wusongqing 已提交
662 663

```js
E
ester.zhou 已提交
664
let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
E
ester.zhou 已提交
665
Notification.removeSlot(slotType).then(() => {
E
esterzhou 已提交
666
	console.info("removeSlot success");
W
wusongqing 已提交
667 668 669
});
```

E
ester.zhou 已提交
670
## Notification.removeAllSlots
W
wusongqing 已提交
671

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

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

E
ester.zhou 已提交
676
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
677

E
ester.zhou 已提交
678
**Parameters**
W
wusongqing 已提交
679

E
ester.zhou 已提交
680 681 682
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
683

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

```js
function removeAllCallBack(err) {
E
esterzhou 已提交
688 689 690 691 692
    if (err.code) {
        console.info("removeAllSlots failed " + JSON.stringify(err));
    } else {
        console.info("removeAllSlots success");
    }
W
wusongqing 已提交
693
}
E
ester.zhou 已提交
694
Notification.removeAllSlots(removeAllCallBack);
W
wusongqing 已提交
695 696
```

E
ester.zhou 已提交
697
## Notification.removeAllSlots
W
wusongqing 已提交
698

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

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

E
ester.zhou 已提交
703
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
704

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

```js
E
ester.zhou 已提交
708
Notification.removeAllSlots().then(() => {
E
esterzhou 已提交
709
	console.info("removeAllSlots success");
W
wusongqing 已提交
710 711 712
});
```

E
ester.zhou 已提交
713
## Notification.subscribe
W
wusongqing 已提交
714

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

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

E
ester.zhou 已提交
719
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
720

E
ester.zhou 已提交
721 722
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
727 728 729
| Name      | Type                     | Mandatory| Description            |
| ---------- | ------------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.    |
E
esterzhou 已提交
730
| info       | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes  | Notification subscription information.|
E
ester.zhou 已提交
731
| callback   | AsyncCallback\<void\>     | Yes  | Callback used to return the result.|
W
wusongqing 已提交
732

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

```js
// subscribe callback
function subscribeCallback(err) {
E
esterzhou 已提交
738 739 740 741 742
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribe success");
    }
W
wusongqing 已提交
743
}
E
ester.zhou 已提交
744
function onConsumeCallback(data) {
E
esterzhou 已提交
745
	console.info("Consume callback: " + JSON.stringify(data));
W
wusongqing 已提交
746
}
E
ester.zhou 已提交
747
let subscriber = {
W
wusongqing 已提交
748
    onConsume: onConsumeCallback
E
ester.zhou 已提交
749 750
};
let info = {
E
esterzhou 已提交
751
    bundleNames: ["bundleName1", "bundleName2"]
E
ester.zhou 已提交
752
};
W
wusongqing 已提交
753 754 755
Notification.subscribe(subscriber, info, subscribeCallback);
```

E
ester.zhou 已提交
756
## Notification.subscribe
W
wusongqing 已提交
757

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

E
esterzhou 已提交
760
Subscribes to notifications of all applications under this user. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
761

E
ester.zhou 已提交
762
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
763

E
ester.zhou 已提交
764 765
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
768
**Parameters**
W
wusongqing 已提交
769

E
ester.zhou 已提交
770 771 772 773
| Name      | Type                  | Mandatory| Description            |
| ---------- | ---------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.    |
| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
774

E
ester.zhou 已提交
775
**Example**
W
wusongqing 已提交
776 777 778

```js
function subscribeCallback(err) {
E
esterzhou 已提交
779 780 781 782 783
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribe success");
    }
W
wusongqing 已提交
784
}
E
ester.zhou 已提交
785
function onConsumeCallback(data) {
E
esterzhou 已提交
786
	console.info("Consume callback: " + JSON.stringify(data));
W
wusongqing 已提交
787
}
E
ester.zhou 已提交
788
let subscriber = {
W
wusongqing 已提交
789
    onConsume: onConsumeCallback
E
ester.zhou 已提交
790
};
W
wusongqing 已提交
791 792 793
Notification.subscribe(subscriber, subscribeCallback);
```

E
ester.zhou 已提交
794
## Notification.subscribe
W
wusongqing 已提交
795

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

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

E
ester.zhou 已提交
800
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
801

E
ester.zhou 已提交
802 803
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
806
**Parameters**
W
wusongqing 已提交
807

E
ester.zhou 已提交
808 809 810
| Name      | Type                     | Mandatory| Description        |
| ---------- | ------------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber)    | Yes  | Notification subscriber.|
E
esterzhou 已提交
811
| info       | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No  | Notification subscription information.  |
W
wusongqing 已提交
812

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

```js
E
ester.zhou 已提交
816
function onConsumeCallback(data) {
E
esterzhou 已提交
817
    console.info("Consume callback: " + JSON.stringify(data));
W
wusongqing 已提交
818
}
E
ester.zhou 已提交
819
let subscriber = {
W
wusongqing 已提交
820 821
    onConsume: onConsumeCallback
};
E
ester.zhou 已提交
822
Notification.subscribe(subscriber).then(() => {
E
esterzhou 已提交
823
	console.info("subscribe success");
W
wusongqing 已提交
824 825 826
});
```

E
ester.zhou 已提交
827
## Notification.unsubscribe
W
wusongqing 已提交
828

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

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

E
ester.zhou 已提交
833
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
834

E
ester.zhou 已提交
835 836
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
839
**Parameters**
W
wusongqing 已提交
840

E
ester.zhou 已提交
841 842 843 844
| Name      | Type                  | Mandatory| Description                |
| ---------- | ---------------------- | ---- | -------------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.        |
| callback   | AsyncCallback\<void\>  | Yes  | Callback used to return the result.|
W
wusongqing 已提交
845

E
ester.zhou 已提交
846
**Example**
W
wusongqing 已提交
847 848 849

```js
function unsubscribeCallback(err) {
E
esterzhou 已提交
850 851 852 853 854
    if (err.code) {
        console.info("unsubscribe failed " + JSON.stringify(err));
    } else {
        console.info("unsubscribe success");
    }
W
wusongqing 已提交
855
}
E
ester.zhou 已提交
856 857
function onDisconnectCallback() {
	console.info("subscribe disconnect");
W
wusongqing 已提交
858
}
E
ester.zhou 已提交
859
let subscriber = {
E
esterzhou 已提交
860
    onDisconnect: onDisconnectCallback
E
ester.zhou 已提交
861
};
W
wusongqing 已提交
862 863 864
Notification.unsubscribe(subscriber, unsubscribeCallback);
```

E
ester.zhou 已提交
865
## Notification.unsubscribe
W
wusongqing 已提交
866

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

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

E
ester.zhou 已提交
871
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
872

E
ester.zhou 已提交
873 874
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
877
**Parameters**
W
wusongqing 已提交
878

E
ester.zhou 已提交
879 880 881
| Name      | Type                  | Mandatory| Description        |
| ---------- | ---------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes  | Notification subscriber.|
W
wusongqing 已提交
882

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

```js
E
ester.zhou 已提交
886 887
function onDisconnectCallback() {
	console.info("subscribe disconnect");
W
wusongqing 已提交
888
}
E
ester.zhou 已提交
889
let subscriber = {
E
esterzhou 已提交
890
    onDisconnect: onDisconnectCallback
W
wusongqing 已提交
891
};
E
ester.zhou 已提交
892
Notification.unsubscribe(subscriber).then(() => {
E
esterzhou 已提交
893
	console.info("unsubscribe success");
W
wusongqing 已提交
894 895 896
});
```

E
ester.zhou 已提交
897
## Notification.enableNotification
W
wusongqing 已提交
898

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

E
esterzhou 已提交
901
Sets whether to enable notification for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
902

E
ester.zhou 已提交
903
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
904

E
ester.zhou 已提交
905 906
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
909
**Parameters**
W
wusongqing 已提交
910

E
ester.zhou 已提交
911 912
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
esterzhou 已提交
913
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.       |
E
ester.zhou 已提交
914 915
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
916

E
ester.zhou 已提交
917
**Example**
W
wusongqing 已提交
918 919 920

```js
function enableNotificationCallback(err) {
E
esterzhou 已提交
921 922 923 924 925
    if (err.code) {
        console.info("enableNotification failed " + JSON.stringify(err));
    } else {
        console.info("enableNotification success");
    }
W
wusongqing 已提交
926
}
E
ester.zhou 已提交
927
let bundle = {
E
ester.zhou 已提交
928
    bundle: "bundleName1",
E
ester.zhou 已提交
929
};
W
wusongqing 已提交
930 931 932
Notification.enableNotification(bundle, false, enableNotificationCallback);
```

E
ester.zhou 已提交
933
## Notification.enableNotification
W
wusongqing 已提交
934

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

E
esterzhou 已提交
937
Sets whether to enable notification for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
938

E
ester.zhou 已提交
939
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
940

E
ester.zhou 已提交
941 942
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
945
**Parameters**
W
wusongqing 已提交
946

E
ester.zhou 已提交
947 948
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
949
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
E
ester.zhou 已提交
950
| enable | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
951

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

```js
E
ester.zhou 已提交
955
let bundle = {
E
ester.zhou 已提交
956
    bundle: "bundleName1",
E
ester.zhou 已提交
957
};
E
ester.zhou 已提交
958
Notification.enableNotification(bundle, false).then(() => {
E
esterzhou 已提交
959
	console.info("enableNotification success");
W
wusongqing 已提交
960 961 962
});
```

E
ester.zhou 已提交
963
## Notification.isNotificationEnabled
W
wusongqing 已提交
964

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

E
esterzhou 已提交
967
Checks whether notification is enabled for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
968

E
ester.zhou 已提交
969
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
970

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

E
ester.zhou 已提交
973 974
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
975
**Parameters**
W
wusongqing 已提交
976

E
ester.zhou 已提交
977 978
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
E
esterzhou 已提交
979
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.           |
E
ester.zhou 已提交
980
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
981

E
ester.zhou 已提交
982
**Example**
W
wusongqing 已提交
983 984 985

```js
function isNotificationEnabledCallback(err, data) {
E
esterzhou 已提交
986 987 988 989 990
    if (err.code) {
        console.info("isNotificationEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationEnabled success");
    }
W
wusongqing 已提交
991
}
E
ester.zhou 已提交
992
let bundle = {
E
ester.zhou 已提交
993
    bundle: "bundleName1",
E
ester.zhou 已提交
994
};
W
wusongqing 已提交
995 996 997
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
```

E
ester.zhou 已提交
998 999 1000
## Notification.isNotificationEnabled

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

E
esterzhou 已提交
1002
Checks whether notification is enabled for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1003

E
ester.zhou 已提交
1004
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1005

E
ester.zhou 已提交
1006 1007
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1010
**Parameters**
W
wusongqing 已提交
1011

E
ester.zhou 已提交
1012 1013
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1014
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1015

E
ester.zhou 已提交
1016
**Return value**
W
wusongqing 已提交
1017

E
esterzhou 已提交
1018 1019
| Type              | Description                                               |
| ------------------ | --------------------------------------------------- |
E
ester.zhou 已提交
1020
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1021

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

```js
E
ester.zhou 已提交
1025
let bundle = {
E
ester.zhou 已提交
1026
    bundle: "bundleName1",
E
ester.zhou 已提交
1027
};
W
wusongqing 已提交
1028
Notification.isNotificationEnabled(bundle).then((data) => {
E
esterzhou 已提交
1029
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1030 1031 1032
});
```

E
ester.zhou 已提交
1033
## Notification.isNotificationEnabled
W
wusongqing 已提交
1034

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

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

E
ester.zhou 已提交
1039
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1040

E
ester.zhou 已提交
1041 1042
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1047 1048 1049
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1050

E
ester.zhou 已提交
1051
**Example**
W
wusongqing 已提交
1052 1053 1054

```js
function isNotificationEnabledCallback(err, data) {
E
esterzhou 已提交
1055 1056 1057 1058 1059
    if (err.code) {
        console.info("isNotificationEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationEnabled success");
    }
W
wusongqing 已提交
1060 1061 1062 1063 1064
}

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```

E
ester.zhou 已提交
1065
## Notification.isNotificationEnabled
W
wusongqing 已提交
1066

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

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

E
ester.zhou 已提交
1071
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1072

E
ester.zhou 已提交
1073 1074
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1079 1080
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1081
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1082

E
ester.zhou 已提交
1083 1084 1085 1086 1087
**Return value**

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

E
ester.zhou 已提交
1089
**Example**
W
wusongqing 已提交
1090 1091 1092

```js
Notification.isNotificationEnabled().then((data) => {
E
esterzhou 已提交
1093
	console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1094 1095 1096
});
```

E
ester.zhou 已提交
1097
## Notification.displayBadge
W
wusongqing 已提交
1098

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

E
esterzhou 已提交
1101
Sets whether to enable the notification badge for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1102

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

E
ester.zhou 已提交
1105 1106
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1111 1112
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
esterzhou 已提交
1113
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1114 1115
| enable   | boolean               | Yes  | Whether to enable notification.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1116

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

```js
function displayBadgeCallback(err) {
E
esterzhou 已提交
1121 1122 1123 1124 1125
    if (err.code) {
        console.info("displayBadge failed " + JSON.stringify(err));
    } else {
        console.info("displayBadge success");
    }
W
wusongqing 已提交
1126
}
E
ester.zhou 已提交
1127
let bundle = {
E
ester.zhou 已提交
1128
    bundle: "bundleName1",
E
ester.zhou 已提交
1129
};
W
wusongqing 已提交
1130 1131 1132
Notification.displayBadge(bundle, false, displayBadgeCallback);
```

E
ester.zhou 已提交
1133
## Notification.displayBadge
W
wusongqing 已提交
1134

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

E
esterzhou 已提交
1137
Sets whether to enable the notification badge for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1138

E
ester.zhou 已提交
1139
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1140

E
ester.zhou 已提交
1141 1142
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1147 1148
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1149
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
E
ester.zhou 已提交
1150
| enable | boolean      | Yes  | Whether to enable notification.  |
W
wusongqing 已提交
1151

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

```js
E
ester.zhou 已提交
1155
let bundle = {
E
ester.zhou 已提交
1156
    bundle: "bundleName1",
E
ester.zhou 已提交
1157
};
E
ester.zhou 已提交
1158
Notification.displayBadge(bundle, false).then(() => {
E
esterzhou 已提交
1159
	console.info("displayBadge success");
W
wusongqing 已提交
1160 1161 1162
});
```

E
ester.zhou 已提交
1163
## Notification.isBadgeDisplayed
W
wusongqing 已提交
1164

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

E
esterzhou 已提交
1167
Checks whether the notification badge is enabled for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1168

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

E
ester.zhou 已提交
1171 1172
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1177 1178
| Name    | Type                 | Mandatory| Description                    |
| -------- | --------------------- | ---- | ------------------------ |
E
esterzhou 已提交
1179
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.              |
E
ester.zhou 已提交
1180
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1181

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

```js
function isBadgeDisplayedCallback(err, data) {
E
esterzhou 已提交
1186 1187 1188 1189 1190
    if (err.code) {
        console.info("isBadgeDisplayed failed " + JSON.stringify(err));
    } else {
        console.info("isBadgeDisplayed success");
    }
W
wusongqing 已提交
1191
}
E
ester.zhou 已提交
1192
let bundle = {
E
ester.zhou 已提交
1193
    bundle: "bundleName1",
E
ester.zhou 已提交
1194
};
W
wusongqing 已提交
1195 1196 1197
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```

E
ester.zhou 已提交
1198 1199 1200
## Notification.isBadgeDisplayed

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

E
esterzhou 已提交
1202
Checks whether the notification badge is enabled for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1203

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

E
ester.zhou 已提交
1206 1207
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1212 1213
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1214
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1215

E
ester.zhou 已提交
1216
**Return value**
W
wusongqing 已提交
1217

E
ester.zhou 已提交
1218 1219 1220
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
1221

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

```js
E
ester.zhou 已提交
1225
let bundle = {
E
ester.zhou 已提交
1226
    bundle: "bundleName1",
E
ester.zhou 已提交
1227
};
W
wusongqing 已提交
1228
Notification.isBadgeDisplayed(bundle).then((data) => {
E
esterzhou 已提交
1229
	console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1230 1231 1232
});
```

E
ester.zhou 已提交
1233
## Notification.setSlotByBundle
W
wusongqing 已提交
1234

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

E
esterzhou 已提交
1237
Sets the notification slot for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1238

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

E
ester.zhou 已提交
1241 1242
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1245
**Parameters**
W
wusongqing 已提交
1246

E
ester.zhou 已提交
1247 1248
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
esterzhou 已提交
1249
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1250 1251
| slot     | [NotificationSlot](#notificationslot)      | Yes  | Notification slot.            |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1252

E
ester.zhou 已提交
1253
**Example**
W
wusongqing 已提交
1254 1255 1256

```js
function setSlotByBundleCallback(err) {
E
esterzhou 已提交
1257 1258 1259 1260 1261
    if (err.code) {
        console.info("setSlotByBundle failed " + JSON.stringify(err));
    } else {
        console.info("setSlotByBundle success");
    }
W
wusongqing 已提交
1262
}
E
ester.zhou 已提交
1263
let bundle = {
E
ester.zhou 已提交
1264
    bundle: "bundleName1",
E
ester.zhou 已提交
1265 1266
};
let notificationSlot = {
W
wusongqing 已提交
1267
    type: Notification.SlotType.SOCIAL_COMMUNICATION
E
ester.zhou 已提交
1268
};
W
wusongqing 已提交
1269 1270 1271
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```

E
ester.zhou 已提交
1272
## Notification.setSlotByBundle
W
wusongqing 已提交
1273

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

E
esterzhou 已提交
1276
Sets the notification slot for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1277

E
ester.zhou 已提交
1278
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1279

E
ester.zhou 已提交
1280 1281
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1284
**Parameters**
W
wusongqing 已提交
1285

E
ester.zhou 已提交
1286 1287
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1288 1289
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
| slot   | [NotificationSlot](#notificationslot) | Yes  | Notification slot.|
W
wusongqing 已提交
1290

E
ester.zhou 已提交
1291
**Example**
W
wusongqing 已提交
1292 1293

```js
E
ester.zhou 已提交
1294
let bundle = {
E
ester.zhou 已提交
1295
    bundle: "bundleName1",
E
ester.zhou 已提交
1296 1297
};
let notificationSlot = {
W
wusongqing 已提交
1298
    type: Notification.SlotType.SOCIAL_COMMUNICATION
E
ester.zhou 已提交
1299
};
E
ester.zhou 已提交
1300
Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
E
esterzhou 已提交
1301
	console.info("setSlotByBundle success");
W
wusongqing 已提交
1302 1303 1304
});
```

E
ester.zhou 已提交
1305
## Notification.getSlotsByBundle
W
wusongqing 已提交
1306

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

E
esterzhou 已提交
1309
Obtains the notification slots of a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1310

E
ester.zhou 已提交
1311
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1312

E
ester.zhou 已提交
1313 1314
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1317
**Parameters**
W
wusongqing 已提交
1318

E
ester.zhou 已提交
1319 1320
| Name    | Type                                    | Mandatory| Description                |
| -------- | ---------------------------------------- | ---- | -------------------- |
E
esterzhou 已提交
1321
| bundle   | [BundleOption](#bundleoption)                             | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1322
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1323

E
ester.zhou 已提交
1324
**Example**
W
wusongqing 已提交
1325 1326 1327

```js
function getSlotsByBundleCallback(err, data) {
E
esterzhou 已提交
1328 1329 1330 1331 1332
    if (err.code) {
        console.info("getSlotsByBundle failed " + JSON.stringify(err));
    } else {
        console.info("getSlotsByBundle success");
    }
W
wusongqing 已提交
1333
}
E
ester.zhou 已提交
1334
let bundle = {
E
ester.zhou 已提交
1335
    bundle: "bundleName1",
E
ester.zhou 已提交
1336
};
W
wusongqing 已提交
1337 1338 1339
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```

E
ester.zhou 已提交
1340
## Notification.getSlotsByBundle
W
wusongqing 已提交
1341

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

E
esterzhou 已提交
1344
Obtains the notification slots of a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1345

E
ester.zhou 已提交
1346
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1347

E
ester.zhou 已提交
1348 1349
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1352
**Parameters**
W
wusongqing 已提交
1353

E
ester.zhou 已提交
1354 1355
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1356
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.|
W
wusongqing 已提交
1357

E
ester.zhou 已提交
1358
**Return value**
W
wusongqing 已提交
1359

E
ester.zhou 已提交
1360 1361 1362 1363 1364
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | Promise used to return the result.|

**Example**
W
wusongqing 已提交
1365 1366

```js
E
ester.zhou 已提交
1367
let bundle = {
E
ester.zhou 已提交
1368
    bundle: "bundleName1",
E
ester.zhou 已提交
1369
};
W
wusongqing 已提交
1370
Notification.getSlotsByBundle(bundle).then((data) => {
E
esterzhou 已提交
1371
	console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1372 1373 1374
});
```

E
ester.zhou 已提交
1375
## Notification.getSlotNumByBundle
W
wusongqing 已提交
1376

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

E
esterzhou 已提交
1379
Obtains the number of notification slots of a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1380

E
ester.zhou 已提交
1381
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1382

E
ester.zhou 已提交
1383 1384
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1387
**Parameters**
W
wusongqing 已提交
1388

E
ester.zhou 已提交
1389 1390
| Name    | Type                     | Mandatory| Description                  |
| -------- | ------------------------- | ---- | ---------------------- |
E
esterzhou 已提交
1391
| bundle   | [BundleOption](#bundleoption)              | Yes  | Bundle information of the application.            |
E
ester.zhou 已提交
1392
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1393

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

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

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

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

E
esterzhou 已提交
1414
Obtains the number of notification slots of a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1415

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

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

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

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

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

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

E
ester.zhou 已提交
1430 1431 1432 1433 1434
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

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

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

E
ester.zhou 已提交
1445
## Notification.remove
W
wusongqing 已提交
1446

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

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

E
ester.zhou 已提交
1451
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1452

E
ester.zhou 已提交
1453 1454
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1457
**Parameters**
W
wusongqing 已提交
1458

E
ester.zhou 已提交
1459
| Name           | Type                               | Mandatory| Description                |
E
esterzhou 已提交
1460
| --------------- |   ----------------------------------| ---- | -------------------- |
E
esterzhou 已提交
1461
| bundle          | [BundleOption](#bundleoption)       | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
1462
| notificationKey | [NotificationKey](#notificationkey) | Yes  | Notification key.            |
E
esterzhou 已提交
1463
| reason          | [RemoveReason](#removereason9)      | Yes  | Indicates the reason for deleting a notification.        |
E
ester.zhou 已提交
1464
| callback        | AsyncCallback\<void\>               | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1465

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

```js
function removeCallback(err) {
E
esterzhou 已提交
1470 1471 1472 1473 1474
    if (err.code) {
        console.info("remove failed " + JSON.stringify(err));
    } else {
        console.info("remove success");
    }
W
wusongqing 已提交
1475
}
E
ester.zhou 已提交
1476
let bundle = {
E
ester.zhou 已提交
1477
    bundle: "bundleName1",
E
ester.zhou 已提交
1478 1479
};
let notificationKey = {
E
ester.zhou 已提交
1480 1481
    id: 0,
    label: "label",
E
ester.zhou 已提交
1482 1483
};
let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
E
esterzhou 已提交
1484
Notification.remove(bundle, notificationKey, reason, removeCallback);
W
wusongqing 已提交
1485 1486
```

E
ester.zhou 已提交
1487
## Notification.remove
W
wusongqing 已提交
1488

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

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

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

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

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

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

E
ester.zhou 已提交
1501 1502
| Name           | Type           | Mandatory| Description      |
| --------------- | --------------- | ---- | ---------- |
E
esterzhou 已提交
1503
| bundle          | [BundleOption](#bundleoption)    | Yes  | Bundle information of the application.|
E
ester.zhou 已提交
1504
| notificationKey | [NotificationKey](#notificationkey) | Yes  | Notification key.  |
E
esterzhou 已提交
1505
| reason          | [RemoveReason](#removereason9) | Yes  | Reason for deleting the notification.        |
W
wusongqing 已提交
1506

E
ester.zhou 已提交
1507
**Example**
W
wusongqing 已提交
1508 1509

```js
E
ester.zhou 已提交
1510
let bundle = {
E
ester.zhou 已提交
1511
    bundle: "bundleName1",
E
ester.zhou 已提交
1512 1513
};
let notificationKey = {
E
ester.zhou 已提交
1514 1515
    id: 0,
    label: "label",
E
ester.zhou 已提交
1516 1517
};
let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
E
esterzhou 已提交
1518
Notification.remove(bundle, notificationKey, reason).then(() => {
E
esterzhou 已提交
1519
	console.info("remove success");
W
wusongqing 已提交
1520 1521 1522
});
```

E
ester.zhou 已提交
1523
## Notification.remove
W
wusongqing 已提交
1524

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

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

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

E
ester.zhou 已提交
1531 1532
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1537 1538
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
E
esterzhou 已提交
1539
| hashCode | string                | Yes  | Unique notification ID. It is the **hashCode** in the [NotificationRequest](#notificationrequest) object of [SubscribeCallbackData](#subscribecallbackdata) of the [onConsume](#onconsume) callback.|
E
esterzhou 已提交
1540
| reason   | [RemoveReason](#removereason9) | Yes  | Indicates the reason for deleting a notification.        |
E
ester.zhou 已提交
1541
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1542

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

```js
E
ester.zhou 已提交
1546
let hashCode = 'hashCode';
E
ester.zhou 已提交
1547

W
wusongqing 已提交
1548
function removeCallback(err) {
E
esterzhou 已提交
1549 1550 1551 1552 1553
    if (err.code) {
        console.info("remove failed " + JSON.stringify(err));
    } else {
        console.info("remove success");
    }
W
wusongqing 已提交
1554
}
E
ester.zhou 已提交
1555
let reason = Notification.RemoveReason.CANCEL_REASON_REMOVE;
E
esterzhou 已提交
1556
Notification.remove(hashCode, reason, removeCallback);
W
wusongqing 已提交
1557 1558
```

E
ester.zhou 已提交
1559
## Notification.remove
W
wusongqing 已提交
1560

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

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

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

E
ester.zhou 已提交
1567 1568
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1573 1574 1575
| Name    | Type      | Mandatory| Description      |
| -------- | ---------- | ---- | ---------- |
| hashCode | string | Yes  | Unique notification ID.|
E
esterzhou 已提交
1576
| reason   | [RemoveReason](#removereason9) | Yes  | Reason for deleting the notification.        |
W
wusongqing 已提交
1577

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

```js
E
ester.zhou 已提交
1581 1582
let hashCode = 'hashCode';
let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
E
esterzhou 已提交
1583
Notification.remove(hashCode, reason).then(() => {
E
esterzhou 已提交
1584
	console.info("remove success");
W
wusongqing 已提交
1585 1586 1587
});
```

E
ester.zhou 已提交
1588
## Notification.removeAll
W
wusongqing 已提交
1589

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

E
esterzhou 已提交
1592
Removes all notifications for a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1593

E
ester.zhou 已提交
1594
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1595

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

E
ester.zhou 已提交
1598 1599
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
1600
**Parameters**
W
wusongqing 已提交
1601

E
ester.zhou 已提交
1602 1603
| Name    | Type                 | Mandatory| Description                        |
| -------- | --------------------- | ---- | ---------------------------- |
E
esterzhou 已提交
1604
| bundle   | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
1605
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1606

E
ester.zhou 已提交
1607
**Example**
W
wusongqing 已提交
1608 1609 1610

```js
function removeAllCallback(err) {
E
esterzhou 已提交
1611 1612 1613 1614 1615
    if (err.code) {
        console.info("removeAll failed " + JSON.stringify(err));
    } else {
        console.info("removeAll success");
    }
W
wusongqing 已提交
1616
}
E
ester.zhou 已提交
1617
let bundle = {
E
ester.zhou 已提交
1618
    bundle: "bundleName1",
E
ester.zhou 已提交
1619
};
W
wusongqing 已提交
1620 1621 1622
Notification.removeAll(bundle, removeAllCallback);
```

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

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

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

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

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

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

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

E
ester.zhou 已提交
1637 1638 1639
| Name    | Type                 | Mandatory| Description                |
| -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1640

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

```js
function removeAllCallback(err) {
E
esterzhou 已提交
1645 1646 1647 1648 1649
    if (err.code) {
        console.info("removeAll failed " + JSON.stringify(err));
    } else {
        console.info("removeAll success");
    }
W
wusongqing 已提交
1650 1651 1652 1653 1654
}

Notification.removeAll(removeAllCallback);
```

E
ester.zhou 已提交
1655
## Notification.removeAll
W
wusongqing 已提交
1656

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

E
esterzhou 已提交
1659
Removes all notifications for a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1660

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

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

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

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

E
ester.zhou 已提交
1669 1670
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1671
| bundle | [BundleOption](#bundleoption) | No  | Bundle information of the application.|
W
wusongqing 已提交
1672

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

```js
E
esterzhou 已提交
1676
// If no application is specified, notifications of all applications are deleted.
E
ester.zhou 已提交
1677
Notification.removeAll().then(() => {
E
esterzhou 已提交
1678
	console.info("removeAll success");
W
wusongqing 已提交
1679 1680 1681
});
```

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

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

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

E
ester.zhou 已提交
1688
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1689

E
ester.zhou 已提交
1690 1691
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
1694
**Parameters**
W
wusongqing 已提交
1695

E
ester.zhou 已提交
1696 1697
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1698
| userId | number | Yes  | User ID.|
E
ester.zhou 已提交
1699
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1700

E
ester.zhou 已提交
1701
**Example**
W
wusongqing 已提交
1702

E
ester.zhou 已提交
1703 1704
```js
function removeAllCallback(err) {
E
esterzhou 已提交
1705 1706 1707 1708 1709
    if (err.code) {
        console.info("removeAll failed " + JSON.stringify(err));
    } else {
        console.info("removeAll success");
    }
E
ester.zhou 已提交
1710 1711
}

E
ester.zhou 已提交
1712
let userId = 1;
E
ester.zhou 已提交
1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723
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 已提交
1724 1725
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1730 1731
| Name  | Type        | Mandatory| Description      |
| ------ | ------------ | ---- | ---------- |
E
esterzhou 已提交
1732
| userId | number | Yes  | User ID.|
E
ester.zhou 已提交
1733 1734 1735 1736

**Example**

```js
E
ester.zhou 已提交
1737
let userId = 1;
E
esterzhou 已提交
1738 1739 1740
Notification.removeAll(userId).then(() => {
	console.info("removeAll success");
});
E
ester.zhou 已提交
1741 1742 1743 1744
```


## Notification.getAllActiveNotifications
W
wusongqing 已提交
1745

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

E
ester.zhou 已提交
1748 1749 1750 1751
Obtains all active notifications. This API uses an asynchronous callback to return the result.

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

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

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

E
ester.zhou 已提交
1756 1757
**Parameters**

E
ester.zhou 已提交
1758 1759 1760
| Name    | Type                                                        | Mandatory| Description                |
| -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
1761 1762

**Example**
W
wusongqing 已提交
1763 1764 1765

```js
function getAllActiveNotificationsCallback(err, data) {
E
esterzhou 已提交
1766 1767 1768 1769 1770
    if (err.code) {
        console.info("getAllActiveNotifications failed " + JSON.stringify(err));
    } else {
        console.info("getAllActiveNotifications success");
    }
W
wusongqing 已提交
1771 1772 1773 1774 1775
}

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```

E
ester.zhou 已提交
1776
## Notification.getAllActiveNotifications
W
wusongqing 已提交
1777

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

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

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

E
ester.zhou 已提交
1784 1785
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1790 1791 1792
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result.|
W
wusongqing 已提交
1793

E
ester.zhou 已提交
1794
**Example**
W
wusongqing 已提交
1795 1796 1797

```js
Notification.getAllActiveNotifications().then((data) => {
E
esterzhou 已提交
1798
	console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1799 1800 1801
});
```

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

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

E
esterzhou 已提交
1806
Obtains the number of active notifications of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1807

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

E
ester.zhou 已提交
1810
**Parameters**
W
wusongqing 已提交
1811

E
ester.zhou 已提交
1812 1813 1814
| Name    | Type                  | Mandatory| Description                  |
| -------- | ---------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1815

E
ester.zhou 已提交
1816
**Example**
W
wusongqing 已提交
1817 1818 1819

```js
function getActiveNotificationCountCallback(err, data) {
E
esterzhou 已提交
1820 1821 1822 1823 1824
    if (err.code) {
        console.info("getActiveNotificationCount failed " + JSON.stringify(err));
    } else {
        console.info("getActiveNotificationCount success");
    }
W
wusongqing 已提交
1825 1826 1827 1828 1829
}

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```

E
ester.zhou 已提交
1830
## Notification.getActiveNotificationCount
W
wusongqing 已提交
1831

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

E
esterzhou 已提交
1834
Obtains the number of active notifications of this application. This API uses a promise to return the result.
W
wusongqing 已提交
1835

E
ester.zhou 已提交
1836
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1837

E
ester.zhou 已提交
1838
**Return value**
W
wusongqing 已提交
1839

E
esterzhou 已提交
1840 1841
| Type             | Description                                       |
| ----------------- | ------------------------------------------- |
E
ester.zhou 已提交
1842
| Promise\<number\> | Promise used to return the result.|
W
wusongqing 已提交
1843

E
ester.zhou 已提交
1844
**Example**
W
wusongqing 已提交
1845 1846 1847

```js
Notification.getActiveNotificationCount().then((data) => {
E
esterzhou 已提交
1848
	console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1849 1850 1851
});
```

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

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

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

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

E
ester.zhou 已提交
1860
**Parameters**
W
wusongqing 已提交
1861

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

E
ester.zhou 已提交
1866
**Example**
W
wusongqing 已提交
1867 1868 1869

```js
function getActiveNotificationsCallback(err, data) {
E
esterzhou 已提交
1870 1871 1872 1873 1874
    if (err.code) {
        console.info("getActiveNotifications failed " + JSON.stringify(err));
    } else {
        console.info("getActiveNotifications success");
    }
W
wusongqing 已提交
1875 1876 1877 1878 1879
}

Notification.getActiveNotifications(getActiveNotificationsCallback);
```

E
ester.zhou 已提交
1880
## Notification.getActiveNotifications
W
wusongqing 已提交
1881

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

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

E
ester.zhou 已提交
1886
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1887

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

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

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

```js
Notification.getActiveNotifications().then((data) => {
E
esterzhou 已提交
1898
	console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
W
wusongqing 已提交
1899 1900 1901
});
```

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

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

E
esterzhou 已提交
1906
Cancels notifications under a notification group of this application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1907

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

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

E
ester.zhou 已提交
1912 1913
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
E
esterzhou 已提交
1914
| groupName | string                | Yes  | Name of the notification group, which is specified through [NotificationRequest](#notificationrequest) when the notification is published.|
E
ester.zhou 已提交
1915
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1916

E
ester.zhou 已提交
1917
**Example**
W
wusongqing 已提交
1918 1919 1920

```js
function cancelGroupCallback(err) {
E
esterzhou 已提交
1921 1922 1923 1924 1925
    if (err.code) {
        console.info("cancelGroup failed " + JSON.stringify(err));
    } else {
        console.info("cancelGroup success");
    }
W
wusongqing 已提交
1926 1927
}

E
ester.zhou 已提交
1928
let groupName = "GroupName";
W
wusongqing 已提交
1929 1930 1931 1932

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

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

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

E
esterzhou 已提交
1937
Cancels notifications under a notification group of this application. This API uses a promise to return the result.
W
wusongqing 已提交
1938

E
ester.zhou 已提交
1939
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
1940

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

E
ester.zhou 已提交
1943 1944 1945
| Name     | Type  | Mandatory| Description          |
| --------- | ------ | ---- | -------------- |
| groupName | string | Yes  | Name of the notification group.|
W
wusongqing 已提交
1946

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

```js
E
ester.zhou 已提交
1950
let groupName = "GroupName";
W
wusongqing 已提交
1951
Notification.cancelGroup(groupName).then(() => {
E
esterzhou 已提交
1952
	console.info("cancelGroup success");
W
wusongqing 已提交
1953 1954 1955
});
```

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

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

E
esterzhou 已提交
1960
Removes notifications under a notification group of a specified application. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1961

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

E
ester.zhou 已提交
1964 1965
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
1970 1971
| Name     | Type                 | Mandatory| Description                        |
| --------- | --------------------- | ---- | ---------------------------- |
E
esterzhou 已提交
1972
| bundle    | [BundleOption](#bundleoption)          | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
1973 1974
| groupName | string                | Yes  | Name of the notification group.              |
| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
1975

E
ester.zhou 已提交
1976
**Example**
W
wusongqing 已提交
1977 1978 1979

```js
function removeGroupByBundleCallback(err) {
E
esterzhou 已提交
1980 1981 1982 1983 1984
    if (err.code) {
        console.info("removeGroupByBundle failed " + JSON.stringify(err));
    } else {
        console.info("removeGroupByBundle success");
    }
W
wusongqing 已提交
1985 1986
}

E
ester.zhou 已提交
1987 1988
let bundleOption = {bundle: "Bundle"};
let groupName = "GroupName";
W
wusongqing 已提交
1989 1990 1991 1992

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

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

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

E
esterzhou 已提交
1997
Removes notifications under a notification group of a specified application. This API uses a promise to return the result.
W
wusongqing 已提交
1998

E
ester.zhou 已提交
1999
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2000

E
ester.zhou 已提交
2001 2002
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2005
**Parameters**
W
wusongqing 已提交
2006

E
ester.zhou 已提交
2007 2008
| Name     | Type        | Mandatory| Description          |
| --------- | ------------ | ---- | -------------- |
E
esterzhou 已提交
2009
| bundle    | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.    |
E
ester.zhou 已提交
2010
| groupName | string       | Yes  | Name of the notification group.|
W
wusongqing 已提交
2011

E
ester.zhou 已提交
2012
**Example**
W
wusongqing 已提交
2013 2014

```js
E
ester.zhou 已提交
2015 2016
let bundleOption = {bundle: "Bundle"};
let groupName = "GroupName";
W
wusongqing 已提交
2017
Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
E
esterzhou 已提交
2018
	console.info("removeGroupByBundle success");
W
wusongqing 已提交
2019 2020 2021
});
```

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

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

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

E
ester.zhou 已提交
2028
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2029

E
ester.zhou 已提交
2030 2031
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2034
**Parameters**
W
wusongqing 已提交
2035

E
ester.zhou 已提交
2036 2037 2038 2039
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2040

E
ester.zhou 已提交
2041
**Example**
W
wusongqing 已提交
2042 2043 2044

```js
function setDoNotDisturbDateCallback(err) {
E
esterzhou 已提交
2045 2046 2047 2048 2049
    if (err.code) {
        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("setDoNotDisturbDate success");
    }
W
wusongqing 已提交
2050 2051
}

E
ester.zhou 已提交
2052
let doNotDisturbDate = {
E
ester.zhou 已提交
2053
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2054 2055
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2056
};
W
wusongqing 已提交
2057 2058 2059 2060

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

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

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

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

E
ester.zhou 已提交
2067
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2068

E
ester.zhou 已提交
2069 2070
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2073
**Parameters**
W
wusongqing 已提交
2074

E
ester.zhou 已提交
2075 2076 2077
| Name| Type            | Mandatory| Description          |
| ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
W
wusongqing 已提交
2078

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

```js
E
ester.zhou 已提交
2082
let doNotDisturbDate = {
E
ester.zhou 已提交
2083
    type: Notification.DoNotDisturbType.TYPE_ONCE,
W
wusongqing 已提交
2084 2085
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2086
};
W
wusongqing 已提交
2087
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
E
esterzhou 已提交
2088
	console.info("setDoNotDisturbDate success");
W
wusongqing 已提交
2089 2090 2091 2092
});
```


E
ester.zhou 已提交
2093 2094 2095 2096 2097 2098 2099 2100
## 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 已提交
2101 2102
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2105 2106
**Parameters**

E
ester.zhou 已提交
2107 2108 2109
| Name    | Type                 | Mandatory| Description                  |
| -------- | --------------------- | ---- | ---------------------- |
| date     | [DoNotDisturbDate](#donotdisturbdate8)      | Yes  | DND time to set.        |
E
esterzhou 已提交
2110
| userId   | number                | Yes  | ID of the user for whom you want to set the DND time.|
E
ester.zhou 已提交
2111
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2112 2113 2114 2115 2116

**Example**

```js
function setDoNotDisturbDateCallback(err) {
E
esterzhou 已提交
2117 2118 2119 2120 2121
    if (err.code) {
        console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("setDoNotDisturbDate success");
    }
E
ester.zhou 已提交
2122 2123
}

E
ester.zhou 已提交
2124
let doNotDisturbDate = {
E
ester.zhou 已提交
2125 2126 2127
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2128
};
E
ester.zhou 已提交
2129

E
ester.zhou 已提交
2130
let userId = 1
E
ester.zhou 已提交
2131 2132 2133 2134 2135 2136 2137 2138 2139 2140
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 已提交
2141

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

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

E
ester.zhou 已提交
2146
**Parameters**
W
wusongqing 已提交
2147

E
ester.zhou 已提交
2148 2149 2150
| Name  | Type            | Mandatory| Description          |
| ------ | ---------------- | ---- | -------------- |
| date   | [DoNotDisturbDate](#donotdisturbdate8) | Yes  | DND time to set.|
E
esterzhou 已提交
2151
| userId | number           | Yes  | ID of the user for whom you want to set the DND time.|
W
wusongqing 已提交
2152

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

E
ester.zhou 已提交
2155
```js
E
ester.zhou 已提交
2156
let doNotDisturbDate = {
E
ester.zhou 已提交
2157 2158 2159
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
E
ester.zhou 已提交
2160
};
E
ester.zhou 已提交
2161

E
ester.zhou 已提交
2162
let userId = 1;
E
ester.zhou 已提交
2163 2164

Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
E
esterzhou 已提交
2165
	console.info("setDoNotDisturbDate success");
E
ester.zhou 已提交
2166 2167 2168 2169 2170
});
```


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

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

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

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

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

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

E
ester.zhou 已提交
2182 2183
**Parameters**

E
ester.zhou 已提交
2184 2185 2186
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2187 2188

**Example**
W
wusongqing 已提交
2189 2190

```js
E
esterzhou 已提交
2191
function getDoNotDisturbDateCallback(err, data) {
E
esterzhou 已提交
2192 2193 2194 2195 2196
    if (err.code) {
        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("getDoNotDisturbDate success");
    }
W
wusongqing 已提交
2197 2198 2199 2200 2201
}

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```

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

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

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

E
ester.zhou 已提交
2208
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2209

E
ester.zhou 已提交
2210 2211
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2214
**Return value**
W
wusongqing 已提交
2215

E
esterzhou 已提交
2216 2217
| Type                                             | Description                                     |
| ------------------------------------------------- | ----------------------------------------- |
E
ester.zhou 已提交
2218
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2219

E
ester.zhou 已提交
2220
**Example**
W
wusongqing 已提交
2221 2222 2223

```js
Notification.getDoNotDisturbDate().then((data) => {
E
esterzhou 已提交
2224
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
W
wusongqing 已提交
2225 2226 2227 2228
});
```


E
ester.zhou 已提交
2229 2230 2231 2232 2233 2234 2235 2236
## 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 已提交
2237 2238 2239 2240
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2241 2242
**Parameters**

E
ester.zhou 已提交
2243 2244 2245 2246
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes  | Callback used to return the result.|
| userId   | number                            | Yes  | User ID.|
E
ester.zhou 已提交
2247 2248 2249 2250 2251

**Example**

```js
function getDoNotDisturbDateCallback(err,data) {
E
esterzhou 已提交
2252 2253 2254 2255 2256
    if (err.code) {
        console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
    } else {
        console.info("getDoNotDisturbDate success");
    }
E
ester.zhou 已提交
2257 2258
}

E
ester.zhou 已提交
2259
let userId = 1;
E
ester.zhou 已提交
2260 2261 2262 2263 2264

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

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

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

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

E
ester.zhou 已提交
2270
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2271

E
ester.zhou 已提交
2272 2273 2274 2275
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

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

E
ester.zhou 已提交
2278 2279 2280
| Name    | Type                             | Mandatory| Description                  |
| -------- | --------------------------------- | ---- | ---------------------- |
| userId   | number                            | Yes  | User ID.|
W
wusongqing 已提交
2281

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

E
esterzhou 已提交
2284 2285
| Type                                             | Description                                     |
| ------------------------------------------------- | ----------------------------------------- |
E
ester.zhou 已提交
2286
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.|
W
wusongqing 已提交
2287

E
ester.zhou 已提交
2288 2289 2290
**Example**

```js
E
ester.zhou 已提交
2291
let userId = 1;
E
ester.zhou 已提交
2292 2293

Notification.getDoNotDisturbDate(userId).then((data) => {
E
esterzhou 已提交
2294
	console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
E
ester.zhou 已提交
2295 2296 2297 2298 2299 2300 2301 2302
});
```


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

supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void

E
esterzhou 已提交
2303
Checks whether DND mode is supported. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
2304 2305 2306

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

E
ester.zhou 已提交
2307 2308
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2311 2312
**Parameters**

E
ester.zhou 已提交
2313 2314 2315
| Name    | Type                    | Mandatory| Description                            |
| -------- | ------------------------ | ---- | -------------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
2316 2317

**Example**
W
wusongqing 已提交
2318 2319 2320

```js
function supportDoNotDisturbModeCallback(err,data) {
E
esterzhou 已提交
2321 2322 2323 2324 2325
    if (err.code) {
        console.info("supportDoNotDisturbMode failed " + JSON.stringify(err));
    } else {
        console.info("supportDoNotDisturbMode success");
    }
W
wusongqing 已提交
2326 2327 2328 2329 2330
}

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```

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

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

E
esterzhou 已提交
2335
Checks whether DND mode is supported. This API uses a promise to return the result.
W
wusongqing 已提交
2336

E
ester.zhou 已提交
2337
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2338

E
ester.zhou 已提交
2339 2340
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2343
**Return value**
W
wusongqing 已提交
2344

E
ester.zhou 已提交
2345 2346 2347
| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2348

E
ester.zhou 已提交
2349
**Example**
W
wusongqing 已提交
2350 2351 2352

```js
Notification.supportDoNotDisturbMode().then((data) => {
E
esterzhou 已提交
2353
	console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
W
wusongqing 已提交
2354 2355 2356
});
```

E
ester.zhou 已提交
2357
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2358 2359 2360

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

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

E
ester.zhou 已提交
2363
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2364

E
ester.zhou 已提交
2365 2366 2367
**Parameters**

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

E
ester.zhou 已提交
2372
**Example**
W
wusongqing 已提交
2373 2374

```javascript
E
ester.zhou 已提交
2375
let templateName = 'process';
W
wusongqing 已提交
2376
function isSupportTemplateCallback(err, data) {
E
esterzhou 已提交
2377 2378 2379 2380 2381
    if (err.code) {
        console.info("isSupportTemplate failed " + JSON.stringify(err));
    } else {
        console.info("isSupportTemplate success");
    }
W
wusongqing 已提交
2382 2383 2384 2385 2386
}

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

E
ester.zhou 已提交
2387
## Notification.isSupportTemplate<sup>8+</sup>
W
wusongqing 已提交
2388 2389 2390

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

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

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

E
ester.zhou 已提交
2395 2396 2397
**Parameters**

| Name      | Type  | Mandatory| Description    |
W
wusongqing 已提交
2398
| ------------ | ------ | ---- | -------- |
E
ester.zhou 已提交
2399
| templateName | string | Yes  | Template name.|
W
wusongqing 已提交
2400

E
ester.zhou 已提交
2401
**Return value**
W
wusongqing 已提交
2402

E
ester.zhou 已提交
2403
| Type              | Description           |
W
wusongqing 已提交
2404 2405 2406
| ------------------ | --------------- |
| Promise\<boolean\> | Promise used to return the result.|

E
ester.zhou 已提交
2407
**Example**
W
wusongqing 已提交
2408 2409

```javascript
E
ester.zhou 已提交
2410
let templateName = 'process';
W
wusongqing 已提交
2411 2412

Notification.isSupportTemplate(templateName).then((data) => {
E
esterzhou 已提交
2413
    console.info("isSupportTemplate success, data: " + JSON.stringify(data));
W
wusongqing 已提交
2414 2415 2416
});
```

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

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

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

E
ester.zhou 已提交
2423
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2424

E
ester.zhou 已提交
2425
**Parameters**
W
wusongqing 已提交
2426

E
ester.zhou 已提交
2427 2428 2429
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2430

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

E
ester.zhou 已提交
2433
```javascript
E
esterzhou 已提交
2434
function requestEnableNotificationCallback(err) {
E
esterzhou 已提交
2435 2436 2437
    if (err.code) {
        console.info("requestEnableNotification failed " + JSON.stringify(err));
    } else {
E
esterzhou 已提交
2438
        console.info("requestEnableNotification success");
E
esterzhou 已提交
2439
    }
E
ester.zhou 已提交
2440 2441
};

E
ester.zhou 已提交
2442
Notification.requestEnableNotification(requestEnableNotificationCallback);
W
wusongqing 已提交
2443 2444
```

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

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

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

E
ester.zhou 已提交
2451
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2452

E
ester.zhou 已提交
2453
**Example**
W
wusongqing 已提交
2454

E
ester.zhou 已提交
2455
```javascript
E
esterzhou 已提交
2456 2457 2458
Notification.requestEnableNotification().then(() => {
    console.info("requestEnableNotification success");
});
E
ester.zhou 已提交
2459
```
W
wusongqing 已提交
2460 2461


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

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

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

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

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

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

E
ester.zhou 已提交
2474
**Parameters**
W
wusongqing 已提交
2475

E
ester.zhou 已提交
2476 2477
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
2478
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|
E
ester.zhou 已提交
2479
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2480

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

E
ester.zhou 已提交
2483
```javascript
E
esterzhou 已提交
2484
function enabledNotificationCallback(err) {
E
esterzhou 已提交
2485 2486 2487 2488 2489
    if (err.code) {
        console.info("enableDistributed failed " + JSON.stringify(err));
    } else {
        console.info("enableDistributed success");
    }
E
ester.zhou 已提交
2490
};
W
wusongqing 已提交
2491

E
ester.zhou 已提交
2492
let enable = true;
W
wusongqing 已提交
2493

E
ester.zhou 已提交
2494
Notification.enableDistributed(enable, enabledNotificationCallback);
W
wusongqing 已提交
2495 2496
```

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

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

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

E
ester.zhou 已提交
2503
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2504

E
ester.zhou 已提交
2505 2506
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2509
**Parameters**
W
wusongqing 已提交
2510

E
ester.zhou 已提交
2511 2512
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
2513
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.|
W
wusongqing 已提交
2514

E
ester.zhou 已提交
2515
**Example**
W
wusongqing 已提交
2516

E
ester.zhou 已提交
2517
```javascript
E
ester.zhou 已提交
2518
let enable = true;
E
esterzhou 已提交
2519 2520 2521
Notification.enableDistributed(enable).then(() => {
    console.info("enableDistributed success");
});
E
ester.zhou 已提交
2522
```
W
wusongqing 已提交
2523 2524


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

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

E
esterzhou 已提交
2529
Checks whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2530

E
ester.zhou 已提交
2531
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2532

E
ester.zhou 已提交
2533
**Parameters**
W
wusongqing 已提交
2534

E
ester.zhou 已提交
2535 2536 2537
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2538

E
ester.zhou 已提交
2539
**Example**
W
wusongqing 已提交
2540

E
ester.zhou 已提交
2541
```javascript
E
esterzhou 已提交
2542
function isDistributedEnabledCallback(err, data) {
E
esterzhou 已提交
2543 2544 2545
    if (err.code) {
        console.info("isDistributedEnabled failed " + JSON.stringify(err));
    } else {
E
esterzhou 已提交
2546
        console.info("isDistributedEnabled success " + JSON.stringify(data));
E
esterzhou 已提交
2547
    }
E
ester.zhou 已提交
2548
};
W
wusongqing 已提交
2549

E
ester.zhou 已提交
2550
Notification.isDistributedEnabled(isDistributedEnabledCallback);
E
ester.zhou 已提交
2551
```
W
wusongqing 已提交
2552

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

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

E
esterzhou 已提交
2557
Checks whether this device supports distributed notifications. This API uses a promise to return the result.
W
wusongqing 已提交
2558

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

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

E
esterzhou 已提交
2563 2564 2565
| Type              | Description                                         |
| ------------------ | --------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
W
wusongqing 已提交
2566

E
ester.zhou 已提交
2567 2568 2569
**Example**

```javascript
E
esterzhou 已提交
2570 2571 2572
Notification.isDistributedEnabled().then((data) => {
    console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
});
W
wusongqing 已提交
2573 2574 2575
```


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

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

E
esterzhou 已提交
2580
Sets whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2581

E
ester.zhou 已提交
2582
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2583

E
ester.zhou 已提交
2584 2585
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2588
**Parameters**
W
wusongqing 已提交
2589

E
ester.zhou 已提交
2590 2591
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
2592
| bundle   | [BundleOption](#bundleoption)             | Yes  | Bundle information of the application.                  |
E
ester.zhou 已提交
2593 2594
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                      |
| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2595

E
ester.zhou 已提交
2596
**Example**
W
wusongqing 已提交
2597

E
ester.zhou 已提交
2598
```javascript
E
esterzhou 已提交
2599
function enableDistributedByBundleCallback(err) {
E
esterzhou 已提交
2600 2601 2602 2603 2604
    if (err.code) {
        console.info("enableDistributedByBundle failed " + JSON.stringify(err));
    } else {
        console.info("enableDistributedByBundle success");
    }
E
ester.zhou 已提交
2605
};
W
wusongqing 已提交
2606

E
ester.zhou 已提交
2607
let bundle = {
E
ester.zhou 已提交
2608
    bundle: "bundleName1",
E
ester.zhou 已提交
2609
};
W
wusongqing 已提交
2610

E
ester.zhou 已提交
2611
let enable = true;
W
wusongqing 已提交
2612

E
ester.zhou 已提交
2613 2614
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
W
wusongqing 已提交
2615

E
ester.zhou 已提交
2616 2617
## Notification.enableDistributedByBundle<sup>8+</sup>

E
ester.zhou 已提交
2618
enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
E
ester.zhou 已提交
2619

E
esterzhou 已提交
2620
Sets whether a specified application supports distributed notifications. This API uses a promise to return the result.
E
ester.zhou 已提交
2621 2622 2623

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

E
ester.zhou 已提交
2624 2625
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2628 2629 2630 2631 2632 2633 2634 2635 2636 2637
**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.               |
| enable   | boolean                  | Yes  | Whether the device supports distributed notifications.                 |

**Example**

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

E
ester.zhou 已提交
2642
let enable = true;
E
esterzhou 已提交
2643 2644 2645
Notification.enableDistributedByBundle(bundle, enable).then(() => {
    console.info("enableDistributedByBundle success");
});
W
wusongqing 已提交
2646 2647
```

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

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

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

E
ester.zhou 已提交
2654
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
2655

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

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

E
ester.zhou 已提交
2660
**Parameters**
W
wusongqing 已提交
2661

E
ester.zhou 已提交
2662 2663 2664 2665
| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.                    |
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2666

E
ester.zhou 已提交
2667
**Example**
W
wusongqing 已提交
2668

E
ester.zhou 已提交
2669
```javascript
E
esterzhou 已提交
2670
function isDistributedEnabledByBundleCallback(err, data) {
E
esterzhou 已提交
2671 2672 2673
    if (err.code) {
        console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
    } else {
E
esterzhou 已提交
2674
        console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
E
esterzhou 已提交
2675
    }
E
ester.zhou 已提交
2676
};
W
wusongqing 已提交
2677

E
ester.zhou 已提交
2678
let bundle = {
E
ester.zhou 已提交
2679
    bundle: "bundleName1",
E
ester.zhou 已提交
2680
};
W
wusongqing 已提交
2681

E
ester.zhou 已提交
2682
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
E
ester.zhou 已提交
2683
```
W
wusongqing 已提交
2684

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

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

E
esterzhou 已提交
2689
Checks whether a specified application supports distributed notifications. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
2690

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

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

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

E
ester.zhou 已提交
2697 2698 2699 2700 2701 2702 2703 2704
**Parameters**

| Name  | Type                    | Mandatory| Description                      |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | [BundleOption](#bundleoption)             | Yes  | Application bundle.               |

**Return value**

E
esterzhou 已提交
2705 2706 2707
| Type              | Description                                             |
| ------------------ | ------------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
E
ester.zhou 已提交
2708 2709 2710 2711

**Example**

```javascript
E
ester.zhou 已提交
2712
let bundle = {
E
ester.zhou 已提交
2713
    bundle: "bundleName1",
E
ester.zhou 已提交
2714
};
E
ester.zhou 已提交
2715

E
esterzhou 已提交
2716 2717 2718
Notification.isDistributedEnabledByBundle(bundle).then((data) => {
    console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
});
W
wusongqing 已提交
2719 2720 2721
```


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

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

E
ester.zhou 已提交
2726
Obtains the notification reminder type. 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
| Name  | Type                              | Mandatory| Description                      |
| -------- | --------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
2739

E
ester.zhou 已提交
2740
**Example**
W
wusongqing 已提交
2741

E
ester.zhou 已提交
2742
```javascript
E
esterzhou 已提交
2743
function getDeviceRemindTypeCallback(err,data) {
E
esterzhou 已提交
2744 2745 2746 2747 2748
    if (err.code) {
        console.info("getDeviceRemindType failed " + JSON.stringify(err));
    } else {
        console.info("getDeviceRemindType success");
    }
E
ester.zhou 已提交
2749
};
W
wusongqing 已提交
2750

E
ester.zhou 已提交
2751 2752
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
W
wusongqing 已提交
2753

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

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

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

E
ester.zhou 已提交
2760 2761
**System capability**: SystemCapability.Notification.Notification

E
ester.zhou 已提交
2762 2763
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

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

E
ester.zhou 已提交
2766 2767 2768 2769 2770 2771 2772 2773 2774
**Return value**

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

**Example**

```javascript
E
esterzhou 已提交
2775 2776 2777
Notification.getDeviceRemindType().then((data) => {
    console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
});
W
wusongqing 已提交
2778 2779
```

E
ester.zhou 已提交
2780

E
ester.zhou 已提交
2781 2782 2783 2784 2785 2786 2787 2788
## 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 已提交
2789 2790
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

**Parameters**

E
esterzhou 已提交
2795 2796 2797 2798 2799 2800
| Name              | Type                                       | Mandatory| Description                                    |
| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request              | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                      |
| userId               | number                                      | Yes  | User ID.                                |
| callback             | AsyncCallback                               | Yes  | Callback used to return the result.                |
E
ester.zhou 已提交
2801 2802 2803 2804

**Example**

```js
E
esterzhou 已提交
2805 2806
// publishAsBundle callback
function callback(err) {
E
esterzhou 已提交
2807 2808 2809 2810 2811
    if (err.code) {
        console.info("publishAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("publishAsBundle success");
    }
E
ester.zhou 已提交
2812 2813
}
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
2814
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
2815
// User ID
E
ester.zhou 已提交
2816
let userId = 100;
E
ester.zhou 已提交
2817
// NotificationRequest object
E
esterzhou 已提交
2818
let request = {
E
ester.zhou 已提交
2819 2820 2821 2822 2823 2824 2825 2826 2827
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
2828
};
E
ester.zhou 已提交
2829

E
esterzhou 已提交
2830
Notification.publishAsBundle(request, representativeBundle, userId, callback);
E
ester.zhou 已提交
2831 2832 2833 2834 2835 2836 2837 2838 2839 2840
```

## 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 已提交
2841 2842
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER

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

**Parameters**


| Name              | Type                                       | Mandatory| Description                                         |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
E
esterzhou 已提交
2850
| request              | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish.|
E
ester.zhou 已提交
2851
| representativeBundle | string                                      | Yes  | Bundle name of the application whose notification function is taken over by the reminder agent.                           |
E
esterzhou 已提交
2852
| userId               | number                                      | Yes  | User ID.                           |
E
ester.zhou 已提交
2853 2854 2855 2856 2857

**Example**

```js
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
2858
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
2859
// User ID
E
ester.zhou 已提交
2860
let userId = 100;
E
ester.zhou 已提交
2861
// NotificationRequest object
E
ester.zhou 已提交
2862
let request = {
E
ester.zhou 已提交
2863 2864 2865 2866 2867 2868 2869 2870 2871
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
E
ester.zhou 已提交
2872
};
E
ester.zhou 已提交
2873

E
esterzhou 已提交
2874 2875
Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
	console.info("publishAsBundle success");
E
ester.zhou 已提交
2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886
});
```

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

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

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

E
ester.zhou 已提交
2893
**Parameters**
E
ester.zhou 已提交
2894 2895 2896 2897 2898

| 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.      |
E
esterzhou 已提交
2899
| userId               | number        | Yes  | User ID.      |
E
ester.zhou 已提交
2900 2901 2902 2903 2904
| callback             | AsyncCallback | Yes  | Callback used to return the result.|

**Example**

```js
E
esterzhou 已提交
2905
// cancelAsBundle
E
ester.zhou 已提交
2906
function cancelAsBundleCallback(err) {
E
esterzhou 已提交
2907 2908 2909 2910 2911
    if (err.code) {
        console.info("cancelAsBundle failed " + JSON.stringify(err));
    } else {
        console.info("cancelAsBundle success");
    }
E
ester.zhou 已提交
2912 2913
}
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
2914
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
2915
// User ID
E
ester.zhou 已提交
2916
let userId = 100;
E
ester.zhou 已提交
2917 2918 2919 2920 2921 2922 2923 2924

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

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

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

E
esterzhou 已提交
2925
Cancels a notification published by the reminder agent. This API uses a promise to return the result.
E
ester.zhou 已提交
2926 2927 2928

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

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

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

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

E
ester.zhou 已提交
2935
**Parameters**
E
ester.zhou 已提交
2936 2937 2938 2939 2940

| 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.|
E
esterzhou 已提交
2941
| userId               | number | Yes  | User ID.|
E
ester.zhou 已提交
2942 2943 2944 2945 2946

**Example**

```js
// Bundle name of the application whose notification function is taken over by the reminder agent
E
ester.zhou 已提交
2947
let representativeBundle = "com.example.demo";
E
esterzhou 已提交
2948
// User ID
E
ester.zhou 已提交
2949
let userId = 100;
E
ester.zhou 已提交
2950 2951

Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
E
esterzhou 已提交
2952
	console.info("cancelAsBundle success");
E
ester.zhou 已提交
2953 2954 2955
});
```

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

E
ester.zhou 已提交
2958
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
2959

E
esterzhou 已提交
2960
Sets the enabled status of a notification slot type for a specified application. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
2961 2962 2963 2964 2965

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

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

E
ester.zhou 已提交
2966 2967
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
2968 2969 2970 2971
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
E
esterzhou 已提交
2972
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
2973 2974 2975 2976 2977 2978 2979
| 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
E
esterzhou 已提交
2980
// enableNotificationSlot
E
ester.zhou 已提交
2981
function enableSlotCallback(err) {
E
esterzhou 已提交
2982 2983 2984 2985 2986
    if (err.code) {
        console.info("enableNotificationSlot failed " + JSON.stringify(err));
    } else {
        console.info("enableNotificationSlot success");
    }
E
ester.zhou 已提交
2987 2988 2989 2990
};

Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
2991
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
2992 2993 2994 2995
    true,
    enableSlotCallback);
```

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

E
ester.zhou 已提交
2998
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> 
E
ester.zhou 已提交
2999

E
esterzhou 已提交
3000
Sets the enabled status of a notification slot type for a specified application. This API uses a promise to return the result.
E
ester.zhou 已提交
3001 3002 3003 3004 3005

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

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

E
ester.zhou 已提交
3006 3007
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3008 3009 3010 3011
**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
E
esterzhou 已提交
3012
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.  |
E
ester.zhou 已提交
3013 3014 3015 3016 3017 3018
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|
| enable | boolean                       | Yes  | Whether to enable notification.    |

**Example**

```js
E
esterzhou 已提交
3019 3020 3021 3022 3023
// enableNotificationSlot
Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", },
    Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => {
    console.info("enableNotificationSlot success");
});
E
ester.zhou 已提交
3024 3025
```

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

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

E
esterzhou 已提交
3030
Checks whether a specified notification slot type is enabled for a specified application. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3031 3032 3033 3034 3035

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

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

E
ester.zhou 已提交
3036 3037
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3038 3039 3040 3041
**Parameters**

| Name  | Type                         | Mandatory| Description                  |
| -------- | ----------------------------- | ---- | ---------------------- |
E
esterzhou 已提交
3042
| bundle   | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.          |
E
ester.zhou 已提交
3043
| type     | [SlotType](#slottype)         | Yes  | Notification slot type.        |
E
ester.zhou 已提交
3044
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3045 3046 3047 3048

**Example**

```js
E
esterzhou 已提交
3049
// isNotificationSlotEnabled
E
ester.zhou 已提交
3050
function getEnableSlotCallback(err, data) {
E
esterzhou 已提交
3051 3052 3053 3054 3055
    if (err.code) {
        console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
    } else {
        console.info("isNotificationSlotEnabled success");
    }
E
ester.zhou 已提交
3056 3057 3058 3059
};

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
E
ester.zhou 已提交
3060
    Notification.SlotType.SOCIAL_COMMUNICATION,
E
ester.zhou 已提交
3061 3062 3063
    getEnableSlotCallback);
```

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

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

E
esterzhou 已提交
3068
Checks whether a specified notification slot type is enabled for a specified application. This API uses a promise to return the result.
E
ester.zhou 已提交
3069 3070 3071 3072 3073

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

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

E
ester.zhou 已提交
3074 3075
**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

E
ester.zhou 已提交
3076 3077 3078 3079
**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
E
esterzhou 已提交
3080
| bundle | [BundleOption](#bundleoption) | Yes  | Bundle information of the application.  |
E
ester.zhou 已提交
3081 3082
| type   | [SlotType](#slottype)         | Yes  | Notification slot type.|

E
ester.zhou 已提交
3083 3084
**Return value**

E
esterzhou 已提交
3085 3086 3087
| Type              | Description                           |
| ------------------ | ------------------------------- |
| Promise\<boolean\> | Promise used to return the result.|
E
ester.zhou 已提交
3088

E
ester.zhou 已提交
3089 3090 3091
**Example**

```js
E
esterzhou 已提交
3092 3093 3094 3095 3096
// isNotificationSlotEnabled
Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
    Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
    console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
E
ester.zhou 已提交
3097 3098
```

E
ester.zhou 已提交
3099

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

E
ester.zhou 已提交
3102
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
E
ester.zhou 已提交
3103

E
esterzhou 已提交
3104
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116

**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
esterzhou 已提交
3117
| enable | boolean | Yes  | Whether the feature is enabled.  |
E
ester.zhou 已提交
3118
| callback | AsyncCallback\<void\>    | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3119 3120 3121 3122 3123 3124 3125

**Example**

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

E
esterzhou 已提交
3126
function callback(err) {
E
esterzhou 已提交
3127 3128 3129 3130 3131
    if (err.code) {
        console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
    } else {
        console.info("setSyncNotificationEnabledWithoutApp success");
    }
E
ester.zhou 已提交
3132 3133
}

E
esterzhou 已提交
3134
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
E
ester.zhou 已提交
3135 3136 3137
```


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

E
ester.zhou 已提交
3140
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
E
ester.zhou 已提交
3141

E
esterzhou 已提交
3142
Sets whether to enable the notification sync feature for devices where the application is not installed. This API uses a promise to return the result.
E
ester.zhou 已提交
3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154

**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
esterzhou 已提交
3155
| enable | boolean | Yes  | Whether the feature is enabled.  |
E
ester.zhou 已提交
3156 3157 3158 3159 3160 3161

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<void\> | Promise used to return the result.|
E
ester.zhou 已提交
3162 3163 3164 3165 3166 3167 3168

**Example**

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

E
esterzhou 已提交
3169 3170 3171 3172 3173
Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
    console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => {
    console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
});
E
ester.zhou 已提交
3174 3175 3176
```


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

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

E
esterzhou 已提交
3181
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses an asynchronous callback to return the result.
E
ester.zhou 已提交
3182 3183 3184 3185 3186 3187 3188 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.

**Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER

**Parameters**

| Name| Type                         | Mandatory| Description          |
| ------ | ----------------------------- | ---- | -------------- |
| userId | number | Yes  | User ID.  |
E
esterzhou 已提交
3194
| callback | AsyncCallback\<boolean\>         | Yes  | Callback used to return the result.|
E
ester.zhou 已提交
3195 3196 3197 3198 3199 3200

**Example**

```js
let userId = 100;

E
esterzhou 已提交
3201
function getSyncNotificationEnabledWithoutAppCallback(err, data) {
E
ester.zhou 已提交
3202
    if (err) {
E
esterzhou 已提交
3203
        console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
E
ester.zhou 已提交
3204
    } else {
E
esterzhou 已提交
3205
        console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
E
ester.zhou 已提交
3206
    }
E
ester.zhou 已提交
3207 3208
}

E
ester.zhou 已提交
3209
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
E
ester.zhou 已提交
3210 3211 3212
```


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

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

E
esterzhou 已提交
3217
Obtains whether the notification sync feature is enabled for devices where the application is not installed. This API uses a promise to return the result.
E
ester.zhou 已提交
3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232

**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**

E
esterzhou 已提交
3233 3234 3235
| Type              | Description                                                        |
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.|
E
ester.zhou 已提交
3236 3237 3238 3239 3240

**Example**

```js
let userId = 100;
E
esterzhou 已提交
3241 3242 3243 3244 3245
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
    console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => {
    console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
});
E
ester.zhou 已提交
3246 3247
```

E
ester.zhou 已提交
3248 3249
## NotificationSubscriber

E
esterzhou 已提交
3250
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).
E
esterzhou 已提交
3251

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

E
ester.zhou 已提交
3254 3255
### onConsume

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

E
ester.zhou 已提交
3258
Callback for receiving notifications.
W
wusongqing 已提交
3259

E
ester.zhou 已提交
3260 3261
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
3264 3265 3266 3267
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
3268
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification received.|
E
ester.zhou 已提交
3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279

**Example**

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

E
ester.zhou 已提交
3281 3282 3283 3284
function onConsumeCallback(data) {
    let req = data.request;
    console.info('===> onConsume callback req.id:' + req.id);
};
W
wusongqing 已提交
3285

E
ester.zhou 已提交
3286
let subscriber = {
E
ester.zhou 已提交
3287 3288
    onConsume: onConsumeCallback
};
W
wusongqing 已提交
3289

E
ester.zhou 已提交
3290 3291
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3292

E
ester.zhou 已提交
3293
### onCancel
W
wusongqing 已提交
3294

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

E
esterzhou 已提交
3297
Callback for canceling notifications.
W
wusongqing 已提交
3298

E
ester.zhou 已提交
3299
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3300

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

E
ester.zhou 已提交
3303
**Parameters**
W
wusongqing 已提交
3304

E
ester.zhou 已提交
3305 3306
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
3307
| data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Information about the notification to cancel.|
W
wusongqing 已提交
3308

E
ester.zhou 已提交
3309
**Example**
W
wusongqing 已提交
3310

E
ester.zhou 已提交
3311 3312 3313 3314
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3315
    } else {
E
ester.zhou 已提交
3316
        console.info("subscribeCallback");
W
wusongqing 已提交
3317
    }
E
ester.zhou 已提交
3318 3319 3320 3321 3322
};

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

E
ester.zhou 已提交
3325
let subscriber = {
E
ester.zhou 已提交
3326 3327
    onCancel: onCancelCallback
};
W
wusongqing 已提交
3328

E
ester.zhou 已提交
3329
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3330 3331
```

E
ester.zhou 已提交
3332
### onUpdate
W
wusongqing 已提交
3333

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

E
ester.zhou 已提交
3336
Callback for notification sorting updates.
W
wusongqing 已提交
3337

E
ester.zhou 已提交
3338
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3339

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

E
ester.zhou 已提交
3342
**Parameters**
W
wusongqing 已提交
3343

E
ester.zhou 已提交
3344 3345
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
esterzhou 已提交
3346
| data | [NotificationSortingMap](#notificationsortingmap) | Yes| Latest notification sorting list.|
W
wusongqing 已提交
3347

E
ester.zhou 已提交
3348
**Example**
W
wusongqing 已提交
3349

E
ester.zhou 已提交
3350 3351 3352 3353 3354 3355 3356 3357
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3358

E
esterzhou 已提交
3359 3360
function onUpdateCallback(map) {
    console.info('===> onUpdateCallback map:' + JSON.stringify(map));
E
ester.zhou 已提交
3361
}
W
wusongqing 已提交
3362

E
ester.zhou 已提交
3363
let subscriber = {
E
ester.zhou 已提交
3364 3365
    onUpdate: onUpdateCallback
};
W
wusongqing 已提交
3366

E
ester.zhou 已提交
3367 3368
Notification.subscribe(subscriber, subscribeCallback);
```
W
wusongqing 已提交
3369

E
ester.zhou 已提交
3370
### onConnect
W
wusongqing 已提交
3371

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

E
ester.zhou 已提交
3374 3375 3376 3377
Callback for subscription.

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

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

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

E
ester.zhou 已提交
3395
let subscriber = {
E
ester.zhou 已提交
3396 3397
    onConnect: onConnectCallback
};
W
wusongqing 已提交
3398

E
ester.zhou 已提交
3399
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3400 3401
```

E
ester.zhou 已提交
3402
### onDisconnect
W
wusongqing 已提交
3403

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

E
ester.zhou 已提交
3406
Callback for unsubscription.
W
wusongqing 已提交
3407

E
ester.zhou 已提交
3408
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3409

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

E
ester.zhou 已提交
3412
**Example**
W
wusongqing 已提交
3413

E
ester.zhou 已提交
3414 3415 3416 3417 3418 3419 3420 3421
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
E
esterzhou 已提交
3422 3423 3424 3425 3426 3427 3428
function unsubscribeCallback(err) {
    if (err.code) {
        console.info("unsubscribe failed " + JSON.stringify(err));
    } else {
        console.info("unsubscribeCallback");
    }
};
W
wusongqing 已提交
3429

E
esterzhou 已提交
3430 3431 3432
function onConnectCallback() {
    console.info('===> onConnect in test');
}
E
ester.zhou 已提交
3433 3434 3435
function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}
W
wusongqing 已提交
3436

E
ester.zhou 已提交
3437
let subscriber = {
E
esterzhou 已提交
3438
    onConnect: onConnectCallback,
E
ester.zhou 已提交
3439 3440
    onDisconnect: onDisconnectCallback
};
W
wusongqing 已提交
3441

E
esterzhou 已提交
3442
// The onConnect callback is invoked when subscription to the notification is complete.
E
ester.zhou 已提交
3443
Notification.subscribe(subscriber, subscribeCallback);
E
esterzhou 已提交
3444 3445
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
Notification.unsubscribe(subscriber, unsubscribeCallback);
E
ester.zhou 已提交
3446
```
W
wusongqing 已提交
3447

E
ester.zhou 已提交
3448
### onDestroy
W
wusongqing 已提交
3449

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

E
ester.zhou 已提交
3452
Callback for service disconnection.
W
wusongqing 已提交
3453

E
ester.zhou 已提交
3454
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3455

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

E
ester.zhou 已提交
3458 3459 3460 3461 3462 3463
**Example**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
W
wusongqing 已提交
3464
    } else {
E
ester.zhou 已提交
3465
        console.info("subscribeCallback");
W
wusongqing 已提交
3466
    }
E
ester.zhou 已提交
3467 3468 3469 3470
};

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

E
ester.zhou 已提交
3473
let subscriber = {
E
ester.zhou 已提交
3474 3475
    onDestroy: onDestroyCallback
};
W
wusongqing 已提交
3476

E
ester.zhou 已提交
3477
Notification.subscribe(subscriber, subscribeCallback);
W
wusongqing 已提交
3478 3479
```

E
ester.zhou 已提交
3480 3481
### onDoNotDisturbDateChange<sup>8+</sup>

E
ester.zhou 已提交
3482
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
E
ester.zhou 已提交
3483 3484 3485 3486 3487

Callback for DND time setting updates.

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

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

E
ester.zhou 已提交
3490 3491 3492 3493
**Parameters**

| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
E
ester.zhou 已提交
3494
| mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.|
E
ester.zhou 已提交
3495 3496 3497 3498 3499 3500 3501 3502 3503 3504

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

E
esterzhou 已提交
3506 3507
function onDoNotDisturbDateChangeCallback(mode) {
    console.info('===> onDoNotDisturbDateChange:' + mode);
E
ester.zhou 已提交
3508
}
W
wusongqing 已提交
3509

E
ester.zhou 已提交
3510
let subscriber = {
E
ester.zhou 已提交
3511 3512 3513
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
Notification.subscribe(subscriber, subscribeCallback);
E
esterzhou 已提交
3514

E
ester.zhou 已提交
3515
let doNotDisturbDate = {
E
esterzhou 已提交
3516 3517 3518 3519 3520 3521 3522 3523
    type: Notification.DoNotDisturbType.TYPE_ONCE,
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
}
// Set the onDoNotDisturbDateChange callback for DND time setting updates.
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
	console.info("setDoNotDisturbDate sucess");
});
E
ester.zhou 已提交
3524
```
W
wusongqing 已提交
3525 3526


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

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

E
esterzhou 已提交
3531
Listens for the notification enabled status changes. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
3532

E
ester.zhou 已提交
3533
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3534

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

E
ester.zhou 已提交
3537
**Parameters**
W
wusongqing 已提交
3538

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

E
ester.zhou 已提交
3543
**Example**
W
wusongqing 已提交
3544

E
ester.zhou 已提交
3545 3546 3547 3548 3549 3550 3551 3552
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};
W
wusongqing 已提交
3553

E
ester.zhou 已提交
3554
function onEnabledNotificationChangedCallback(callbackData) {
E
esterzhou 已提交
3555 3556 3557
    console.info("bundle: " + callbackData.bundle);
    console.info("uid: " + callbackData.uid);
    console.info("enable: " + callbackData.enable);
E
ester.zhou 已提交
3558
};
W
wusongqing 已提交
3559

E
ester.zhou 已提交
3560
let subscriber = {
E
ester.zhou 已提交
3561 3562 3563
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
Notification.subscribe(subscriber, subscribeCallback);
E
esterzhou 已提交
3564

E
ester.zhou 已提交
3565
let bundle = {
E
esterzhou 已提交
3566 3567 3568 3569 3570 3571
    bundle: "bundleName1",
}
// Set the onEnabledNotificationChanged callback that is triggered when the notification enabled status changes.
Notification.enableNotification(bundle, false).then(() => {
	console.info("enableNotification sucess");
});
W
wusongqing 已提交
3572 3573
```

E
ester.zhou 已提交
3574
## SubscribeCallbackData
W
wusongqing 已提交
3575

E
ester.zhou 已提交
3576
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3577

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

E
esterzhou 已提交
3580 3581 3582 3583 3584 3585 3586
| Name           | Type                                             | Readable| Writable| Description    |
| --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request         | [NotificationRequest](#notificationrequest)       | Yes | No | Notification content.|
| sortingMap      | [NotificationSortingMap](#notificationsortingmap) | Yes | No | Notification sorting information.|
| reason          | number                                            | Yes | No | Reason for deletion.|
| sound           | string                                            | Yes | No | Sound used for notification.|
| vibrationValues | Array\<number\>                                   | Yes | No | Vibration used for notification.|
W
wusongqing 已提交
3587 3588


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

E
ester.zhou 已提交
3591
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3592

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

E
esterzhou 已提交
3595 3596 3597 3598 3599
| Name  | Type   | Readable| Writable| Description            |
| ------ | ------- | ---- | --- | ---------------- |
| bundle | string  | Yes | No | Bundle name of the application.      |
| uid    | number  | Yes | No | UID of the application.       |
| enable | boolean | Yes | No | Notification enabled status of the application.|
W
wusongqing 已提交
3600 3601


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

E
ester.zhou 已提交
3604
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3605

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

E
esterzhou 已提交
3608 3609 3610 3611 3612
| Name | Type                                  | Readable| Writable| Description                  |
| ----- | -------------------------------------- | ---- | ---- | ---------------------- |
| type  | [DoNotDisturbType](#donotdisturbtype8) | Yes  | Yes  | DND time type.|
| begin | Date                                   | Yes  | Yes  | DND start time.|
| end   | Date                                   | Yes  | Yes  | DND end time.|
W
wusongqing 已提交
3613

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

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

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

E
ester.zhou 已提交
3620 3621
| Name        | Value              | Description                                      |
| ------------ | ---------------- | ------------------------------------------ |
E
ester.zhou 已提交
3622 3623 3624 3625
| 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 已提交
3626 3627


E
ester.zhou 已提交
3628
## ContentType
W
wusongqing 已提交
3629

E
ester.zhou 已提交
3630
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3631

E
ester.zhou 已提交
3632 3633
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3634 3635 3636 3637 3638
| 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 已提交
3639

E
ester.zhou 已提交
3640
## SlotLevel
W
wusongqing 已提交
3641

E
ester.zhou 已提交
3642
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3643

E
ester.zhou 已提交
3644 3645
| Name                             | Value         | Description              |
| --------------------------------- | ----------- | ------------------ |
E
ester.zhou 已提交
3646 3647 3648
| 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 已提交
3649 3650
| 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 已提交
3651 3652


E
ester.zhou 已提交
3653
## BundleOption
W
wusongqing 已提交
3654

E
ester.zhou 已提交
3655
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3656

E
esterzhou 已提交
3657 3658
| Name  | Type  | Readable| Writable| Description  |
| ------ | ------ |---- | --- |  ------ |
E
esterzhou 已提交
3659
| bundle | string | Yes | Yes | Bundle information of the application.|
E
esterzhou 已提交
3660
| uid    | number | Yes | Yes | User ID.|
W
wusongqing 已提交
3661

E
ester.zhou 已提交
3662
## NotificationKey
W
wusongqing 已提交
3663

E
ester.zhou 已提交
3664
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3665

E
esterzhou 已提交
3666 3667 3668 3669
| Name | Type  | Readable| Writable| Description    |
| ----- | ------ | ---- | --- | -------- |
| id    | number | Yes | Yes | Notification ID.  |
| label | string | Yes | Yes | Notification label.|
W
wusongqing 已提交
3670 3671


E
ester.zhou 已提交
3672
## SlotType
W
wusongqing 已提交
3673

E
ester.zhou 已提交
3674
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3675

E
ester.zhou 已提交
3676 3677
| Name                | Value      | Description      |
| -------------------- | -------- | ---------- |
E
ester.zhou 已提交
3678 3679 3680 3681 3682
| 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 已提交
3683 3684


E
ester.zhou 已提交
3685
## NotificationActionButton
W
wusongqing 已提交
3686

E
esterzhou 已提交
3687
Describes the button displayed in the notification.
E
esterzhou 已提交
3688

E
ester.zhou 已提交
3689
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3690

E
esterzhou 已提交
3691 3692 3693
| Name     | Type                                           | Readable| Writable| Description                     |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title     | string                                          | Yes | Yes | Button title.                 |
E
esterzhou 已提交
3694
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md)   | Yes | Yes | **WantAgent** of the button.|
E
esterzhou 已提交
3695 3696
| extras    | { [key: string]: any }                          | Yes | Yes | Extra information of the button.             |
| userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | Yes | Yes | User input object.         |
W
wusongqing 已提交
3697 3698


E
ester.zhou 已提交
3699
## NotificationBasicContent
W
wusongqing 已提交
3700

E
esterzhou 已提交
3701 3702
Describes the normal text notification.

E
ester.zhou 已提交
3703
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3704

E
esterzhou 已提交
3705 3706 3707 3708 3709
| Name          | Type  | Readable| Writable| Description                              |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title          | string | Yes  | Yes  | Notification title.                        |
| text           | string | Yes  | Yes  | Notification content.                        |
| additionalText | string | Yes  | Yes  | Additional information of the notification.|
W
wusongqing 已提交
3710 3711


E
ester.zhou 已提交
3712
## NotificationLongTextContent
W
wusongqing 已提交
3713

E
esterzhou 已提交
3714 3715
Describes the long text notification.

E
ester.zhou 已提交
3716
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3717

E
esterzhou 已提交
3718 3719 3720 3721 3722 3723 3724 3725
| Name          | Type  | Readable| Writable| Description                            |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title          | string | Yes | Yes | Notification title.                        |
| text           | string | Yes | Yes | Notification content.                        |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| longText       | string | Yes | Yes | Long text of the notification.                    |
| briefText      | string | Yes | Yes | Brief text of the notification.|
| expandedTitle  | string | Yes | Yes | Title of the notification in the expanded state.                |
W
wusongqing 已提交
3726 3727


E
ester.zhou 已提交
3728 3729
## NotificationMultiLineContent

E
esterzhou 已提交
3730 3731
Describes the multi-line text notification.

E
ester.zhou 已提交
3732 3733
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3734 3735 3736 3737 3738 3739 3740 3741
| Name          | Type           | Readable| Writable| Description                            |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title          | string          | Yes | Yes | Notification title.                        |
| text           | string          | Yes | Yes | Notification content.                        |
| additionalText | string          | Yes | Yes | Additional information of the notification.|
| briefText      | string          | Yes | Yes | Brief text of the notification.|
| longTitle      | string          | Yes | Yes | Title of the notification in the expanded state.                |
| lines          | Array\<string\> | Yes | Yes | Multi-line text of the notification.                  |
E
ester.zhou 已提交
3742 3743 3744 3745


## NotificationPictureContent

E
esterzhou 已提交
3746 3747
Describes the picture-attached notification.

E
ester.zhou 已提交
3748 3749
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3750 3751 3752 3753 3754 3755 3756
| Name          | Type          | Readable| Writable| Description                            |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title          | string         | Yes | Yes | Notification title.                        |
| text           | string         | Yes | Yes | Notification content.                        |
| additionalText | string         | Yes | Yes | Additional information of the notification.|
| briefText      | string         | Yes | Yes | Brief text of the notification.|
| expandedTitle  | string         | Yes | Yes | Title of the notification in the expanded state.                |
E
esterzhou 已提交
3757
| picture        | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification.                  |
E
ester.zhou 已提交
3758 3759 3760 3761


## NotificationContent

E
esterzhou 已提交
3762 3763
Describes the notification content.

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

E
esterzhou 已提交
3766 3767 3768 3769 3770 3771 3772
| Name       | Type                                                        | Readable| Writable| Description              |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](#contenttype)                                  | Yes | Yes | Notification content type.      |
| normal      | [NotificationBasicContent](#notificationbasiccontent)        | Yes | Yes | Normal text.  |
| longText    | [NotificationLongTextContent](#notificationlongtextcontent)  | Yes | Yes | Long text.|
| multiLine   | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text.  |
| picture     | [NotificationPictureContent](#notificationpicturecontent)    | Yes | Yes | Picture-attached.  |
E
ester.zhou 已提交
3773 3774 3775 3776


## NotificationFlagStatus<sup>8+</sup>

E
esterzhou 已提交
3777 3778
Describes the notification flag status.

E
ester.zhou 已提交
3779 3780
**System capability**: SystemCapability.Notification.Notification

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

E
ester.zhou 已提交
3783 3784 3785 3786 3787 3788 3789 3790 3791
| Name          | Value | Description                              |
| -------------- | --- | --------------------------------- |
| TYPE_NONE      | 0   | The default flag is used.                        |
| TYPE_OPEN      | 1   | The notification flag is enabled.                    |
| TYPE_CLOSE     | 2   | The notification flag is disabled.                    |


## NotificationFlags<sup>8+</sup>

E
esterzhou 已提交
3792 3793
Enumerates notification flags.

E
ester.zhou 已提交
3794 3795
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3796 3797
| Name            | Type                   | Readable| Writable| Description                              |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
E
esterzhou 已提交
3798 3799
| soundEnabled     | [NotificationFlagStatus](#notificationflagstatus8) | Yes  | No  | Whether to enable the sound alert for the notification.                 |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus8) | Yes  | No  | Whether to enable vibration for the notification.              |
E
ester.zhou 已提交
3800 3801 3802 3803


## NotificationRequest

E
esterzhou 已提交
3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817
Describes the notification request.

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

| Name                 | Type                                         | Readable| Writable| Description                      |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content               | [NotificationContent](#notificationcontent)   | Yes | Yes | Notification content.                  |
| id                    | number                                        | Yes | Yes | Notification ID.                    |
| slotType              | [SlotType](#slottype)                         | Yes | Yes | Slot type.                  |
| isOngoing             | boolean                                       | Yes | Yes | Whether the notification is an ongoing notification.            |
| isUnremovable         | boolean                                       | Yes | Yes | Whether the notification can be removed.                |
| deliveryTime          | number                                        | Yes | Yes | Time when the notification is sent.              |
| tapDismissed          | boolean                                       | Yes | Yes | Whether the notification is automatically cleared.          |
| autoDeletedTime       | number                                        | Yes | Yes | Time when the notification is automatically cleared.            |
E
esterzhou 已提交
3818
| wantAgent             | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked. |
E
esterzhou 已提交
3819
| extraInfo             | {[key: string]: any}                          | Yes | Yes | Extended parameters.                  |
E
esterzhou 已提交
3820 3821
| color                 | number                                        | Yes | Yes | Background color of the notification. Not supported currently.|
| colorEnabled          | boolean                                       | Yes | Yes | Whether the notification background color is enabled. Not supported currently.|
E
esterzhou 已提交
3822 3823 3824
| isAlertOnce           | boolean                                       | Yes | Yes | Whether the notification triggers an alert only once.|
| isStopwatch           | boolean                                       | Yes | Yes | Whether to display the stopwatch.          |
| isCountDown           | boolean                                       | Yes | Yes | Whether to display the countdown time.        |
E
esterzhou 已提交
3825
| isFloatingIcon        | boolean                                       | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar.        |
E
esterzhou 已提交
3826 3827 3828 3829
| label                 | string                                        | Yes | Yes | Notification label.                  |
| badgeIconStyle        | number                                        | Yes | Yes | Notification badge type.              |
| showDeliveryTime      | boolean                                       | Yes | Yes | Whether to display the time when the notification is delivered.          |
| actionButtons         | Array\<[NotificationActionButton](#notificationactionbutton)\>             | Yes | Yes | Buttons in the notification. Up to two buttons are allowed.    |
E
esterzhou 已提交
3830 3831
| smallIcon             | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| largeIcon             | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
E
esterzhou 已提交
3832 3833 3834 3835 3836 3837
| creatorBundleName     | string                                        | Yes | No | Name of the bundle that creates the notification.            |
| creatorUid            | number                                        | Yes | No | UID used for creating the notification.             |
| creatorPid            | number                                        | Yes | No | PID used for creating the notification.             |
| creatorUserId<sup>8+</sup>| number                                    | Yes | No | ID of the user who creates the notification.          |
| hashCode              | string                                        | Yes | No | Unique ID of the notification.              |
| classification        | string                                        | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
E
esterzhou 已提交
3838
| groupName<sup>8+</sup>| string                                        | Yes | Yes | Notification group name.                |
E
esterzhou 已提交
3839 3840 3841
| template<sup>8+</sup> | [NotificationTemplate](#notificationtemplate8) | Yes | Yes | Notification template.                  |
| isRemoveAllowed<sup>8+</sup> | boolean                                | Yes | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
| source<sup>8+</sup>   | number                                        | Yes | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.                  |
E
esterzhou 已提交
3842
| distributedOption<sup>8+</sup>   | [DistributedOptions](#distributedoptions8)                 | Yes | Yes | Distributed notification options.         |
E
esterzhou 已提交
3843 3844
| deviceId<sup>8+</sup> | string                                        | Yes | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications.         |
| notificationFlags<sup>8+</sup> | [NotificationFlags](#notificationflags8)                    | Yes | No | Notification flags.         |
E
esterzhou 已提交
3845
| removalWantAgent<sup>9+</sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed.         |
E
esterzhou 已提交
3846
| badgeNumber<sup>9+</sup> | number                    | Yes | Yes | Number of notifications displayed on the application icon.         |
E
ester.zhou 已提交
3847 3848 3849

## DistributedOptions<sup>8+</sup>

E
esterzhou 已提交
3850
Describes distributed notifications options.
E
esterzhou 已提交
3851

E
ester.zhou 已提交
3852 3853
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3854 3855 3856
| Name                  | Type           | Readable| Writable| Description                              |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed          | boolean        | Yes  | Yes  | Whether the notification is a distributed notification.                 |
E
esterzhou 已提交
3857 3858
| supportDisplayDevices  | Array\<string> | Yes  | Yes  | List of the devices to which the notification can be synchronized.        |
| supportOperateDevices  | Array\<string> | Yes  | Yes  | List of the devices on which the notification can be opened.             |
E
esterzhou 已提交
3859
| remindType             | number         | Yes  | No  | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications.                   |
E
ester.zhou 已提交
3860 3861 3862 3863


## NotificationSlot

E
esterzhou 已提交
3864 3865
Describes the notification slot.

E
ester.zhou 已提交
3866 3867
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3868 3869 3870 3871 3872 3873
| Name                | Type                 | Readable| Writable| Description                                      |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type                 | [SlotType](#slottype) | Yes | Yes | Slot type.                                  |
| level                | number                | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc                 | string                | Yes | Yes | Notification slot description.                          |
| badgeFlag            | boolean               | Yes | Yes | Whether to display the badge.                              |
E
esterzhou 已提交
3874
| bypassDnd            | boolean               | Yes | Yes | Whether to bypass DND mode in the system.              |
E
esterzhou 已提交
3875
| lockscreenVisibility | number                | Yes | Yes | Mode for displaying the notification on the lock screen.                |
E
esterzhou 已提交
3876
| vibrationEnabled     | boolean               | Yes | Yes | Whether vibration is enabled for the notification.                                |
E
esterzhou 已提交
3877 3878 3879 3880
| sound                | string                | Yes | Yes | Notification alert tone.                                |
| lightEnabled         | boolean               | Yes | Yes | Whether the indicator blinks for the notification.                                  |
| lightColor           | number                | Yes | Yes | Indicator color of the notification.                                |
| vibrationValues      | Array\<number\>       | Yes | Yes | Vibration mode of the notification.                              |
E
esterzhou 已提交
3881
| enabled<sup>9+</sup> | boolean               | Yes | No | Whether the notification slot is enabled.                     |
E
ester.zhou 已提交
3882 3883 3884 3885


## NotificationSorting

E
esterzhou 已提交
3886 3887
Provides sorting information of active notifications.

E
ester.zhou 已提交
3888 3889
**System capability**: SystemCapability.Notification.Notification

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

E
esterzhou 已提交
3892 3893 3894 3895 3896
| Name    | Type                                 | Readable| Writable| Description        |
| -------- | ------------------------------------- | ---- | --- | ------------ |
| slot     | [NotificationSlot](#notificationslot) | Yes | No | Notification slot content.|
| hashCode | string                                | Yes | No | Unique ID of the notification.|
| ranking  | number                                | Yes | No | Notification sequence number.|
E
ester.zhou 已提交
3897 3898 3899 3900


## NotificationSortingMap

E
esterzhou 已提交
3901 3902
Provides sorting information of active notifications in all subscribed notifications.

E
ester.zhou 已提交
3903 3904
**System capability**: SystemCapability.Notification.Notification

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

E
esterzhou 已提交
3907 3908 3909 3910
| Name          | Type                                                        | Readable| Writable| Description            |
| -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- |
| sortings       | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | No | Array of notification sorting information.|
| sortedHashCode | Array\<string\>                                              | Yes | No | Array of unique notification IDs.|
E
ester.zhou 已提交
3911 3912 3913 3914


## NotificationSubscribeInfo

E
esterzhou 已提交
3915 3916
Provides the information about the publisher for notification subscription.

E
ester.zhou 已提交
3917 3918
**System capability**: SystemCapability.Notification.Notification

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

E
esterzhou 已提交
3921 3922 3923 3924
| Name       | Type           | Readable| Writable| Description                           |
| ----------- | --------------- | --- | ---- | ------------------------------- |
| bundleNames | Array\<string\> | Yes | Yes | Bundle names of the applications whose notifications are to be subscribed to.|
| userId      | number          | Yes | Yes | User whose notifications are to be subscribed to.   |
E
ester.zhou 已提交
3925 3926 3927 3928


## NotificationTemplate<sup>8+</sup>

E
esterzhou 已提交
3929
Describes the notification template.
E
esterzhou 已提交
3930

E
ester.zhou 已提交
3931 3932
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3933
| Name| Type                   | Readable| Writable| Description      |
E
ester.zhou 已提交
3934 3935 3936 3937 3938 3939 3940
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | Yes  | Yes  | Template name.|
| data | {[key:string]: Object} | Yes  | Yes  | Template data.|


## NotificationUserInput<sup>8+</sup>

E
esterzhou 已提交
3941 3942
Provides the notification user input.

E
ester.zhou 已提交
3943 3944
**System capability**: SystemCapability.Notification.Notification

E
esterzhou 已提交
3945 3946 3947
| Name    | Type  | Readable| Writable| Description                         |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.|
E
ester.zhou 已提交
3948

W
wusongqing 已提交
3949

E
ester.zhou 已提交
3950
## DeviceRemindType<sup>8+</sup>
W
wusongqing 已提交
3951

E
ester.zhou 已提交
3952
**System capability**: SystemCapability.Notification.Notification
W
wusongqing 已提交
3953

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

E
ester.zhou 已提交
3956 3957 3958 3959 3960 3961
| 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 已提交
3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974


## 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 已提交
3975 3976 3977 3978 3979 3980 3981 3982 3983

## 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                 |
| -------------------- | --- | -------------------- |
E
esterzhou 已提交
3984
| CLICK_REASON_REMOVE  | 1   | The notification is removed after a click on it.   |
E
esterzhou 已提交
3985
| CANCEL_REASON_REMOVE | 2   | The notification is removed by the user.        |