js-apis-notification.md 106.7 KB
Newer Older
X
xuchenghua09 已提交
1
# Notification模块
Z
zhaoyuan17 已提交
2

3 4
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
5

X
xuchenghua09 已提交
6
## 导入模块
Z
zhaoyuan17 已提交
7 8

```js
X
xuchenghua09 已提交
9
import Notification from '@ohos.notification';
Z
zhaoyuan17 已提交
10 11
```

X
xuzhihao 已提交
12
## Notification.publish
Z
zero-cyc 已提交
13

X
xuzhihao 已提交
14
publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
15

X
xuzhihao 已提交
16
发布通知(callback形式)。
Z
zhaoyuan17 已提交
17

X
xuzhihao 已提交
18
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
19

X
xuzhihao 已提交
20
**参数:**
Z
zhaoyuan17 已提交
21

X
xuzhihao 已提交
22 23 24 25
| 名称     | 可读 | 可写 | 类型                                        | 必填 | 描述                                        |
| -------- | ---- | ---- | ------------------------------------------- | ---- | ------------------------------------------- |
| request  | 是   | 否   |[NotificationRequest](#notificationrequest) | 是   | 设置要发布通知内容的NotificationRequest对象。 |
| callback | 是   | 否   |AsyncCallback\<void\>                       | 是   | 被指定的回调方法。                            |
Z
zhaoyuan17 已提交
26

X
xuzhihao 已提交
27
**示例:**
Z
zhaoyuan17 已提交
28 29 30 31 32 33 34 35 36 37

```js
//publish回调
function publishCallback(err) {
	console.info("==========================>publishCallback=======================>");
}
//通知Request对象
var notificationRequest = {
    id: 1,
    content: {
Z
zengsiyu 已提交
38
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
Z
zhaoyuan17 已提交
39 40 41 42 43 44 45 46 47 48 49 50
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest, publishCallback)
```



X
xuzhihao 已提交
51
## Notification.publish
Z
zhaoyuan17 已提交
52

X
xuzhihao 已提交
53
publish(request: NotificationRequest): Promise\<void\>
Z
zhaoyuan17 已提交
54

X
xuzhihao 已提交
55
发布通知(Promise形式)。
Z
zhaoyuan17 已提交
56

X
xuzhihao 已提交
57
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
58

X
xuzhihao 已提交
59
**示例:**
Z
zhaoyuan17 已提交
60 61 62 63 64 65

```js
//通知Request对象
var notificationRequest = {
    notificationId: 1,
    content: {
Z
zengsiyu 已提交
66
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
Z
zhaoyuan17 已提交
67 68 69 70 71 72 73
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Z
zengsiyu 已提交
74
Notification.publish(notificationRequest).then(() => {
Z
zhaoyuan17 已提交
75 76 77 78 79
	console.info("==========================>publishCallback=======================>");
});

```

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

X
xuzhihao 已提交
82
publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

发布通知(callback形式)。

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称     | 可读 | 可写 | 类型                                        | 必填 | 描述                                        |
| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
| request  | 是   | 否   |[NotificationRequest](#notificationrequest) | 是   | 设置要发布通知内容的NotificationRequest对象。 |
| userId   | 是   | 否   |number                                      | 是   | 接收通知用户的Id。                           |
| callback | 是   | 否   |AsyncCallback\<void\>                       | 是   | 被指定的回调方法。                           |

**示例:**

```js
//publish回调
function publishCallback(err) {
	console.info("==========================>publishCallback=======================>");
}
// 接收通知的用户ID
var userId = 1
//通知Request对象
var notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}
Notification.publish(notificationRequest, userId, publishCallback);
```

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

X
xuzhihao 已提交
122
publish(request: NotificationRequest, userId: number): Promise\<void\>
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155

发布通知(Promise形式)。

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称     | 可读 | 可写 | 类型                                        | 必填 | 描述                                        |
| -------- | ---- | ---- | ----------------------------------------- | ---- | ------------------------------------------- |
| request  | 是   | 否   |[NotificationRequest](#notificationrequest) | 是   | 设置要发布通知内容的NotificationRequest对象。 |
| userId   | 是   | 否   |number                                      | 是   | 接收通知用户的Id。                           |

**示例:**

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

var userId = 1

Notification.publish(notificationRequest, userId).then(() => {
	console.info("==========================>publishCallback=======================>");
});
```
Z
zhaoyuan17 已提交
156 157


X
xuzhihao 已提交
158
## Notification.cancel
Z
zhaoyuan17 已提交
159

X
xuzhihao 已提交
160
cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
161

X
xuzhihao 已提交
162
取消与指定id和label相匹配的已发布通知(callback形式)。
Z
zhaoyuan17 已提交
163

X
xuzhihao 已提交
164
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
165

X
xuzhihao 已提交
166
**参数:**
Z
zhaoyuan17 已提交
167

X
xuzhihao 已提交
168 169 170 171 172
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | --- | ---- | --------------------- | ---- | -------------------- |
| id       | 是   | 否   | number                | 是   | 通知ID。               |
| label    | 是   | 否   | string                | 是   | 通知标签。             |
| callback | 是   | 否   | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
Z
zhaoyuan17 已提交
173

X
xuzhihao 已提交
174
**示例:**
Z
zhaoyuan17 已提交
175 176 177 178 179 180 181 182 183 184 185

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



X
xuzhihao 已提交
186
## Notification.cancel
Z
zhaoyuan17 已提交
187

188
cancel(id:number, label?:string): Promise\<void\>
Z
zhaoyuan17 已提交
189

R
RayShih 已提交
190
取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。
Z
zhaoyuan17 已提交
191

X
xuzhihao 已提交
192
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
193

X
xuzhihao 已提交
194
**参数:**
Z
zhaoyuan17 已提交
195

X
xuzhihao 已提交
196 197 198 199
| 名称  | 可读 | 可写 | 类型   | 必填 | 描述     |
| ----- | --- | ---- | ------ | ---- | -------- |
| id    | 是   | 否   | number | 是   | 通知ID。   |
| label | 是   | 否   | string | 否   | 通知标签。 |
Z
zhaoyuan17 已提交
200

X
xuzhihao 已提交
201
**示例:**
Z
zhaoyuan17 已提交
202 203

```js
Z
zengsiyu 已提交
204
Notification.cancel(0).then(() => {
Z
zhaoyuan17 已提交
205 206 207 208 209 210
	console.info("==========================>cancelCallback=======================>");
});
```



X
xuzhihao 已提交
211
## Notification.cancel
Z
zhaoyuan17 已提交
212

X
xuzhihao 已提交
213
cancel(id: number, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
214

R
RayShih 已提交
215
取消与指定id相匹配的已发布通知(callback形式)。
Z
zhaoyuan17 已提交
216

X
xuzhihao 已提交
217
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
218

X
xuzhihao 已提交
219
**参数:**
Z
zhaoyuan17 已提交
220

X
xuzhihao 已提交
221 222 223 224
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| id       | 是   | 否  | number                | 是   | 通知ID。               |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
Z
zhaoyuan17 已提交
225

X
xuzhihao 已提交
226
**示例:**
Z
zhaoyuan17 已提交
227 228 229 230 231 232 233 234 235 236 237

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



X
xuzhihao 已提交
238
## Notification.cancelAll
Z
zhaoyuan17 已提交
239

X
xuzhihao 已提交
240
cancelAll(callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
241

R
RayShih 已提交
242
取消所有已发布的通知(callback形式)。
Z
zhaoyuan17 已提交
243

X
xuzhihao 已提交
244
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
245

X
xuzhihao 已提交
246
**参数:**
Z
zhaoyuan17 已提交
247

X
xuzhihao 已提交
248 249 250
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
Z
zhaoyuan17 已提交
251

X
xuzhihao 已提交
252
**示例:**
Z
zhaoyuan17 已提交
253 254 255

```js
//cancel回调
Z
zengsiyu 已提交
256 257
function cancelAllCallback(err) {
	console.info("==========================>cancelAllCallback=======================>");
Z
zhaoyuan17 已提交
258
}
Z
zengsiyu 已提交
259
Notification.cancelAll(cancelAllCallback)
Z
zhaoyuan17 已提交
260 261 262 263
```



X
xuzhihao 已提交
264
## Notification.cancelAll
Z
zhaoyuan17 已提交
265

X
xuzhihao 已提交
266
cancelAll(): Promise\<void\>
Z
zhaoyuan17 已提交
267

R
RayShih 已提交
268
取消所有已发布的通知(Promise形式)。
Z
zhaoyuan17 已提交
269

X
xuzhihao 已提交
270
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
271

X
xuzhihao 已提交
272
**示例:**
Z
zhaoyuan17 已提交
273 274

```js
Z
zengsiyu 已提交
275 276
Notification.cancelAll().then(() => {
	console.info("==========================>cancelAllCallback=======================>");
Z
zhaoyuan17 已提交
277 278 279 280 281
});
```



X
xuzhihao 已提交
282
## Notification.addSlot
Z
zhaoyuan17 已提交
283

X
xuzhihao 已提交
284
addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
285

R
RayShih 已提交
286
创建通知通道(callback形式)。
Z
zhaoyuan17 已提交
287

X
xuzhihao 已提交
288
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
289

X
xuzhihao 已提交
290
**参数:**
Z
zhaoyuan17 已提交
291

X
xuzhihao 已提交
292 293
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
294
| slot     | 是   | 否  | [NotificationSlot](#notificationslot)       | 是   | 要创建的通知通道对象。 |
X
xuzhihao 已提交
295
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
Z
zhaoyuan17 已提交
296

X
xuzhihao 已提交
297
**示例:**
Z
zhaoyuan17 已提交
298 299 300 301 302 303 304 305

```js
//addslot回调
function addSlotCallBack(err) {
	console.info("==========================>addSlotCallBack=======================>");
}
//通知slot对象
var notificationSlot = {
X
xuchenghua09 已提交
306
    type: Notification.SlotType.SOCIAL_COMMUNICATION
Z
zhaoyuan17 已提交
307 308 309 310 311 312
}
Notification.addSlot(notificationSlot, addSlotCallBack)
```



X
xuzhihao 已提交
313
## Notification.addSlot
Z
zhaoyuan17 已提交
314

X
xuzhihao 已提交
315
addSlot(slot: NotificationSlot): Promise\<void\>
Z
zhaoyuan17 已提交
316

R
RayShih 已提交
317
创建通知通道(Promise形式)。
Z
zhaoyuan17 已提交
318

X
xuzhihao 已提交
319
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
320

X
xuzhihao 已提交
321
**参数:**
Z
zhaoyuan17 已提交
322

X
xuzhihao 已提交
323 324
| 名称 | 可读 | 可写 | 类型             | 必填 | 描述                 |
| ---- | ---- | --- | ---------------- | ---- | -------------------- |
325
| slot | 是   | 否  | [NotificationSlot](#notificationslot) | 是   | 要创建的通知通道对象。 |
Z
zhaoyuan17 已提交
326

X
xuzhihao 已提交
327
**示例:**
Z
zhaoyuan17 已提交
328 329 330

```js
//通知slot对象
X
xuchenghua09 已提交
331 332 333
var notificationSlot = {
    type: Notification.SlotType.SOCIAL_COMMUNICATION
}
Z
zengsiyu 已提交
334
Notification.addSlot(notificationSlot).then(() => {
Z
zhaoyuan17 已提交
335 336 337 338 339 340
	console.info("==========================>addSlotCallback=======================>");
});
```



X
xuzhihao 已提交
341
## Notification.addSlot
Z
zhaoyuan17 已提交
342

X
xuzhihao 已提交
343
addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
344

R
RayShih 已提交
345
创建通知通道(callback形式)。
Z
zhaoyuan17 已提交
346

X
xuzhihao 已提交
347
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
348

X
xuzhihao 已提交
349
**参数:**
Z
zhaoyuan17 已提交
350

X
xuzhihao 已提交
351 352 353 354
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                   |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
| type     | 是   | 否  | [SlotType](#slottype)              | 是   | 要创建的通知通道的类型。 |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。   |
Z
zhaoyuan17 已提交
355

X
xuzhihao 已提交
356
**示例:**
Z
zhaoyuan17 已提交
357 358 359 360 361 362

```js
//addslot回调
function addSlotCallBack(err) {
	console.info("==========================>addSlotCallBack=======================>");
}
X
xuchenghua09 已提交
363
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack)
Z
zhaoyuan17 已提交
364 365 366 367
```



X
xuzhihao 已提交
368
## Notification.addSlot
Z
zhaoyuan17 已提交
369

X
xuzhihao 已提交
370
addSlot(type: SlotType): Promise\<void\>
Z
zhaoyuan17 已提交
371

R
RayShih 已提交
372
创建通知通道(Promise形式)。
Z
zhaoyuan17 已提交
373

X
xuzhihao 已提交
374
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
375

X
xuzhihao 已提交
376
**参数:**
Z
zhaoyuan17 已提交
377

X
xuzhihao 已提交
378 379 380
| 名称 | 可读 | 可写 | 类型     | 必填 | 描述                   |
| ---- | ---- | --- | -------- | ---- | ---------------------- |
| type | 是   | 否  | [SlotType](#slottype) | 是   | 要创建的通知通道的类型。 |
Z
zhaoyuan17 已提交
381

X
xuzhihao 已提交
382
**示例:**
Z
zhaoyuan17 已提交
383 384

```js
Z
zengsiyu 已提交
385
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
Z
zhaoyuan17 已提交
386 387 388 389 390 391
	console.info("==========================>addSlotCallback=======================>");
});
```



X
xuzhihao 已提交
392
## Notification.addSlots
Z
zhaoyuan17 已提交
393

X
xuzhihao 已提交
394
addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
395

R
RayShih 已提交
396
创建多个通知通道(callback形式)。
Z
zhaoyuan17 已提交
397

X
xuzhihao 已提交
398
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
399

X
xuzhihao 已提交
400
**参数:**
Z
zhaoyuan17 已提交
401

X
xuzhihao 已提交
402 403
| 名称     | 可读 | 可写 | 类型                      | 必填 | 描述                     |
| -------- | ---- | --- | ------------------------- | ---- | ------------------------ |
404
| slots    | 是   | 否  | Array\<[NotificationSlot](#notificationslot)\> | 是   | 要创建的通知通道对象数组。 |
X
xuzhihao 已提交
405
| callback | 是   | 否  | AsyncCallback\<void\>     | 是   | 表示被指定的回调方法。     |
Z
zhaoyuan17 已提交
406

X
xuzhihao 已提交
407
**示例:**
Z
zhaoyuan17 已提交
408 409 410 411 412 413 414 415

```js
//addSlots回调
function addSlotsCallBack(err) {
	console.info("==========================>addSlotsCallBack=======================>");
}
//通知slot对象
var notificationSlot = {
X
xuchenghua09 已提交
416
    type: Notification.SlotType.SOCIAL_COMMUNICATION
Z
zhaoyuan17 已提交
417 418
}
//通知slot array 对象
Z
zengsiyu 已提交
419 420
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
Z
zhaoyuan17 已提交
421 422 423 424 425 426

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



X
xuzhihao 已提交
427
## Notification.addSlots
Z
zhaoyuan17 已提交
428

X
xuzhihao 已提交
429
addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
Z
zhaoyuan17 已提交
430

R
RayShih 已提交
431
创建多个通知通道(Promise形式)。
Z
zhaoyuan17 已提交
432

X
xuzhihao 已提交
433
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
434

X
xuzhihao 已提交
435
**参数:**
Z
zhaoyuan17 已提交
436

X
xuzhihao 已提交
437 438
| 名称  | 可读 | 可写 | 类型                      | 必填 | 描述                     |
| ----- | ---- | --- | ------------------------- | ---- | ------------------------ |
439
| slots | 是   | 否  | Array\<[NotificationSlot](#notificationslot)\> | 是   | 要创建的通知通道对象数组。 |
Z
zhaoyuan17 已提交
440

X
xuzhihao 已提交
441
**示例:**
Z
zhaoyuan17 已提交
442 443 444 445

```js
//通知slot对象
var notificationSlot = {
X
xuchenghua09 已提交
446
    type: Notification.SlotType.SOCIAL_COMMUNICATION
Z
zhaoyuan17 已提交
447 448
}
//通知slot array 对象
Z
zengsiyu 已提交
449 450
var notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot;
Z
zhaoyuan17 已提交
451

Z
zengsiyu 已提交
452
Notification.addSlots(notificationSlotArray).then(() => {
Z
zhaoyuan17 已提交
453 454 455 456 457 458
	console.info("==========================>addSlotCallback=======================>");
});
```



X
xuzhihao 已提交
459
## Notification.getSlot
Z
zhaoyuan17 已提交
460

X
xuzhihao 已提交
461
getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
Z
zhaoyuan17 已提交
462

R
RayShih 已提交
463
获取一个通知通道(callback形式)。
Z
zhaoyuan17 已提交
464

X
xuzhihao 已提交
465
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
466

X
xuzhihao 已提交
467
**参数:**
Z
zhaoyuan17 已提交
468

X
xuzhihao 已提交
469 470 471
| 名称     | 可读 | 可写 | 类型                              | 必填 | 描述                                                        |
| -------- | ---- | --- | --------------------------------- | ---- | ----------------------------------------------------------- |
| slotType | 是   | 否  | [SlotType](#slottype)                          | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
472
| callback | 是   | 否  | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是   | 表示被指定的回调方法。                                        |
Z
zhaoyuan17 已提交
473

X
xuzhihao 已提交
474
**示例:**
Z
zhaoyuan17 已提交
475 476 477 478 479 480

```js
//getSlot回调
function getSlotCallback(err,data) {
	console.info("==========================>getSlotCallback=======================>");
}
X
xuchenghua09 已提交
481
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Z
zhaoyuan17 已提交
482 483 484 485 486
Notification.getSlot(slotType, getSlotCallback)
```



X
xuzhihao 已提交
487
## Notification.getSlot
Z
zhaoyuan17 已提交
488

X
xuzhihao 已提交
489
getSlot(slotType: SlotType): Promise\<NotificationSlot\>
Z
zhaoyuan17 已提交
490

R
RayShih 已提交
491
获取一个通知通道(Promise形式)。
Z
zhaoyuan17 已提交
492

X
xuzhihao 已提交
493
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
494

X
xuzhihao 已提交
495
**参数:**
Z
zhaoyuan17 已提交
496

X
xuzhihao 已提交
497 498 499
| 名称     | 可读 | 可写 | 类型     | 必填 | 描述                                                        |
| -------- | ---- | --- | -------- | ---- | ----------------------------------------------------------- |
| slotType | 是   | 否  | [SlotType](#slottype) | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
Z
zhaoyuan17 已提交
500

X
xuzhihao 已提交
501
**返回值:**
Z
zhaoyuan17 已提交
502

X
xuzhihao 已提交
503 504 505 506 507
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<NotificationSlot\> | 以Promise形式返回获取一个通知通道。 |

**示例:**
Z
zhaoyuan17 已提交
508 509

```js
X
xuchenghua09 已提交
510
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Z
zhaoyuan17 已提交
511 512
Notification.getSlot(slotType).then((data) => {
	console.info("==========================>getSlotCallback=======================>");
X
xuchenghua09 已提交
513
});
Z
zhaoyuan17 已提交
514 515 516 517
```



X
xuzhihao 已提交
518
## Notification.getSlots
Z
zhaoyuan17 已提交
519

X
xuzhihao 已提交
520
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
Z
zhaoyuan17 已提交
521

R
RayShih 已提交
522
获取此应用程序的所有通知通道(callback形式)。
Z
zhaoyuan17 已提交
523

X
xuzhihao 已提交
524
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
525

X
xuzhihao 已提交
526
**参数:**
Z
zhaoyuan17 已提交
527

X
xuzhihao 已提交
528 529
| 名称     | 可读 | 可写 | 类型                              | 必填 | 描述                 |
| -------- | ---- | --- | --------------------------------- | ---- | -------------------- |
530
| callback | 是   | 否  | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是   | 表示被指定的回调方法。 |
Z
zhaoyuan17 已提交
531

X
xuzhihao 已提交
532
**示例:**
Z
zhaoyuan17 已提交
533 534 535 536 537 538 539 540 541 542 543

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



X
xuzhihao 已提交
544
## Notification.getSlots
Z
zhaoyuan17 已提交
545

X
xuzhihao 已提交
546
getSlots(): Promise\<Array\<NotificationSlot\>>
Z
zhaoyuan17 已提交
547

R
RayShih 已提交
548
获取此应用程序的所有通知通道(Promise形式)。
Z
zhaoyuan17 已提交
549

X
xuzhihao 已提交
550
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
551

X
xuzhihao 已提交
552
**返回值:**
Z
zhaoyuan17 已提交
553

X
xuzhihao 已提交
554 555
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
556
| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | 以Promise形式返回获取此应用程序的所有通知通道的结果。 |
X
xuezhongzhu 已提交
557

X
xuzhihao 已提交
558
**示例:**
Z
zhaoyuan17 已提交
559 560 561 562

```js
Notification.getSlots().then((data) => {
	console.info("==========================>getSlotsCallback=======================>");
X
xuchenghua09 已提交
563
});
Z
zhaoyuan17 已提交
564 565 566 567
```



X
xuzhihao 已提交
568
## Notification.removeSlot
Z
zhaoyuan17 已提交
569

X
xuzhihao 已提交
570
removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
571

R
RayShih 已提交
572
根据通知通道类型删除创建的通知通道(callback形式)。
Z
zhaoyuan17 已提交
573

X
xuzhihao 已提交
574
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
575

X
xuzhihao 已提交
576
**参数:**
Z
zhaoyuan17 已提交
577

X
xuzhihao 已提交
578 579 580 581
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                                                        |
| -------- | ---- | --- | --------------------- | ---- | ----------------------------------------------------------- |
| slotType | 是   | 否  | [SlotType](#slottype)              | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。                                        |
Z
zhaoyuan17 已提交
582

X
xuzhihao 已提交
583
**示例:**
Z
zhaoyuan17 已提交
584 585 586 587 588 589

```js
//removeSlot回调
function removeSlotCallback(err) {
	console.info("==========================>removeSlotCallback=======================>");
}
X
xuchenghua09 已提交
590
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Z
zhaoyuan17 已提交
591 592 593 594 595
Notification.removeSlot(slotType,removeSlotCallback)
```



X
xuzhihao 已提交
596
## Notification.removeSlot
Z
zhaoyuan17 已提交
597

X
xuzhihao 已提交
598
removeSlot(slotType: SlotType): Promise\<void\>
Z
zhaoyuan17 已提交
599

R
RayShih 已提交
600
根据通知通道类型删除创建的通知通道(Promise形式)。
Z
zhaoyuan17 已提交
601

X
xuzhihao 已提交
602
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
603

X
xuzhihao 已提交
604
**参数:**
Z
zhaoyuan17 已提交
605

X
xuzhihao 已提交
606 607 608
| 名称     | 可读 | 可写 | 类型     | 必填 | 描述                                                        |
| -------- | ---- | --- | -------- | ---- | ----------------------------------------------------------- |
| slotType | 是   | 否  | [SlotType](#slottype) | 是   | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
Z
zhaoyuan17 已提交
609

X
xuzhihao 已提交
610
**示例:**
Z
zhaoyuan17 已提交
611 612

```js
X
xuchenghua09 已提交
613
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Z
zengsiyu 已提交
614
Notification.removeSlot(slotType).then(() => {
Z
zhaoyuan17 已提交
615
	console.info("==========================>removeSlotCallback=======================>");
X
xuchenghua09 已提交
616
});
Z
zhaoyuan17 已提交
617 618 619 620
```



X
xuzhihao 已提交
621
## Notification.removeAllSlots
Z
zhaoyuan17 已提交
622

X
xuzhihao 已提交
623
removeAllSlots(callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
624

R
RayShih 已提交
625
删除所有通知通道(callback形式)。
Z
zhaoyuan17 已提交
626

X
xuzhihao 已提交
627
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
628

X
xuzhihao 已提交
629
**参数:**
Z
zhaoyuan17 已提交
630

X
xuzhihao 已提交
631 632 633
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 表示被指定的回调方法。 |
Z
zhaoyuan17 已提交
634

X
xuzhihao 已提交
635
**示例:**
Z
zhaoyuan17 已提交
636 637 638 639 640 641 642 643 644 645

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



X
xuzhihao 已提交
646
## Notification.removeAllSlots
Z
zhaoyuan17 已提交
647

X
xuzhihao 已提交
648
removeAllSlots(): Promise\<void\>
Z
zhaoyuan17 已提交
649

R
RayShih 已提交
650
删除所有通知通道(Promise形式)。
Z
zhaoyuan17 已提交
651

X
xuzhihao 已提交
652
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
653

X
xuzhihao 已提交
654
**示例:**
Z
zhaoyuan17 已提交
655 656

```js
Z
zengsiyu 已提交
657
Notification.removeAllSlots().then(() => {
Z
zhaoyuan17 已提交
658 659 660 661 662 663
	console.info("==========================>removeAllCallBack=======================>");
});
```



X
xuzhihao 已提交
664
## Notification.subscribe
Z
zhaoyuan17 已提交
665

X
xuzhihao 已提交
666
subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
667

R
RayShih 已提交
668
订阅通知并指定订阅信息(callback形式)。
Z
zhaoyuan17 已提交
669

X
xuzhihao 已提交
670
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
671

X
xuzhihao 已提交
672
**参数:**
Z
zhaoyuan17 已提交
673

X
xuzhihao 已提交
674 675 676 677 678
| 名称       | 可读 | 可写 | 类型                      | 必填 | 描述             |
| ---------- | ---- | --- | ------------------------- | ---- | ---------------- |
| subscriber | 是   | 否  | [NotificationSubscriber](#notificationsubscriber)    | 是   | 通知订阅对象。     |
| info       | 是   | 否  | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是   | 订阅信息。         |
| callback   | 是   | 否  | AsyncCallback\<void\>     | 是   | 订阅动作回调函数。 |
Z
zhaoyuan17 已提交
679

X
xuzhihao 已提交
680
**示例:**
Z
zhaoyuan17 已提交
681 682 683 684 685 686 687 688 689 690

```js
//subscribe回调
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
X
xuchenghua09 已提交
691
    onConsume: onConsumeCallback
Z
zhaoyuan17 已提交
692 693
}
var info = {
X
xuchenghua09 已提交
694
    bundleNames: ["bundleName1","bundleName2"]
Z
zhaoyuan17 已提交
695 696 697 698 699 700
}
Notification.subscribe(subscriber, info, subscribeCallback);
```



X
xuzhihao 已提交
701
## Notification.subscribe
Z
zhaoyuan17 已提交
702

X
xuzhihao 已提交
703
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
704

R
RayShih 已提交
705
订阅通知并指定订阅信息(callback形式)。
Z
zhaoyuan17 已提交
706

X
xuzhihao 已提交
707
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
708

X
xuzhihao 已提交
709
**参数:**
Z
zhaoyuan17 已提交
710

X
xuzhihao 已提交
711 712 713 714
| 名称       | 可读 | 可写 | 类型                   | 必填 | 描述             |
| ---------- | ---- | --- | ---------------------- | ---- | ---------------- |
| subscriber | 是   | 否  | [NotificationSubscriber](#notificationsubscriber) | 是   | 通知订阅对象。     |
| callback   | 是   | 否  | AsyncCallback\<void\>  | 是   | 订阅动作回调函数。 |
Z
zhaoyuan17 已提交
715

X
xuzhihao 已提交
716
**示例:**
Z
zhaoyuan17 已提交
717 718 719 720 721 722 723 724 725

```js
function subscribeCallback(err) {
	console.info("==========================>subscribeCallback=======================>");
}
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
X
xuchenghua09 已提交
726
    onConsume: onConsumeCallback
Z
zhaoyuan17 已提交
727 728 729 730 731 732
}
Notification.subscribe(subscriber, subscribeCallback);
```



X
xuzhihao 已提交
733
## Notification.subscribe
Z
zhaoyuan17 已提交
734

X
xuzhihao 已提交
735
subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise\<void\>
Z
zhaoyuan17 已提交
736

R
RayShih 已提交
737
订阅通知并指定订阅信息(Promise形式)。
Z
zhaoyuan17 已提交
738

X
xuzhihao 已提交
739
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
740

X
xuzhihao 已提交
741
**参数:**
Z
zhaoyuan17 已提交
742

X
xuzhihao 已提交
743 744 745 746
| 名称       | 可读 | 可写 | 类型                      | 必填 | 描述         |
| ---------- | ---- | --- | ------------------------- | ---- | ------------ |
| subscriber | 是   | 否  | [NotificationSubscriber](#notificationsubscriber)    | 是   | 通知订阅对象。 |
| info       | 是   | 否  | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否   | 订阅信息。     |
Z
zhaoyuan17 已提交
747

X
xuzhihao 已提交
748
**示例:**
Z
zhaoyuan17 已提交
749 750 751 752 753 754

```js
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
X
xuchenghua09 已提交
755
    onConsume: onConsumeCallback
Z
zhaoyuan17 已提交
756
};
Z
zengsiyu 已提交
757
Notification.subscribe(subscriber).then(() => {
Z
zhaoyuan17 已提交
758 759 760 761 762 763
	console.info("==========================>subscribeCallback=======================>");
});
```



X
xuzhihao 已提交
764
## Notification.unsubscribe
Z
zhaoyuan17 已提交
765

X
xuzhihao 已提交
766
unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
767

R
RayShih 已提交
768
取消订阅(callbcak形式)。
Z
zhaoyuan17 已提交
769

X
xuzhihao 已提交
770
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
771

X
xuzhihao 已提交
772
**参数:**
Z
zhaoyuan17 已提交
773

X
xuzhihao 已提交
774 775 776 777
| 名称       | 可读 | 可写 | 类型                   | 必填 | 描述                 |
| ---------- | ---- | --- | ---------------------- | ---- | -------------------- |
| subscriber | 是   | 否  | [NotificationSubscriber](#notificationsubscriber) | 是   | 通知订阅对象。         |
| callback   | 是   | 否  | AsyncCallback\<void\>  | 是   | 取消订阅动作回调函数。 |
Z
zhaoyuan17 已提交
778

X
xuzhihao 已提交
779
**示例:**
Z
zhaoyuan17 已提交
780 781 782 783 784 785 786 787 788

```js
function unsubscribeCallback(err) {
	console.info("==========================>unsubscribeCallback=======================>");
}
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
X
xuchenghua09 已提交
789
    onConsume: onConsumeCallback
Z
zhaoyuan17 已提交
790 791 792 793 794 795
}
Notification.unsubscribe(subscriber, unsubscribeCallback);
```



X
xuzhihao 已提交
796
## Notification.unsubscribe
Z
zhaoyuan17 已提交
797

X
xuzhihao 已提交
798
unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
Z
zhaoyuan17 已提交
799

R
RayShih 已提交
800
取消订阅(Promise形式)。
Z
zhaoyuan17 已提交
801

X
xuzhihao 已提交
802
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
803

X
xuzhihao 已提交
804
**参数:**
Z
zhaoyuan17 已提交
805

X
xuzhihao 已提交
806 807 808
| 名称       | 可读 | 可写 | 类型                   | 必填 | 描述         |
| ---------- | ---- | --- | ---------------------- | ---- | ------------ |
| subscriber | 是   | 否  | [NotificationSubscriber](#notificationsubscriber) | 是   | 通知订阅对象。 |
Z
zhaoyuan17 已提交
809

X
xuzhihao 已提交
810
**示例:**
Z
zhaoyuan17 已提交
811 812 813 814 815 816

```js
function onConsumeCallback(err, data) {
	console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
X
xuchenghua09 已提交
817
    onConsume: onConsumeCallback
Z
zhaoyuan17 已提交
818
};
Z
zengsiyu 已提交
819
Notification.unsubscribe(subscriber).then(() => {
Z
zhaoyuan17 已提交
820 821 822 823 824 825
	console.info("==========================>unsubscribeCallback=======================>");
});
```



X
xuzhihao 已提交
826
## Notification.enableNotification
Z
zhaoyuan17 已提交
827

X
xuzhihao 已提交
828
enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
829

R
RayShih 已提交
830
设定指定包的通知使能状态(Callback形式)。
Z
zhaoyuan17 已提交
831

X
xuzhihao 已提交
832
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
833

X
xuzhihao 已提交
834
**参数:**
Z
zhaoyuan17 已提交
835

X
xuzhihao 已提交
836 837 838 839 840
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)          | 是   | 指定包信息。           |
| enable   | 是   | 否  | boolean               | 是   | 使能状态。             |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 设定通知使能回调函数。 |
Z
zhaoyuan17 已提交
841

X
xuzhihao 已提交
842
**示例:**
Z
zhaoyuan17 已提交
843 844 845 846 847 848

```js
function enableNotificationCallback(err) {
	console.info("==========================>enableNotificationCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
849
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
850 851 852 853 854 855
}
Notification.enableNotification(bundle, false, enableNotificationCallback);
```



X
xuzhihao 已提交
856
## Notification.enableNotification
Z
zhaoyuan17 已提交
857

X
xuzhihao 已提交
858
enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\>
Z
zhaoyuan17 已提交
859

R
RayShih 已提交
860
设定指定包的通知使能状态(Promise形式)。
Z
zhaoyuan17 已提交
861

X
xuzhihao 已提交
862
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
863

X
xuzhihao 已提交
864
**参数:**
Z
zhaoyuan17 已提交
865

X
xuzhihao 已提交
866 867 868 869
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
| enable | 是   | 否  | boolean      | 是   | 使能状态。   |
Z
zhaoyuan17 已提交
870

X
xuzhihao 已提交
871
**示例:**
Z
zhaoyuan17 已提交
872 873 874

```js
var bundle = {
Z
zengsiyu 已提交
875
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
876
}
Z
zengsiyu 已提交
877
Notification.enableNotification(bundle, false).then(() => {
Z
zhaoyuan17 已提交
878 879 880 881 882 883
	console.info("==========================>enableNotificationCallback=======================>");
});
```



X
xuzhihao 已提交
884
## Notification.isNotificationEnabled
Z
zhaoyuan17 已提交
885

X
xuzhihao 已提交
886
isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
Z
zhaoyuan17 已提交
887

R
RayShih 已提交
888
获取指定包的通知使能状态(Callback形式)。
Z
zhaoyuan17 已提交
889

X
xuzhihao 已提交
890
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
891

X
xuzhihao 已提交
892
**参数:**
Z
zhaoyuan17 已提交
893

X
xuzhihao 已提交
894 895 896 897
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                     |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)          | 是   | 指定包信息。               |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 获取通知使能状态回调函数。 |
Z
zhaoyuan17 已提交
898

X
xuzhihao 已提交
899
**示例:**
Z
zhaoyuan17 已提交
900 901 902 903 904 905

```js
function isNotificationEnabledCallback(err, data) {
	console.info("==========================>isNotificationEnabledCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
906
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
907 908 909 910 911 912
}
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
```



X
xuzhihao 已提交
913 914 915
## Notification.isNotificationEnabled

isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
Z
zhaoyuan17 已提交
916

R
RayShih 已提交
917
获取指定包的通知使能状态(Promise形式)。
Z
zhaoyuan17 已提交
918

X
xuzhihao 已提交
919
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
920

X
xuzhihao 已提交
921
**参数:**
Z
zhaoyuan17 已提交
922

X
xuzhihao 已提交
923 924 925
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
Z
zhaoyuan17 已提交
926

X
xuzhihao 已提交
927
**返回值:**
Z
zhaoyuan17 已提交
928

X
xuzhihao 已提交
929 930 931
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取指定包的通知使能状态的结果。 |
Z
zhaoyuan17 已提交
932

X
xuzhihao 已提交
933
**示例:**
Z
zhaoyuan17 已提交
934 935 936

```js
var bundle = {
Z
zengsiyu 已提交
937
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
938 939 940 941 942 943 944 945
}
Notification.isNotificationEnabled(bundle).then((data) => {
	console.info("==========================>isNotificationEnabledCallback=======================>");
});
```



X
xuzhihao 已提交
946
## Notification.isNotificationEnabled
Z
zhaoyuan17 已提交
947

X
xuzhihao 已提交
948
isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
Z
zhaoyuan17 已提交
949

R
RayShih 已提交
950
获取通知使能状态(Callback形式)。
Z
zhaoyuan17 已提交
951

X
xuzhihao 已提交
952
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
953

X
xuzhihao 已提交
954
**参数:**
Z
zhaoyuan17 已提交
955

X
xuzhihao 已提交
956 957 958
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                     |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 获取通知使能状态回调函数。 |
Z
zhaoyuan17 已提交
959

X
xuzhihao 已提交
960
**示例:**
Z
zhaoyuan17 已提交
961 962 963 964 965 966 967 968 969 970 971

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



X
xuzhihao 已提交
972 973 974
## Notification.isNotificationEnabled

isNotificationEnabled(): Promise\<boolean\>
Z
zhaoyuan17 已提交
975

R
RayShih 已提交
976
获取通知使能状态(Promise形式)。
Z
zhaoyuan17 已提交
977

X
xuzhihao 已提交
978
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
979

X
xuzhihao 已提交
980
**参数:**
Z
zhaoyuan17 已提交
981

X
xuzhihao 已提交
982 983 984
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
Z
zhaoyuan17 已提交
985

X
xuzhihao 已提交
986
**返回值:**
Z
zhaoyuan17 已提交
987

X
xuzhihao 已提交
988 989 990
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取通知使能状态的结果。 |
Z
zhaoyuan17 已提交
991

X
xuzhihao 已提交
992
**示例:**
Z
zhaoyuan17 已提交
993 994 995 996 997 998 999 1000 1001

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



X
xuzhihao 已提交
1002
## Notification.displayBadge
Z
zhaoyuan17 已提交
1003

X
xuzhihao 已提交
1004
displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1005

R
RayShih 已提交
1006
设定指定包的角标使能状态(Callback形式)。
Z
zhaoyuan17 已提交
1007

X
xuzhihao 已提交
1008
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1009

X
xuzhihao 已提交
1010
**参数:**
Z
zhaoyuan17 已提交
1011

X
xuzhihao 已提交
1012 1013 1014 1015 1016
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)          | 是   | 指定包信息。           |
| enable   | 是   | 否  | boolean               | 是   | 使能状态。             |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 设定角标使能回调函数。 |
Z
zhaoyuan17 已提交
1017

X
xuzhihao 已提交
1018
**示例:**
Z
zhaoyuan17 已提交
1019 1020 1021 1022 1023 1024

```js
function displayBadgeCallback(err) {
	console.info("==========================>displayBadgeCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
1025
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1026 1027 1028 1029 1030 1031
}
Notification.displayBadge(bundle, false, displayBadgeCallback);
```



X
xuzhihao 已提交
1032
## Notification.displayBadge
Z
zhaoyuan17 已提交
1033

X
xuzhihao 已提交
1034
displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
Z
zhaoyuan17 已提交
1035

R
RayShih 已提交
1036
设定指定包的角标使能状态(Promise形式)。
Z
zhaoyuan17 已提交
1037

X
xuzhihao 已提交
1038
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1039

X
xuzhihao 已提交
1040
**参数:**
Z
zhaoyuan17 已提交
1041

X
xuzhihao 已提交
1042 1043 1044 1045
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
| enable | 是   | 否  | boolean      | 是   | 使能状态。   |
Z
zhaoyuan17 已提交
1046

X
xuzhihao 已提交
1047
**示例:**
Z
zhaoyuan17 已提交
1048 1049 1050

```js
var bundle = {
Z
zengsiyu 已提交
1051
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1052
}
Z
zengsiyu 已提交
1053
Notification.displayBadge(bundle, false).then(() => {
Z
zhaoyuan17 已提交
1054 1055 1056 1057 1058 1059
	console.info("==========================>displayBadgeCallback=======================>");
});
```



X
xuzhihao 已提交
1060
## Notification.isBadgeDisplayed
Z
zhaoyuan17 已提交
1061

X
xuzhihao 已提交
1062
isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
Z
zhaoyuan17 已提交
1063

R
RayShih 已提交
1064
获取指定包的角标使能状态(Callback形式)。
Z
zhaoyuan17 已提交
1065

X
xuzhihao 已提交
1066
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1067

X
xuzhihao 已提交
1068
**参数:**
Z
zhaoyuan17 已提交
1069

X
xuzhihao 已提交
1070 1071 1072 1073
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                     |
| -------- | ---- | --- | --------------------- | ---- | ------------------------ |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)          | 是   | 指定包信息。               |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 获取角标使能状态回调函数。 |
Z
zhaoyuan17 已提交
1074

X
xuzhihao 已提交
1075
**示例:**
Z
zhaoyuan17 已提交
1076 1077 1078 1079 1080 1081

```js
function isBadgeDisplayedCallback(err, data) {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
1082
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1083 1084 1085 1086 1087 1088
}
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
```



X
xuzhihao 已提交
1089
## Notification.isBadgeDisplayed
Z
zhaoyuan17 已提交
1090

X
xuzhihao 已提交
1091
isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
Z
zhaoyuan17 已提交
1092

R
RayShih 已提交
1093
获取指定包的角标使能状态(Promise形式)。
Z
zhaoyuan17 已提交
1094

X
xuzhihao 已提交
1095
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1096

X
xuzhihao 已提交
1097
**参数:**
Z
zhaoyuan17 已提交
1098

X
xuzhihao 已提交
1099 1100 1101
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
Z
zhaoyuan17 已提交
1102

X
xuzhihao 已提交
1103
**返回值:**
Z
zhaoyuan17 已提交
1104

X
xuzhihao 已提交
1105 1106 1107 1108 1109
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取指定包的角标使能状态。 |

**示例:**
Z
zhaoyuan17 已提交
1110 1111 1112

```js
var bundle = {
Z
zengsiyu 已提交
1113
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1114 1115 1116 1117 1118 1119 1120 1121
}
Notification.isBadgeDisplayed(bundle).then((data) => {
	console.info("==========================>isBadgeDisplayedCallback=======================>");
});
```



X
xuzhihao 已提交
1122
## Notification.setSlotByBundle
Z
zhaoyuan17 已提交
1123

X
xuzhihao 已提交
1124
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1125

R
RayShih 已提交
1126
设定指定包的通知通道状态(Callback形式)。
Z
zhaoyuan17 已提交
1127

X
xuzhihao 已提交
1128
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1129

X
xuzhihao 已提交
1130
**参数:**
Z
zhaoyuan17 已提交
1131

X
xuzhihao 已提交
1132 1133 1134
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)          | 是   | 指定包信息。           |
1135
| slot     | 是   | 否  | [NotificationSlot](#notificationslot)      | 是   | 通知通道。             |
X
xuzhihao 已提交
1136
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 设定通知通道回调函数。 |
Z
zhaoyuan17 已提交
1137

X
xuzhihao 已提交
1138
**示例:**
Z
zhaoyuan17 已提交
1139 1140 1141 1142 1143 1144

```js
function setSlotByBundleCallback(err) {
	console.info("==========================>setSlotByBundleCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
1145
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1146 1147
}
var notificationSlot = {
X
xuchenghua09 已提交
1148
    type: Notification.SlotType.SOCIAL_COMMUNICATION
Z
zhaoyuan17 已提交
1149 1150 1151 1152 1153 1154
}
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
```



X
xuzhihao 已提交
1155
## Notification.setSlotByBundle
Z
zhaoyuan17 已提交
1156

X
xuzhihao 已提交
1157
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
Z
zhaoyuan17 已提交
1158

R
RayShih 已提交
1159
设定指定包的角标使能状态(Promise形式)。
Z
zhaoyuan17 已提交
1160

X
xuzhihao 已提交
1161
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1162

X
xuzhihao 已提交
1163
**参数:**
Z
zhaoyuan17 已提交
1164

X
xuzhihao 已提交
1165 1166 1167
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
1168
| slot   | 是   | 否  | [NotificationSlot](#notificationslot) | 是   | 使能状态。   |
Z
zhaoyuan17 已提交
1169

X
xuzhihao 已提交
1170
**示例:**
Z
zhaoyuan17 已提交
1171 1172 1173

```js
var bundle = {
Z
zengsiyu 已提交
1174
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1175 1176
}
var notificationSlot = {
X
xuchenghua09 已提交
1177
    type: Notification.SlotType.SOCIAL_COMMUNICATION
Z
zhaoyuan17 已提交
1178
}
Z
zengsiyu 已提交
1179
Notification.displayBadge(bundle, notificationSlot).then(() => {
Z
zhaoyuan17 已提交
1180 1181 1182 1183 1184 1185
	console.info("==========================>setSlotByBundleCallback=======================>");
});
```



X
xuzhihao 已提交
1186
## Notification.getSlotsByBundle
Z
zhaoyuan17 已提交
1187

X
xuzhihao 已提交
1188
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
Z
zhaoyuan17 已提交
1189

R
RayShih 已提交
1190
获取指定包的通知通道(Callback形式)。
Z
zhaoyuan17 已提交
1191

X
xuzhihao 已提交
1192
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1193

X
xuzhihao 已提交
1194
**参数:**
Z
zhaoyuan17 已提交
1195

X
xuzhihao 已提交
1196 1197 1198
| 名称     | 可读 | 可写 | 类型                                     | 必填 | 描述                 |
| -------- | ---- | --- | ---------------------------------------- | ---- | -------------------- |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)                             | 是   | 指定包信息。           |
1199
| callback | 是   | 否  | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | 是   | 获取通知通道回调函数。 |
Z
zhaoyuan17 已提交
1200

X
xuzhihao 已提交
1201
**示例:**
Z
zhaoyuan17 已提交
1202 1203 1204 1205 1206 1207

```js
function getSlotsByBundleCallback(err, data) {
	console.info("==========================>getSlotsByBundleCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
1208
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1209 1210 1211 1212 1213 1214
}
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
```



X
xuzhihao 已提交
1215
## Notification.getSlotsByBundle
Z
zhaoyuan17 已提交
1216

X
xuzhihao 已提交
1217
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
Z
zhaoyuan17 已提交
1218

R
RayShih 已提交
1219
获取指定包的通知通道(Promise形式)。
Z
zhaoyuan17 已提交
1220

X
xuzhihao 已提交
1221
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1222

X
xuzhihao 已提交
1223
**参数:**
Z
zhaoyuan17 已提交
1224

X
xuzhihao 已提交
1225 1226 1227
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
Z
zhaoyuan17 已提交
1228

X
xuzhihao 已提交
1229
**返回值:**
Z
zhaoyuan17 已提交
1230

X
xuzhihao 已提交
1231 1232
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
1233
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | 以Promise形式返回获取指定包的通知通道。 |
X
xuzhihao 已提交
1234 1235

**示例:**
Z
zhaoyuan17 已提交
1236 1237 1238

```js
var bundle = {
Z
zengsiyu 已提交
1239
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1240 1241 1242 1243 1244 1245 1246 1247
}
Notification.getSlotsByBundle(bundle).then((data) => {
	console.info("==========================>getSlotsByBundleCallback=======================>");
});
```



X
xuzhihao 已提交
1248
## Notification.getSlotNumByBundle
Z
zhaoyuan17 已提交
1249

X
xuzhihao 已提交
1250
getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
Z
zhaoyuan17 已提交
1251

R
RayShih 已提交
1252
获取指定包的通知通道数(Callback形式)。
Z
zhaoyuan17 已提交
1253

X
xuzhihao 已提交
1254
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1255

X
xuzhihao 已提交
1256
**参数:**
Z
zhaoyuan17 已提交
1257

X
xuzhihao 已提交
1258 1259 1260 1261
| 名称     | 可读 | 可写 | 类型                      | 必填 | 描述                   |
| -------- | ---- | --- | ------------------------- | ---- | ---------------------- |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)              | 是   | 指定包信息。             |
| callback | 是   | 否  | AsyncCallback\<number\> | 是   | 获取通知通道数回调函数。 |
Z
zhaoyuan17 已提交
1262

X
xuzhihao 已提交
1263
**示例:**
Z
zhaoyuan17 已提交
1264 1265 1266 1267 1268 1269

```js
function getSlotNumByBundle(err, data) {
	console.info("==========================>getSlotNumByBundleCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
1270
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1271 1272 1273 1274 1275 1276
}
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
```



X
xuzhihao 已提交
1277 1278 1279
## Notification.getSlotNumByBundle

getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
Z
zhaoyuan17 已提交
1280

R
RayShih 已提交
1281
获取指定包的通知通道数(Promise形式)。
Z
zhaoyuan17 已提交
1282

X
xuzhihao 已提交
1283
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1284

X
xuzhihao 已提交
1285
**参数:**
Z
zhaoyuan17 已提交
1286

X
xuzhihao 已提交
1287 1288 1289
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。 |
Z
zhaoyuan17 已提交
1290

X
xuzhihao 已提交
1291
**返回值:**
Z
zhaoyuan17 已提交
1292

X
xuzhihao 已提交
1293 1294 1295
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | 以Promise形式返回获取指定包的通知通道数。 |
Z
zhaoyuan17 已提交
1296

X
xuzhihao 已提交
1297
**示例:**
Z
zhaoyuan17 已提交
1298 1299 1300

```js
var bundle = {
Z
zengsiyu 已提交
1301
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1302 1303 1304 1305 1306 1307 1308 1309
}
Notification.getSlotNumByBundle(bundle).then((data) => {
	console.info("==========================>getSlotNumByBundleCallback=======================>");
});
```



X
xuzhihao 已提交
1310
## Notification.remove
Z
zhaoyuan17 已提交
1311

X
xuzhihao 已提交
1312
remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1313

R
RayShih 已提交
1314
删除指定通知(Callback形式)。
Z
zhaoyuan17 已提交
1315

X
xuzhihao 已提交
1316
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1317

X
xuzhihao 已提交
1318
**参数:**
Z
zhaoyuan17 已提交
1319

X
xuzhihao 已提交
1320 1321 1322 1323 1324
| 名称            | 可读 | 可写 | 类型                                | 必填 | 描述                 |
| --------------- | ---- | --- | ----------------------------------- | ---- | -------------------- |
| bundle          | 是   | 否  | [BundleOption](#bundleoption)       | 是   | 指定包信息。           |
| notificationKey | 是   | 否  | [NotificationKey](#notificationkey) | 是   | 通知键值。             |
| callback        | 是   | 否  | AsyncCallback\<void\>               | 是   | 删除指定通知回调函数。 |
Z
zhaoyuan17 已提交
1325

X
xuzhihao 已提交
1326
**示例:**
Z
zhaoyuan17 已提交
1327 1328 1329 1330 1331 1332

```js
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
1333
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1334 1335
}
var notificationKey = {
Z
zengsiyu 已提交
1336 1337
    id: 0,
    label: "label",
Z
zhaoyuan17 已提交
1338 1339 1340 1341 1342 1343
}
Notification.remove(bundle, notificationKey, removeCallback);
```



X
xuzhihao 已提交
1344
## Notification.remove
Z
zhaoyuan17 已提交
1345

X
xuzhihao 已提交
1346
remove(bundle: BundleOption, notificationKey: NotificationKey): Promise\<void\>
Z
zhaoyuan17 已提交
1347

R
RayShih 已提交
1348
删除指定通知(Promise形式)。
Z
zhaoyuan17 已提交
1349

X
xuzhihao 已提交
1350
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1351

X
xuzhihao 已提交
1352
**参数:**
Z
zhaoyuan17 已提交
1353

X
xuzhihao 已提交
1354 1355 1356 1357
| 名称            | 可读 | 可写 | 类型            | 必填 | 描述       |
| --------------- | ---- | --- | --------------- | ---- | ---------- |
| bundle          | 是   | 否  | [BundleOption](#bundleoption)    | 是   | 指定包信息。 |
| notificationKey | 是   | 否  | [NotificationKey](#notificationkey) | 是   | 通知键值。   |
Z
zhaoyuan17 已提交
1358

X
xuzhihao 已提交
1359
**示例:**
Z
zhaoyuan17 已提交
1360 1361 1362

```js
var bundle = {
Z
zengsiyu 已提交
1363
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1364 1365
}
var notificationKey = {
Z
zengsiyu 已提交
1366 1367
    id: 0,
    label: "label",
Z
zhaoyuan17 已提交
1368
}
Z
zengsiyu 已提交
1369
Notification.remove(bundle, notificationKey).then(() => {
Z
zhaoyuan17 已提交
1370 1371 1372 1373 1374 1375
	console.info("==========================>removeCallback=======================>");
});
```



X
xuzhihao 已提交
1376
## Notification.remove
Z
zhaoyuan17 已提交
1377

X
xuzhihao 已提交
1378
remove(hashCode: string, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1379

R
RayShih 已提交
1380
删除指定通知(Callback形式)。
Z
zhaoyuan17 已提交
1381

X
xuzhihao 已提交
1382
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1383

X
xuzhihao 已提交
1384
**参数:**
Z
zhaoyuan17 已提交
1385

X
xuzhihao 已提交
1386 1387 1388 1389
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| hashCode | 是   | 否  | string                | 是   | 通知唯一ID。           |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 删除指定通知回调函数。 |
Z
zhaoyuan17 已提交
1390

X
xuzhihao 已提交
1391
**示例:**
Z
zhaoyuan17 已提交
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402

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

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



X
xuzhihao 已提交
1403
## Notification.remove
Z
zhaoyuan17 已提交
1404

X
xuzhihao 已提交
1405
remove(hashCode: string): Promise\<void\>
Z
zhaoyuan17 已提交
1406

R
RayShih 已提交
1407
删除指定通知(Promise形式)。
Z
zhaoyuan17 已提交
1408

X
xuzhihao 已提交
1409
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1410

X
xuzhihao 已提交
1411
**参数:**
Z
zhaoyuan17 已提交
1412

X
xuzhihao 已提交
1413 1414 1415
| 名称     | 可读 | 可写 | 类型       | 必填 | 描述       |
| -------- | ---- | --- | ---------- | ---- | ---------- |
| hashCode | 是   | 否  | string | 是   | 通知唯一ID。 |
Z
zhaoyuan17 已提交
1416

X
xuzhihao 已提交
1417
**示例:**
Z
zhaoyuan17 已提交
1418 1419

```js
Z
zengsiyu 已提交
1420
Notification.remove(hashCode).then(() => {
Z
zhaoyuan17 已提交
1421 1422 1423 1424 1425 1426
	console.info("==========================>removeCallback=======================>");
});
```



X
xuzhihao 已提交
1427
## Notification.removeAll
Z
zhaoyuan17 已提交
1428

X
xuzhihao 已提交
1429
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1430

R
RayShih 已提交
1431
删除指定包的所有通知(Callback形式)。
Z
zhaoyuan17 已提交
1432

X
xuzhihao 已提交
1433
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1434

X
xuzhihao 已提交
1435
**参数:**
Z
zhaoyuan17 已提交
1436

X
xuzhihao 已提交
1437 1438 1439 1440
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                         |
| -------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| bundle   | 是   | 否  | [BundleOption](#bundleoption)          | 是   | 指定包信息。                   |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 删除指定包的所有通知回调函数。 |
Z
zhaoyuan17 已提交
1441

X
xuzhihao 已提交
1442
**示例:**
Z
zhaoyuan17 已提交
1443 1444 1445 1446 1447 1448

```js
function removeAllCallback(err) {
	console.info("==========================>removeAllCallback=======================>");
}
var bundle = {
Z
zengsiyu 已提交
1449
    bundle: "bundleName1",
Z
zhaoyuan17 已提交
1450 1451 1452 1453 1454 1455
}
Notification.removeAll(bundle, removeAllCallback);
```



X
xuzhihao 已提交
1456
## Notification.removeAll
Z
zhaoyuan17 已提交
1457

X
xuzhihao 已提交
1458
removeAll(callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1459

R
RayShih 已提交
1460
删除所有通知(Callback形式)。
Z
zhaoyuan17 已提交
1461

X
xuzhihao 已提交
1462
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1463

X
xuzhihao 已提交
1464
**参数:**
Z
zhaoyuan17 已提交
1465

X
xuzhihao 已提交
1466 1467 1468
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                 |
| -------- | ---- | --- | --------------------- | ---- | -------------------- |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 删除所有通知回调函数。 |
Z
zhaoyuan17 已提交
1469

X
xuzhihao 已提交
1470
**示例:**
Z
zhaoyuan17 已提交
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481

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

Notification.removeAll(removeAllCallback);
```



X
xuzhihao 已提交
1482
## Notification.removeAll
Z
zhaoyuan17 已提交
1483

X
xuzhihao 已提交
1484
removeAll(bundle?: BundleOption): Promise\<void\>
Z
zhaoyuan17 已提交
1485

R
RayShih 已提交
1486
删除所有通知(Promise形式)。
Z
zhaoyuan17 已提交
1487

X
xuzhihao 已提交
1488
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1489

X
xuzhihao 已提交
1490
**参数:**
Z
zhaoyuan17 已提交
1491

X
xuzhihao 已提交
1492 1493 1494
| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| bundle | 是   | 否  | [BundleOption](#bundleoption) | 否   | 指定包信息。 |
Z
zhaoyuan17 已提交
1495

X
xuzhihao 已提交
1496
**示例:**
Z
zhaoyuan17 已提交
1497 1498

```js
Z
zengsiyu 已提交
1499
Notification.removeAll().then(() => {
Z
zhaoyuan17 已提交
1500 1501 1502 1503
	console.info("==========================>removeAllCallback=======================>");
});
```

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

X
xuzhihao 已提交
1506
removeAll(userId: number, callback: AsyncCallback\<void>): void
1507

R
RayShih 已提交
1508
删除所有通知(callback形式)。
1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| userId | 是   | 否  | number | 是   | 接收通知用户的Id。 |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 删除所有通知回调函数。 |

**示例:**

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

var userId = 1

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

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

X
xuzhihao 已提交
1533
removeAll(userId: number): Promise\<void>
1534

R
RayShih 已提交
1535
删除所有通知(Promise形式)。
1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称   | 可读 | 可写 | 类型         | 必填 | 描述       |
| ------ | ---- | --- | ------------ | ---- | ---------- |
| userId | 是   | 否  | number | 是   | 接收通知用户的Id。 |

**示例:**

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

var userId = 1

Notification.removeAll(userId, removeAllCallback);
```
Z
zhaoyuan17 已提交
1556 1557


X
xuzhihao 已提交
1558
## Notification.getAllActiveNotifications
Z
zhaoyuan17 已提交
1559

X
xuzhihao 已提交
1560
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
Z
zhaoyuan17 已提交
1561

R
RayShih 已提交
1562
获取活动通知(Callback形式)。
Z
zhaoyuan17 已提交
1563

X
xuzhihao 已提交
1564
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1565

X
xuzhihao 已提交
1566
**参数:**
Z
zhaoyuan17 已提交
1567

X
xuzhihao 已提交
1568 1569 1570
| 名称     | 可读 | 可写 | 类型                                                         | 必填 | 描述                 |
| -------- | ---- | --- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | 是   | 否  | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是   | 获取活动通知回调函数。 |
Z
zhaoyuan17 已提交
1571

X
xuzhihao 已提交
1572
**示例:**
Z
zhaoyuan17 已提交
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583

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

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



X
xuzhihao 已提交
1584
## Notification.getAllActiveNotifications
Z
zhaoyuan17 已提交
1585

X
xuzhihao 已提交
1586
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
Z
zhaoyuan17 已提交
1587

R
RayShih 已提交
1588
获取活动通知(Promise形式)。
Z
zhaoyuan17 已提交
1589

X
xuzhihao 已提交
1590
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1591

X
xuzhihao 已提交
1592
**返回值:**
Z
zhaoyuan17 已提交
1593

X
xuzhihao 已提交
1594 1595 1596
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | 以Promise形式返回获取活动通知。 |
Z
zhaoyuan17 已提交
1597

X
xuzhihao 已提交
1598
**示例:**
Z
zhaoyuan17 已提交
1599 1600 1601 1602 1603 1604 1605 1606 1607

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



X
xuzhihao 已提交
1608
## Notification.getActiveNotificationCount
Z
zhaoyuan17 已提交
1609

X
xuzhihao 已提交
1610
getActiveNotificationCount(callback: AsyncCallback\<number\>): void
Z
zhaoyuan17 已提交
1611

R
RayShih 已提交
1612
获取当前应用的活动通知数(Callback形式)。
Z
zhaoyuan17 已提交
1613

X
xuzhihao 已提交
1614
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1615

X
xuzhihao 已提交
1616
**参数:**
Z
zhaoyuan17 已提交
1617

X
xuzhihao 已提交
1618 1619 1620
| 名称     | 可读 | 可写 | 类型                   | 必填 | 描述                   |
| -------- | ---- | --- | ---------------------- | ---- | ---------------------- |
| callback | 是   | 否  | AsyncCallback\<number\> | 是   | 获取活动通知数回调函数。 |
Z
zhaoyuan17 已提交
1621

X
xuzhihao 已提交
1622
**示例:**
Z
zhaoyuan17 已提交
1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633

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

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



X
xuzhihao 已提交
1634
## Notification.getActiveNotificationCount
Z
zhaoyuan17 已提交
1635

X
xuzhihao 已提交
1636
getActiveNotificationCount(): Promise\<number\>
Z
zhaoyuan17 已提交
1637

R
RayShih 已提交
1638
获取当前应用的活动通知数(Promise形式)。
Z
zhaoyuan17 已提交
1639

X
xuzhihao 已提交
1640
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1641

X
xuzhihao 已提交
1642
**返回值:**
Z
zhaoyuan17 已提交
1643

X
xuzhihao 已提交
1644 1645 1646
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | 以Promise形式返回获取当前应用的活动通知数。 |
Z
zhaoyuan17 已提交
1647

X
xuzhihao 已提交
1648
**示例:**
Z
zhaoyuan17 已提交
1649 1650 1651 1652 1653 1654 1655 1656 1657

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



X
xuzhihao 已提交
1658
## Notification.getActiveNotifications
Z
zhaoyuan17 已提交
1659

X
xuzhihao 已提交
1660
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
Z
zhaoyuan17 已提交
1661

R
RayShih 已提交
1662
获取当前应用的活动通知(Callback形式)。
Z
zhaoyuan17 已提交
1663

X
xuzhihao 已提交
1664
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1665

X
xuzhihao 已提交
1666
**参数:**
Z
zhaoyuan17 已提交
1667

X
xuzhihao 已提交
1668 1669 1670
| 名称     | 可读 | 可写 | 类型                                                         | 必填 | 描述                           |
| -------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | 是   | 否  | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是   | 获取当前应用的活动通知回调函数。 |
Z
zhaoyuan17 已提交
1671

X
xuzhihao 已提交
1672
**示例:**
Z
zhaoyuan17 已提交
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683

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

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



X
xuzhihao 已提交
1684
## Notification.getActiveNotifications
Z
zhaoyuan17 已提交
1685

X
xuzhihao 已提交
1686
getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
Z
zhaoyuan17 已提交
1687

R
RayShih 已提交
1688
获取当前应用的活动通知(Promise形式)。
Z
zhaoyuan17 已提交
1689

X
xuzhihao 已提交
1690
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1691

X
xuzhihao 已提交
1692
**返回值:**
Z
zhaoyuan17 已提交
1693

X
xuzhihao 已提交
1694 1695 1696
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | 以Promise形式返回获取当前应用的活动通知。 |
Z
zhaoyuan17 已提交
1697

X
xuzhihao 已提交
1698
**示例:**
Z
zhaoyuan17 已提交
1699 1700 1701 1702 1703 1704 1705 1706 1707

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



1708
## Notification.cancelGroup<sup>8+</sup>
Z
zhaoyuan17 已提交
1709

X
xuzhihao 已提交
1710
cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1711

R
RayShih 已提交
1712
取消本应用指定组通知(Callback形式)。
Z
zhaoyuan17 已提交
1713

X
xuzhihao 已提交
1714
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1715

X
xuzhihao 已提交
1716
**参数:**
Z
zhaoyuan17 已提交
1717

X
xuzhihao 已提交
1718 1719 1720 1721
| 名称      | 可读 | 可写 | 类型                  | 必填 | 描述                         |
| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| groupName | 是   | 否  | string                | 是   | 指定通知组名称。               |
| callback  | 是   | 否  | AsyncCallback\<void\> | 是   | 取消本应用指定组通知回调函数。 |
Z
zhaoyuan17 已提交
1722

X
xuzhihao 已提交
1723
**示例:**
Z
zhaoyuan17 已提交
1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736

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

var groupName = "GroupName";

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



1737
## Notification.cancelGroup<sup>8+</sup>
Z
zhaoyuan17 已提交
1738

X
xuzhihao 已提交
1739
cancelGroup(groupName: string): Promise\<void\>
Z
zhaoyuan17 已提交
1740

R
RayShih 已提交
1741
取消本应用指定组通知(Promise形式)。
Z
zhaoyuan17 已提交
1742

X
xuzhihao 已提交
1743
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1744

X
xuzhihao 已提交
1745
**参数:**
Z
zhaoyuan17 已提交
1746

X
xuzhihao 已提交
1747 1748 1749
| 名称      | 可读 | 可写 | 类型   | 必填 | 描述           |
| --------- | ---- | --- | ------ | ---- | -------------- |
| groupName | 是   | 否  | string | 是   | 指定通知组名称。 |
Z
zhaoyuan17 已提交
1750

X
xuzhihao 已提交
1751
**示例:**
Z
zhaoyuan17 已提交
1752 1753 1754 1755 1756 1757 1758 1759 1760 1761

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



1762
## Notification.removeGroupByBundle<sup>8+</sup>
Z
zhaoyuan17 已提交
1763

X
xuzhihao 已提交
1764
removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1765

R
RayShih 已提交
1766
删除指定应用指定组通知(Callback形式)。
Z
zhaoyuan17 已提交
1767

X
xuzhihao 已提交
1768
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1769

X
xuzhihao 已提交
1770
**参数:**
Z
zhaoyuan17 已提交
1771

X
xuzhihao 已提交
1772 1773 1774 1775 1776
| 名称      | 可读 | 可写 | 类型                  | 必填 | 描述                         |
| --------- | ---- | --- | --------------------- | ---- | ---------------------------- |
| bundle    | 是   | 否  | [BundleOption](#bundleoption)          | 是   | 指定包信息。                   |
| groupName | 是   | 否  | string                | 是   | 指定通知组名称。               |
| callback  | 是   | 否  | AsyncCallback\<void\> | 是   | 删除本应用指定组通知回调函数。 |
Z
zhaoyuan17 已提交
1777

X
xuzhihao 已提交
1778
**示例:**
Z
zhaoyuan17 已提交
1779 1780 1781 1782 1783 1784

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

X
xuchenghua09 已提交
1785
var bundleOption = {bundle: "Bundle"};
Z
zhaoyuan17 已提交
1786 1787 1788 1789 1790 1791 1792
var groupName = "GroupName";

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



1793
## Notification.removeGroupByBundle<sup>8+</sup>
Z
zhaoyuan17 已提交
1794

X
xuzhihao 已提交
1795
removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
Z
zhaoyuan17 已提交
1796

R
RayShih 已提交
1797
删除指定应用指定组通知(Promise形式)。
Z
zhaoyuan17 已提交
1798

X
xuzhihao 已提交
1799
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1800

X
xuzhihao 已提交
1801
**参数:**
Z
zhaoyuan17 已提交
1802

X
xuzhihao 已提交
1803 1804 1805 1806
| 名称      | 可读 | 可写 | 类型         | 必填 | 描述           |
| --------- | ---- | --- | ------------ | ---- | -------------- |
| bundle    | 是   | 否  | [BundleOption](#bundleoption) | 是   | 指定包信息。     |
| groupName | 是   | 否  | string       | 是   | 指定通知组名称。 |
Z
zhaoyuan17 已提交
1807

X
xuzhihao 已提交
1808
**示例:**
Z
zhaoyuan17 已提交
1809 1810

```js
X
xuchenghua09 已提交
1811
var bundleOption = {bundle: "Bundle"};
Z
zhaoyuan17 已提交
1812 1813 1814 1815 1816 1817 1818 1819
var groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
	console.info("==========================>removeGroupByBundlePromise=======================>");
});
```



1820
## Notification.setDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1821

X
xuzhihao 已提交
1822
setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
Z
zhaoyuan17 已提交
1823

R
RayShih 已提交
1824
设置免打扰时间(Callback形式)。
Z
zhaoyuan17 已提交
1825

X
xuzhihao 已提交
1826
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1827

X
xuzhihao 已提交
1828
**参数:**
Z
zhaoyuan17 已提交
1829

X
xuzhihao 已提交
1830 1831
| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                   |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
1832
| date     | 是   | 否  | [DoNotDisturbDate](#donotdisturbdate8)      | 是   | 免打扰时间选项。         |
X
xuzhihao 已提交
1833
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |
Z
zhaoyuan17 已提交
1834

X
xuzhihao 已提交
1835
**示例:**
Z
zhaoyuan17 已提交
1836 1837 1838 1839 1840 1841 1842

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

var doNotDisturbDate = {
Z
zengsiyu 已提交
1843
    type: Notification.DoNotDisturbType.TYPE_ONCE,
X
xuchenghua09 已提交
1844 1845
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
Z
zhaoyuan17 已提交
1846 1847 1848 1849 1850 1851 1852
}

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



1853
## Notification.setDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1854

X
xuzhihao 已提交
1855
setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
Z
zhaoyuan17 已提交
1856

R
RayShih 已提交
1857
设置免打扰时间接口(Promise形式)。
Z
zhaoyuan17 已提交
1858

X
xuzhihao 已提交
1859
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1860

X
xuzhihao 已提交
1861
**参数:**
Z
zhaoyuan17 已提交
1862

X
xuzhihao 已提交
1863 1864
| 名称 | 可读 | 可写 | 类型             | 必填 | 描述           |
| ---- | ---- | --- | ---------------- | ---- | -------------- |
1865
| date | 是   | 否  | [DoNotDisturbDate](#donotdisturbdate8) | 是   | 免打扰时间选项。 |
Z
zhaoyuan17 已提交
1866

X
xuzhihao 已提交
1867
**示例:**
Z
zhaoyuan17 已提交
1868 1869 1870

```js
var doNotDisturbDate = {
Z
zengsiyu 已提交
1871
    type: Notification.DoNotDisturbType.TYPE_ONCE,
X
xuchenghua09 已提交
1872 1873
    begin: new Date(),
    end: new Date(2021, 11, 15, 18, 0)
Z
zhaoyuan17 已提交
1874 1875 1876 1877 1878 1879 1880
}
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
	console.info("==========================>setDoNotDisturbDatePromise=======================>");
});
```


1881 1882 1883 1884
## Notification.setDoNotDisturbDate<sup>8+</sup>

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

R
RayShih 已提交
1885
指定用户设置免打扰时间(Callback形式)。
1886 1887 1888 1889 1890 1891 1892

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                   |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
1893
| date     | 是   | 否  | [DoNotDisturbDate](#donotdisturbdate8)      | 是   | 免打扰时间选项。         |
1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920
| userId   | 是   | 否  | number                | 是   | 设置免打扰事件的用户ID。 |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |

**示例:**

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

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

var userId = 1

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



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

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

R
RayShih 已提交
1921
指定用户设置免打扰时间接口(Promise形式)。
1922 1923 1924 1925 1926 1927 1928

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称   | 可读 | 可写 | 类型             | 必填 | 描述           |
| ------ | ---- | --- | ---------------- | ---- | -------------- |
1929
| date   | 是   | 否  | [DoNotDisturbDate](#donotdisturbdate8) | 是   | 免打扰时间选项。 |
1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947
| userId | 是   | 否  | number           | 是   | 设置免打扰事件的用户ID。 |

**示例:**

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

var userId = 1

Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
	console.info("==========================>setDoNotDisturbDatePromise=======================>");
});
```

Z
zhaoyuan17 已提交
1948

1949
## Notification.getDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1950

X
xuzhihao 已提交
1951
getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
Z
zhaoyuan17 已提交
1952

R
RayShih 已提交
1953
查询免打扰时间接口(Callback形式)。
Z
zhaoyuan17 已提交
1954

X
xuzhihao 已提交
1955
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1956

X
xuzhihao 已提交
1957
**参数:**
Z
zhaoyuan17 已提交
1958

X
xuzhihao 已提交
1959 1960
| 名称     | 可读 | 可写 | 类型                              | 必填 | 描述                   |
| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
1961
| callback | 是   | 否  | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | 是   | 查询免打扰时间回调函数。 |
Z
zhaoyuan17 已提交
1962

X
xuzhihao 已提交
1963
**示例:**
Z
zhaoyuan17 已提交
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974

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

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



1975
## Notification.getDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1976

X
xuzhihao 已提交
1977
getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
Z
zhaoyuan17 已提交
1978

R
RayShih 已提交
1979
查询免打扰时间接口(Promise形式)。
Z
zhaoyuan17 已提交
1980

X
xuzhihao 已提交
1981
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
1982

X
xuzhihao 已提交
1983
**返回值:**
Z
zhaoyuan17 已提交
1984

X
xuzhihao 已提交
1985 1986
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
1987
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 |
Z
zhaoyuan17 已提交
1988

X
xuzhihao 已提交
1989
**示例:**
Z
zhaoyuan17 已提交
1990 1991 1992 1993 1994 1995 1996 1997

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


1998 1999 2000 2001
## Notification.getDoNotDisturbDate<sup>8+</sup>

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

R
RayShih 已提交
2002
指定用户查询免打扰时间接口(Callback形式)。
2003 2004 2005 2006 2007 2008 2009

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称     | 可读 | 可写 | 类型                              | 必填 | 描述                   |
| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
2010
| callback | 是   | 否  | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | 是   | 查询免打扰时间回调函数。 |
2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030
| userId   | 是   | 否  | number                            | 是   | 设置免打扰事件的用户ID。 |

**示例:**

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

var userId = 1

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



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

getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>

R
RayShih 已提交
2031
指定用户查询免打扰时间接口(Promise形式)。
2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 名称     | 可读 | 可写 | 类型                              | 必填 | 描述                   |
| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
| userId   | 是   | 否  | number                            | 是   | 设置免打扰事件的用户ID。 |

**返回值:**

| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
2045
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 |
2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056

**示例:**

```js
var userId = 1

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

Z
zhaoyuan17 已提交
2057

2058
## Notification.supportDoNotDisturbMode<sup>8+</sup>
Z
zhaoyuan17 已提交
2059

X
xuzhihao 已提交
2060
supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
Z
zhaoyuan17 已提交
2061

R
RayShih 已提交
2062
查询是否支持勿扰模式功能(Callback形式)。
Z
zhaoyuan17 已提交
2063

X
xuzhihao 已提交
2064
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2065

X
xuzhihao 已提交
2066
**参数:**
Z
zhaoyuan17 已提交
2067

X
xuzhihao 已提交
2068 2069 2070
| 名称     | 可读 | 可写 | 类型                     | 必填 | 描述                             |
| -------- | ---- | --- | ------------------------ | ---- | -------------------------------- |
| callback | 是   | 否  | AsyncCallback\<boolean\> | 是   | 查询是否支持勿扰模式功能回调函数。 |
Z
zhaoyuan17 已提交
2071

X
xuzhihao 已提交
2072
**示例:**
Z
zhaoyuan17 已提交
2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083

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

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



2084
## Notification.supportDoNotDisturbMode<sup>8+</sup>
Z
zhaoyuan17 已提交
2085

X
xuzhihao 已提交
2086
supportDoNotDisturbMode(): Promise\<boolean\>
Z
zhaoyuan17 已提交
2087

R
RayShih 已提交
2088
查询是否支持勿扰模式功能(Promise形式)。
Z
zhaoyuan17 已提交
2089

X
xuzhihao 已提交
2090
**系统能力**:SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2091

X
xuzhihao 已提交
2092
**返回值:**
Z
zhaoyuan17 已提交
2093

X
xuzhihao 已提交
2094 2095 2096
| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取是否支持勿扰模式功能的结果。 |
Z
zhaoyuan17 已提交
2097

X
xuzhihao 已提交
2098
**示例:**
Z
zhaoyuan17 已提交
2099 2100 2101 2102 2103 2104 2105 2106 2107

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



2108
## Notification.isSupportTemplate<sup>8+</sup>
Z
zengsiyu 已提交
2109 2110 2111 2112 2113

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

查询模板是否存在。

X
xuzhihao 已提交
2114 2115 2116
**系统能力**:SystemCapability.Notification.Notification

**参数:**
Z
zengsiyu 已提交
2117 2118 2119

| 参数名       | 类型                     | 必填 | 说明                       |
| ------------ | ------------------------ | ---- | -------------------------- |
X
xuzhihao 已提交
2120 2121
| templateName | string                   | 是   | 模板名称。                   |
| callback     | AsyncCallback\<boolean\> | 是   | 查询模板是否存在的回调函数。 |
Z
zengsiyu 已提交
2122

X
xuzhihao 已提交
2123
**示例:**
Z
zengsiyu 已提交
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135

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

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



2136
## Notification.isSupportTemplate<sup>8+</sup>
Z
zengsiyu 已提交
2137 2138 2139 2140 2141

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

查询模板是否存在。

X
xuzhihao 已提交
2142 2143 2144
**系统能力**:SystemCapability.Notification.Notification

**参数:**
Z
zengsiyu 已提交
2145 2146 2147

| 参数名       | 类型   | 必填 | 说明     |
| ------------ | ------ | ---- | -------- |
X
xuzhihao 已提交
2148
| templateName | string | 是   | 模板名称。 |
Z
zengsiyu 已提交
2149

X
xuzhihao 已提交
2150
**返回值:**
Z
zengsiyu 已提交
2151 2152 2153

| 类型               | 说明            |
| ------------------ | --------------- |
X
xuzhihao 已提交
2154
| Promise\<boolean\> | Promise方式返回模板是否存在的结果。 |
Z
zengsiyu 已提交
2155

X
xuzhihao 已提交
2156
**示例:**
Z
zengsiyu 已提交
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167

```javascript
var templateName = 'process';

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



2168
## Notification.requestEnableNotification<sup>8+</sup>
Z
zengsiyu 已提交
2169

X
xuzhihao 已提交
2170
requestEnableNotification(callback: AsyncCallback\<void\>): void
Z
zengsiyu 已提交
2171 2172 2173

应用请求通知使能。

X
xuzhihao 已提交
2174 2175 2176
**系统能力**:SystemCapability.Notification.Notification

**参数:**
Z
zengsiyu 已提交
2177 2178 2179

| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
2180
| callback | AsyncCallback\<void\> | 是   | 应用请求通知使能的回调函数。 |
Z
zengsiyu 已提交
2181

X
xuzhihao 已提交
2182
**示例:**
Z
zengsiyu 已提交
2183 2184

```javascript
2185 2186
function requestEnabledNotificationCallback() {
    console.log('------------- requestEnabledNotification --------------');
Z
zengsiyu 已提交
2187 2188 2189 2190 2191 2192 2193
};

Notification.requestEnabledNotification(requestEnabledNotificationCallback);
```



2194
## Notification.requestEnableNotification<sup>8+</sup>
Z
zengsiyu 已提交
2195

X
xuzhihao 已提交
2196
requestEnableNotification(): Promise\<void\>
Z
zengsiyu 已提交
2197 2198 2199

应用请求通知使能。

X
xuzhihao 已提交
2200 2201 2202
**系统能力**:SystemCapability.Notification.Notification

**示例:**
Z
zengsiyu 已提交
2203 2204

```javascript
2205
Notification.requestEnableNotification()
Z
zengsiyu 已提交
2206
    .then(() => {
2207
        console.info("requestEnableNotification ");
Z
zengsiyu 已提交
2208 2209 2210 2211
	});
```


2212
## Notification.enableDistributed<sup>8+</sup>
X
xuzhihao 已提交
2213

2214
enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void
X
xuzhihao 已提交
2215

2216
设置设备是否支持分布式通知。
X
xuzhihao 已提交
2217 2218 2219 2220 2221

**系统能力**:SystemCapability.Notification.Notification

**参数:**

2222 2223 2224 2225
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
| enable   | boolean                  | 是   | 是否支持。<br/>true 支持。<br/>false 不支持。|
| callback | AsyncCallback\<void\> | 是   | 设置设备是否支持分布式通知的回调函数。 |
X
xuzhihao 已提交
2226 2227 2228 2229

**示例:**

```javascript
2230 2231
function enabledNotificationCallback() {
    console.log('----------- enableDistributed ------------');
X
xuzhihao 已提交
2232 2233
};

2234 2235 2236
var enable = true

Notification.enableDistributed(enable, enabledNotificationCallback);
X
xuzhihao 已提交
2237 2238 2239
```


Z
zengsiyu 已提交
2240

2241
## Notification.enableDistributed<sup>8+</sup>
Z
zengsiyu 已提交
2242

X
xuzhihao 已提交
2243
enableDistributed(enable: boolean): Promise\<void>
X
xuezhongzhu 已提交
2244

2245
设置设备是否支持分布式通知。
Z
zengsiyu 已提交
2246

2247
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2248

2249
**参数:**
Z
zengsiyu 已提交
2250

2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
| enable   | boolean                  | 是   | 是否支持。<br/>true 支持。<br/>false 不支持。|

**示例:**

```javascript
var enable = true

Notification.enableDistributed(enable)
    .then(() => {
        console.log('-------- enableDistributed ----------');
    });
```


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

X
xuzhihao 已提交
2269
isDistributedEnabled(callback: AsyncCallback\<boolean>): void
2270 2271

获取设备是否支持分布式通知。
Z
zengsiyu 已提交
2272

X
xuzhihao 已提交
2273 2274 2275
**系统能力**:SystemCapability.Notification.Notification

**参数:**
Z
zengsiyu 已提交
2276

2277 2278 2279
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<boolean\> | 是   | 设备是否支持分布式通知的回调函数。 |
Z
zengsiyu 已提交
2280

X
xuzhihao 已提交
2281
**示例:**
Z
zengsiyu 已提交
2282 2283

```javascript
2284 2285
function isDistributedEnabledCallback() {
    console.log('----------- isDistributedEnabled ------------');
Z
zengsiyu 已提交
2286 2287
};

2288
Notification.enableDistributed(isDistributedEnabledCallback);
Z
zengsiyu 已提交
2289 2290 2291 2292
```



2293
## Notification.isDistributedEnabled<sup>8+</sup>
X
xuezhongzhu 已提交
2294

X
xuzhihao 已提交
2295
isDistributedEnabled(): Promise\<boolean>
Z
zengsiyu 已提交
2296

2297
获取设备是否支持分布式通知。
Z
zengsiyu 已提交
2298

2299
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2300

2301
**返回值:**
Z
zengsiyu 已提交
2302

2303 2304 2305
| 类型               | 说明            |
| ------------------ | --------------- |
| Promise\<boolean\> | Promise方式返回设备是否支持分布式通知的结果。<br/>true 支持。<br/>false 不支持。 |
Z
zengsiyu 已提交
2306

2307
**示例:**
X
xuezhongzhu 已提交
2308

2309 2310 2311 2312 2313 2314
```javascript
Notification.isDistributedEnabled()
    .then((data) => {
        console.log('-------- isDistributedEnabled ----------');
    });
```
Z
zengsiyu 已提交
2315 2316


2317
## Notification.enableDistributedByBundle<sup>8+</sup>
Z
zengsiyu 已提交
2318

X
xuzhihao 已提交
2319
enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
Z
zengsiyu 已提交
2320

2321
根据应用的包设置应用程序是否支持分布式通知。
X
xuezhongzhu 已提交
2322

2323
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2324

2325
**参数:**
Z
zengsiyu 已提交
2326

2327 2328
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
2329
| bundle   | [BundleOption](#bundleoption)             | 是   | 应用的包。                     |
2330 2331
| enable   | boolean                  | 是   | 是否支持。                       |
| callback | AsyncCallback\<void\> | 是   | 应用程序是否支持分布式通知的回调函数。 |
Z
zengsiyu 已提交
2332

2333
**示例:**
Z
zengsiyu 已提交
2334

2335 2336 2337 2338
```javascript
function enableDistributedByBundleCallback() {
    console.log('----------- enableDistributedByBundle ------------');
};
Z
zengsiyu 已提交
2339

2340 2341 2342
var bundle = {
    bundle: "bundleName1",
}
X
xuezhongzhu 已提交
2343

2344
var enable = true
Z
zengsiyu 已提交
2345

2346 2347
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
Z
zengsiyu 已提交
2348 2349 2350



2351
## Notification.enableDistributedByBundle<sup>8+</sup>
X
xuezhongzhu 已提交
2352

2353
根据bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise<void>
Z
zengsiyu 已提交
2354

2355
根据应用的包设置应用程序是否支持分布式通知。
Z
zengsiyu 已提交
2356

2357
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2358

2359
**参数:**
Z
zengsiyu 已提交
2360

2361 2362
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
2363
| bundle   | [BundleOption](#bundleoption)             | 是   | 应用的包。                |
2364
| enable   | boolean                  | 是   | 是否支持。                  |
X
xuezhongzhu 已提交
2365

2366
**示例:**
Z
zengsiyu 已提交
2367

2368 2369 2370 2371
```javascript
var bundle = {
    bundle: "bundleName1",
}
Z
zengsiyu 已提交
2372

2373
var enable = true
X
xuezhongzhu 已提交
2374

2375 2376 2377 2378 2379
Notification.enableDistributedByBundle(bundle, enable)
    .then(() => {
        console.log('-------- enableDistributedByBundle ----------');
    });
```
Z
zengsiyu 已提交
2380

2381
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
Z
zengsiyu 已提交
2382

X
xuzhihao 已提交
2383
isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
Z
zengsiyu 已提交
2384

2385
根据应用的包获取应用程序是否支持分布式通知。
Z
zengsiyu 已提交
2386

2387
**系统能力**:SystemCapability.Notification.Notification
X
xuezhongzhu 已提交
2388

2389
**参数:**
Z
zengsiyu 已提交
2390

2391 2392
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
2393
| bundle   | [BundleOption](#bundleoption)             | 是   | 应用的包。                     |
2394
| callback | AsyncCallback\<boolean\> | 是   | 应用程序是否支持分布式通知的回调函数。 |
Z
zengsiyu 已提交
2395

2396
**示例:**
Z
zengsiyu 已提交
2397

2398 2399 2400 2401
```javascript
function isDistributedEnabledByBundleCallback(data) {
    console.log('----------- isDistributedEnabledByBundle ------------', data);
};
Z
zengsiyu 已提交
2402

2403 2404 2405
var bundle = {
    bundle: "bundleName1",
}
X
xuezhongzhu 已提交
2406

2407 2408
Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallback);
```
Z
zengsiyu 已提交
2409 2410 2411



2412
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
Z
zengsiyu 已提交
2413

X
xuzhihao 已提交
2414
isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
X
xuezhongzhu 已提交
2415

2416
根据应用的包获取应用程序是否支持分布式通知。
Z
zengsiyu 已提交
2417

2418
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2419

2420
**参数:**
Z
zengsiyu 已提交
2421

2422 2423
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
2424
| bundle   | [BundleOption](#bundleoption)             | 是   | 应用的包。                |
Z
zengsiyu 已提交
2425

2426
**返回值:**
X
xuezhongzhu 已提交
2427

2428 2429 2430
| 类型               | 说明            |
| ------------------ | --------------- |
| Promise\<boolean\> | Promise方式返回应用程序是否支持分布式通知的结果。<br/>true 支持。<br/>false 不支持。 |
Z
zengsiyu 已提交
2431

2432
**示例:**
Z
zengsiyu 已提交
2433

2434 2435 2436 2437
```javascript
var bundle = {
    bundle: "bundleName1",
}
Z
zengsiyu 已提交
2438

2439 2440 2441 2442 2443
Notification.isDistributedEnabledByBundle(bundle)
    .then((data) => {
        console.log('-------- isDistributedEnabledByBundle ----------', data);
    });
```
Z
zengsiyu 已提交
2444

X
xuezhongzhu 已提交
2445

2446
## Notification.getDeviceRemindType<sup>8+</sup>
Z
zengsiyu 已提交
2447

X
xuzhihao 已提交
2448
getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
Z
zengsiyu 已提交
2449

2450
获取通知的提醒方式。
Z
zengsiyu 已提交
2451

2452
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2453

2454
**参数:**
X
xuezhongzhu 已提交
2455

2456 2457
| 参数名   | 类型                               | 必填 | 说明                       |
| -------- | --------------------------------- | ---- | -------------------------- |
2458
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtypesup8sup)\> | 是   | 获取通知的提醒方式的回调函数。 |
Z
zengsiyu 已提交
2459

2460
**示例:**
Z
zengsiyu 已提交
2461

2462 2463 2464 2465
```javascript
function getDeviceRemindTypeCallback(data) {
    console.log('----------- getDeviceRemindType ------------', data);
};
Z
zengsiyu 已提交
2466

2467 2468
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
Z
zengsiyu 已提交
2469

X
xuezhongzhu 已提交
2470

Z
zengsiyu 已提交
2471

2472
## Notification.getDeviceRemindType<sup>8+</sup>
Z
zengsiyu 已提交
2473

X
xuzhihao 已提交
2474
getDeviceRemindType(): Promise\<DeviceRemindType\>
Z
zengsiyu 已提交
2475

2476
获取通知的提醒方式。
Z
zengsiyu 已提交
2477

2478
**系统能力**:SystemCapability.Notification.Notification
X
xuezhongzhu 已提交
2479

2480
**返回值:**
Z
zengsiyu 已提交
2481

2482 2483
| 类型               | 说明            |
| ------------------ | --------------- |
2484
| Promise\<[DeviceRemindType](#deviceremindtypesup8sup)\> | Promise方式返回通知的提醒方式的结果。 |
Z
zengsiyu 已提交
2485

2486
**示例:**
Z
zengsiyu 已提交
2487

2488 2489 2490 2491 2492 2493
```javascript
Notification.getDeviceRemindType()
    .then((data) => {
        console.log('-------- getDeviceRemindType ----------', data);
    });
```
Z
zengsiyu 已提交
2494

2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808
## NotificationSubscriber

### onConsume

onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata))

接收通知回调函数。

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | 是 | 回调返回接收到的通知信息。 |

**示例:**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onConsumeCallback(data) {
    console.info('===> onConsume in test');
    let req = data.request;
    console.info('===> onConsume callback req.id:' + req.id);
    let wantAgent = data.wantAgent;
    wantAgent .getWant(wantAgent)
        .then((data1) => {
            console.log('===> getWant success want:' + JSON.stringfy(data1));
        })
        .catch((err) => {
            console.error('===> getWant failed because' + JSON.stringfy(err));
        });
    console.info('===> onConsume callback req.wantAgent:' + JSON.stringfy(req.wantAgent));
};

var subscriber = {
    onConsume: onConsumeCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```

### onCancel

onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata))

删除通知回调函数。

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | 是 | 回调返回接收到的通知信息。 |

**示例:**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onCancelCallback(data) {
    console.info('===> onCancel in test');
    let req = data.request;
    console.info('===> onCancel callback req.id:' + req.id);
}

var subscriber = {
    onCancel: onCancelCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```

### onUpdate

onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap))

更新通知排序回调函数。

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 回调返回接收到的通知信息。 |

**示例:**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onUpdateCallback() {
    console.info('===> onUpdate in test');
}

var subscriber = {
    onUpdate: onUpdateCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```

### onConnect

onConnect?:void

注册订阅回调函数。

**系统能力**:SystemCapability.Notification.Notification

**示例:**

```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');
}

var subscriber = {
    onConnect: onConnectCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```

### onDisconnect

onDisconnect?:void

取消订阅回调函数。

**系统能力**:SystemCapability.Notification.Notification

**示例:**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onDisconnectCallback() {
    console.info('===> onDisconnect in test');
}

var subscriber = {
    onDisconnect: onDisconnectCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```

### onDestroy

onDestroy?:void

服务失联回调函数。

**系统能力**:SystemCapability.Notification.Notification

**示例:**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onDestroyCallback() {
    console.info('===> onDestroy in test');
}

var subscriber = {
    onDestroy: onDestroyCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```

### onDoNotDisturbDateChange<sup>8+</sup>

onDoNotDisturbDateChange?:(mode: Notification.[DoNotDisturbDate](#donotdisturbdate8))

免打扰时间选项变更回调函数。

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | Notification.[DoNotDisturbDate](#donotdisturbdate8) | 是 | 回调返回免打扰时间选项变更。 |

**示例:**
```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onDoNotDisturbDateChangeCallback() {
    console.info('===> onDoNotDisturbDateChange in test');
}

var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```


### onEnabledNotificationChanged<sup>8+</sup>

onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdatasup8sup))

监听应用通知使能变化。

**系统能力**:SystemCapability.Notification.Notification

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdatasup8sup)\> | 是 | 回调返回监听到的应用信息。 |

**示例:**

```javascript
function subscribeCallback(err) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("subscribeCallback");
    }
};

function onEnabledNotificationChangedCallback(err, callbackData) {
    if (err.code) {
        console.info("subscribe failed " + JSON.stringify(err));
    } else {
        console.info("bundle: ", callbackData.bundle);
        console.info("uid: ", callbackData.uid);
        console.info("enable: ", callbackData.enable);
    }
};

var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};

Notification.subscribe(subscriber, subscribeCallback);
```

## SubscribeCallbackData

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称            | 可读 | 可写 | 类型                                              | 必填 | 描述     |
| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- |
| request         | 是  | 否  | [NotificationRequest](#notificationrequest)       | 是   | 通知内容。 |
| sortingMap      | 是  | 否  | [NotificationSortingMap](#notificationsortingmap) | 否   | 排序信息。 |
| reason          | 是  | 否  | number                                            | 否   | 删除原因。 |
| sound           | 是  | 否  | string                                            | 否   | 通知声音。 |
| vibrationValues | 是  | 否  | Array\<number\>                                   | 否   | 通知震动。 |


## EnabledNotificationCallbackData<sup>8+</sup>

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称   | 可读 | 可写 | 类型    | 必填 | 描述             |
| ------ | ---- | --- | ------- | ---- | ---------------- |
| bundle | 是  | 否  | string  | 是   | 应用的包名。       |
| uid    | 是  | 否  | number  | 是   | 应用的uid。        |
| enable | 是  | 否  | boolean | 是   | 应用通知使能状态。 |

X
xuezhongzhu 已提交
2809

X
xuzhihao 已提交
2810
## DoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
2811

2812
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2813

2814 2815
| 名称  | 可读 | 可写 | 类型                                  | 描述                     |
| ----- | ---- | --- | ------------------------------------- | ------------------------ |
2816
| type  | 是  | 否  | [DoNotDisturbType](#donotdisturbtype8) | 指定免打扰设置的时间类型。 |
2817 2818
| begin | 是  | 否  | Date                                  | 指定免打扰设置的起点时间。 |
| end   | 是  | 否  | Date                                  | 指定免打扰设置的终点时间。 |
Z
zhaoyuan17 已提交
2819 2820 2821



2822
## DoNotDisturbType<sup>8+</sup>
Z
zhaoyuan17 已提交
2823

2824
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2825 2826


2827 2828 2829 2830 2831 2832
| 名称         | 值               | 说明                                       |
| ------------ | ---------------- | ------------------------------------------ |
| TYPE_NONE    | DoNotDisturbType | 非通知勿扰类型。                           |
| TYPE_ONCE    | DoNotDisturbType | 以设置时间段(只看小时和分钟)一次执行勿扰。 |
| TYPE_DAILY   | DoNotDisturbType | 以设置时间段(只看小时和分钟)每天执行勿扰。 |
| TYPE_CLEARLY | DoNotDisturbType | 以设置时间段(明确年月日时分)执行勿扰。     |
Z
zhaoyuan17 已提交
2833 2834


2835
## ContentType
Z
zhaoyuan17 已提交
2836

2837
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2838

2839 2840 2841 2842 2843 2844 2845
| 名称                              | 值          | 说明               |
| --------------------------------- | ----------- | ------------------ |
| NOTIFICATION_CONTENT_BASIC_TEXT   | ContentType | 普通类型通知。     |
| NOTIFICATION_CONTENT_LONG_TEXT    | ContentType | 长文本类型通知。   |
| NOTIFICATION_CONTENT_PICTURE      | ContentType | 图片类型通知。     |
| NOTIFICATION_CONTENT_CONVERSATION | ContentType | 社交类型通知。     |
| NOTIFICATION_CONTENT_MULTILINE    | ContentType | 多行文本类型通知。 |
Z
zhaoyuan17 已提交
2846

X
xuzhihao 已提交
2847
## SlotLevel
Z
zhaoyuan17 已提交
2848

2849
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2850

X
xuzhihao 已提交
2851 2852 2853 2854 2855 2856 2857
| 名称                              | 值          | 说明               |
| --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE                        | 0           | 表示关闭通知功能。     |
| LEVEL_MIN                         | 1           | 启用通知功能,但通知不启用。   |
| LEVEL_LOW                         | 2           | 通知和通止功能都启用。     |
| LEVEL_DEFAULT                     | 3           | 通知和通止功能都启用。     |
| LEVEL_HIGH                        | 4           | 通知和通止功能都启用。     |
Z
zhaoyuan17 已提交
2858 2859


2860
## BundleOption
Z
zhaoyuan17 已提交
2861

2862
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2863

2864 2865 2866 2867
| 名称   | 可读 | 可写 | 类型   | 必填 | 描述   |
| ------ | ---- | --- | ------ | ---- | ------ |
| bundle | 是  | 是  | string | 是   | 包名。   |
| uid    | 是  | 是  | number | 否   | 用户id。 |
Z
zhaoyuan17 已提交
2868 2869 2870



2871
## NotificationKey
Z
zhaoyuan17 已提交
2872

2873
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2874

2875 2876 2877
| 名称  | 可读 | 可写 | 类型   | 必填 | 描述     |
| ----- | ---- | --- | ------ | ---- | -------- |
| id    | 是  | 是  | number | 是   | 通知ID。   |
2878
| label | 是  | 是  | string | 否   | 通知标签。 |
Z
zhaoyuan17 已提交
2879 2880


2881
## SlotType
Z
zhaoyuan17 已提交
2882

2883
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
Z
zhaoyuan17 已提交
2884

2885 2886 2887 2888 2889 2890
| 名称                 | 值       | 说明       |
| -------------------- | -------- | ---------- |
| UNKNOWN_TYPE         | SlotType | 未知类型。 |
| SOCIAL_COMMUNICATION | SlotType | 社交类型。 |
| SERVICE_INFORMATION  | SlotType | 服务类型。 |
| CONTENT_INFORMATION  | SlotType | 内容类型。 |
2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128
| OTHER_TYPES          | SlotType | 其他类型。 |


## NotificationActionButton

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称      | 可读 | 可写 | 类型                                            | 必填 | 描述                      |
| --------- | --- | ---- | ----------------------------------------------- | ---- | ------------------------- |
| title     | 是  | 是  | string                                          | 是   | 按钮标题。                  |
| wantAgent | 是  | 是  | WantAgent                                       | 是   | 点击按钮时触发的WantAgent。 |
| extras    | 是  | 是  | { [key: string]: any }                          | 否   | 按钮扩展信息。              |
| userInput<sup>9+</sup> | 是  | 是  | [NotificationUserInput](#notificationuserinputsup8sup) | 否   | 用户输入对象实例。          |


## NotificationBasicContent

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称           | 可读 | 可写 | 类型   | 必填 | 描述                               |
| -------------- | ---- | ---- | ------ | ---- | ---------------------------------- |
| title          | 是   | 是   | string | 是   | 通知标题。                         |
| text           | 是   | 是   | string | 是   | 通知内容。                         |
| additionalText | 是   | 是   | string | 否   | 通知次要内容,是对通知内容的补充。 |


## NotificationLongTextContent

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称           | 可读 | 可写 | 类型   | 必填 | 描述                             |
| -------------- | ---- | --- | ------ | ---- | -------------------------------- |
| title          | 是  | 是  | string | 是   | 通知标题。                         |
| text           | 是  | 是  | string | 是   | 通知内容。                         |
| additionalText | 是  | 是  | string | 否   | 通知次要内容,是对通知内容的补充。 |
| longText       | 是  | 是  | string | 是   | 通知的长文本。                     |
| briefText      | 是  | 是  | string | 是   | 通知概要内容,是对通知内容的总结。 |
| expandedTitle  | 是  | 是  | string | 是   | 通知展开时的标题。                 |


## NotificationMultiLineContent

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称           | 可读 | 可写 | 类型            | 必填 | 描述                             |
| -------------- | --- | --- | --------------- | ---- | -------------------------------- |
| title          | 是  | 是  | string          | 是   | 通知标题。                         |
| text           | 是  | 是  | string          | 是   | 通知内容。                         |
| additionalText | 是  | 是  | string          | 否   | 通知次要内容,是对通知内容的补充。 |
| briefText      | 是  | 是  | string          | 是   | 通知概要内容,是对通知内容的总结。 |
| longTitle      | 是  | 是  | string          | 是   | 通知展开时的标题。                 |
| lines          | 是  | 是  | Array\<string\> | 是   | 通知的多行文本。                   |


## NotificationPictureContent

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称           | 可读 | 可写 | 类型           | 必填 | 描述                             |
| -------------- | ---- | --- | -------------- | ---- | -------------------------------- |
| title          | 是  | 是  | string         | 是   | 通知标题。                         |
| text           | 是  | 是  | string         | 是   | 通知内容。                         |
| additionalText | 是  | 是  | string         | 否   | 通知次要内容,是对通知内容的补充。 |
| briefText      | 是  | 是  | string         | 是   | 通知概要内容,是对通知内容的总结。 |
| expandedTitle  | 是  | 是  | string         | 是   | 通知展开时的标题。                 |
| picture        | 是  | 是  | image.PixelMap | 是   | 通知的图片内容。                   |


## NotificationContent

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称        | 可读 | 可写 | 类型                                                         | 必填 | 描述               |
| ----------- | ---- | --- | ------------------------------------------------------------ | ---- | ------------------ |
| contentType | 是  | 是  | [ContentType](#contenttype)                                  | 是   | 通知内容类型。       |
| normal      | 是  | 是  | [NotificationBasicContent](#notificationbasiccontent)        | 否   | 基本类型通知内容。   |
| longText    | 是  | 是  | [NotificationLongTextContent](#notificationlongtextcontent)  | 否   | 长文本类型通知内容。 |
| multiLine   | 是  | 是  | [NotificationMultiLineContent](#notificationmultilinecontent) | 否   | 多行类型通知内容。   |
| picture     | 是  | 是  | [NotificationPictureContent](#notificationpicturecontent)    | 否   | 图片类型通知内容。   |


## NotificationFlagStatus<sup>8+</sup>

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称           | 值  | 描述                               |
| -------------- | --- | --------------------------------- |
| TYPE_NONE      | 0   | 默认标志。                         |
| TYPE_OPEN      | 1   | 通知标志打开。                     |
| TYPE_CLOSE     | 2   | 通知标志关闭。                     |


## NotificationFlags<sup>8+</sup>

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称             | 可读 | 可写 | 类型                    | 必填 | 描述                               |
| ---------------- | ---- | ---- | ---------------------- | ---- | --------------------------------- |
| soundEnabled     | 是   | 否   | NotificationFlagStatus | 否   | 是否启用声音提示。                  |
| vibrationEnabled | 是   | 否   | NotificationFlagStatus | 否   | 是否启用振动提醒功能。               |


## NotificationRequest

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称                  | 可读 | 可写 | 类型                                          | 必填 | 描述                       |
| --------------------- | ---- | --- | --------------------------------------------- | ---- | -------------------------- |
| content               | 是  | 是  | [NotificationContent](#notificationcontent)   | 是   | 通知内容。                   |
| id                    | 是  | 是  | number                                        | 否   | 通知ID。                     |
| slotType              | 是  | 是  | [SlotType](#slottype)                                      | 否   | 通道类型。                   |
| isOngoing             | 是  | 是  | boolean                                       | 否   | 是否进行时通知。             |
| isUnremovable         | 是  | 是  | boolean                                       | 否   | 是否可移除。                 |
| deliveryTime          | 是  | 是  | number                                        | 否   | 通知发送时间。               |
| tapDismissed          | 是  | 是  | boolean                                       | 否   | 通知是否自动清除。           |
| autoDeletedTime       | 是  | 是  | number                                        | 否   | 自动清除的时间。             |
| wantAgent             | 是  | 是  | WantAgent                                     | 否   | 点击跳转的WantAgent。        |
| extraInfo             | 是  | 是  | {[key: string]: any}                          | 否   | 扩展参数。                   |
| color                 | 是  | 是  | number                                        | 否   | 通知背景颜色。               |
| colorEnabled          | 是  | 是  | boolean                                       | 否   | 通知背景颜色是否使能。       |
| isAlertOnce           | 是  | 是  | boolean                                       | 否   | 设置是否仅有一次此通知警报。 |
| isStopwatch           | 是  | 是  | boolean                                       | 否   | 是否显示已用时间。           |
| isCountDown           | 是  | 是  | boolean                                       | 否   | 是否显示倒计时时间。         |
| isFloatingIcon        | 是  | 是  | boolean                                       | 否   | 是否显示状态栏图标。         |
| label                 | 是  | 是  | string                                        | 否   | 通知标签。                   |
| badgeIconStyle        | 是  | 是  | number                                        | 否   | 通知角标类型。               |
| showDeliveryTime      | 是  | 是  | boolean                                       | 否   | 是否显示分发时间。           |
| actionButtons         | 是  | 是  | Array\<[NotificationActionButton](#notificationactionbutton)\>             | 否   | 通知按钮,最多两个按钮。     |
| smallIcon             | 是  | 是  | PixelMap                                      | 否   | 通知小图标。                 |
| largeIcon             | 是  | 是  | PixelMap                                      | 否   | 通知大图标。                 |
| creatorBundleName     | 是  | 否  | string                                        | 否   | 创建通知的包名。             |
| creatorUid            | 是  | 否  | number                                        | 否   | 创建通知的UID。              |
| creatorPid            | 是  | 否  | number                                        | 否   | 创建通知的PID。              |
| creatorUserId<sup>8+</sup>| 是  | 否  | number                                    | 否   | 创建通知的UserId。           |
| hashCode              | 是  | 否  | string                                        | 否   | 通知唯一标识。               |
| classification        | 是  | 是  | string                                        | 否   | 通知分类。                   |
| groupName<sup>8+</sup>| 是  | 是  | string                                        | 否   | 组通知名称。                 |
| template<sup>8+</sup> | 是  | 是  | [NotificationTemplate](#notificationtemplatesup8sup) | 否   | 通知模板。                   |
| isRemoveAllowed<sup>8+</sup> | 是  | 否  | boolean                                | 否   | 通知是否能被移除。                   |
| source<sup>8+</sup>   | 是  | 否  | number                                        | 否   | 通知源。                   |
| distributedOption<sup>8+</sup>   | 是  | 是  | [DistributedOptions](#distributedoptionssup8sup)                 | 否   | 分布式通知的选项。          |
| deviceId<sup>8+</sup> | 是  | 否  | string                                        | 否   | 通知源的deviceId。          |
| notificationFlags<sup>8+</sup> | 是  | 否  | [NotificationFlags](#notificationflagssup8sup)                    | 否   | 获取NotificationFlags。          |


## DistributedOptions<sup>8+</sup>

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称                   | 可读 | 可写 | 类型            | 必填 | 描述                               |
| ---------------------- | ---- | ---- | -------------- | ---- | ---------------------------------- |
| isDistributed          | 是   | 是   | boolean        | 否   | 是否为分布式通知。                  |
| supportDisplayDevices  | 是   | 是   | Array\<string> | 是   | 可以同步通知到的设备类型。           |
| supportOperateDevices  | 是   | 是   | Array\<string> | 否   | 可以打开通知的设备。                |
| remindType             | 是   | 否   | number         | 否   | 通知的提醒方式。                    |


## NotificationSlot

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称                 | 可读 | 可写 | 类型                  | 必填 | 描述                                       |
| -------------------- | ---- | --- | --------------------- | ---- | ------------------------------------------ |
| type                 | 是  | 是  | [SlotType](#slottype) | 是   | 通道类型。                                   |
| level                | 是  | 是  | number                | 否   | 通知级别,不设置则根据通知渠道类型有默认值。 |
| desc                 | 是  | 是  | string                | 否   | 通知渠道描述信息。                           |
| badgeFlag            | 是  | 是  | boolean               | 否   | 是否显示角标。                               |
| bypassDnd            | 是  | 是  | boolean               | 否   | 置是否在系统中绕过免打扰模式。               |
| lockscreenVisibility | 是  | 是  | boolean               | 否   | 在锁定屏幕上显示通知的模式。                 |
| vibrationEnabled     | 是  | 是  | boolean               | 否   | 是否可振动。                                 |
| sound                | 是  | 是  | string                | 否   | 通知提示音。                                 |
| lightEnabled         | 是  | 是  | boolean               | 否   | 是否闪灯。                                   |
| lightColor           | 是  | 是  | number                | 否   | 通知灯颜色。                                 |
| vibrationValues      | 是  | 是  | Array\<number\>       | 否   | 通知振动样式。                               |


## NotificationSorting

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称     | 可读 | 可写 | 类型                                  | 必填 | 描述         |
| -------- | ---- | --- | ------------------------------------- | ---- | ------------ |
| slot     | 是  | 否  | [NotificationSlot](#notificationslot) | 是   | 通知通道内容。 |
| hashCode | 是  | 否  | string                                | 是   | 通知唯一标识。 |
| ranking  | 是  | 否  | number                                | 是   | 通知排序序号。 |


## NotificationSortingMap

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称           | 可读 | 可写 | 类型                                                         | 必填 | 描述             |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- |
| sortings       | 是  | 否  | {[key: string]: [NotificationSorting](#notificationsorting)} | 是   | 通知排序信息数组。 |
| sortedHashCode | 是  | 否  | Array\<string\>                                              | 是   | 通知唯一标识数组。 |


## NotificationSubscribeInfo

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称        | 可读 | 可写 | 类型            | 必填 | 描述                            |
| ----------- | --- | ---- | --------------- | ---- | ------------------------------- |
| bundleNames | 是  | 是  | Array\<string\> | 否   | 指定订阅哪些包名的APP发来的通知。 |
| userId      | 是  | 是  | number          | 否   | 指定订阅哪个用户下发来的通知。    |


## NotificationTemplate<sup>8+</sup>

模板信息

**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification

| 名称 | 参数类型               | 可读 | 可写 | 说明       |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | 是   | 是   | 模板名称。 |
| data | {[key:string]: Object} | 是   | 是   | 模板数据。 |


## NotificationUserInput<sup>8+</sup>

**系统能力**:SystemCapability.Notification.Notification

| 名称     | 可读 | 可写 | 类型   | 必填 | 描述                          |
| -------- | --- | ---- | ------ | ---- | ----------------------------- |
| inputKey | 是  | 是  | string | 是   | 用户输入时用于标识此输入的key。 |


## DeviceRemindType<sup>8+</sup>

**系统能力**:SystemCapability.Notification.Notification

| 名称                 | 值  | 描述                               |
| -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND    | 0   | 设备未被使用,无需提醒。            |
| IDLE_REMIND          | 1   | 提醒设备未被使用。                 |
| ACTIVE_DONOT_REMIND  | 2   | 设备正在使用,无需提醒。            |
| ACTIVE_REMIND        | 3   | 提醒设备正在使用。                 |