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

3 4 5 6
>**说明:**
>
>本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

```

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

X
xuzhihao 已提交
83
publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
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 122

发布通知(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 已提交
123
publish(request: NotificationRequest, userId: number): Promise\<void\>
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 156

发布通知(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 已提交
157 158


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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
243
取消所有已发布的通知(callback形式)。
Z
zhaoyuan17 已提交
244

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

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

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

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

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



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

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

X
xuzhihao 已提交
269
取消所有已发布的通知(Promise形式)。
Z
zhaoyuan17 已提交
270

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

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

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



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

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

X
xuzhihao 已提交
287
创建通知通道(callback形式)。
Z
zhaoyuan17 已提交
288

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

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

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

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

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



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

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

X
xuzhihao 已提交
318
创建通知通道(Promise形式)。
Z
zhaoyuan17 已提交
319

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

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

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

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

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



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

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

X
xuzhihao 已提交
346
创建通知通道(callback形式)。
Z
zhaoyuan17 已提交
347

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

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

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

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

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



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

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

X
xuzhihao 已提交
373
创建通知通道(Promise形式)。
Z
zhaoyuan17 已提交
374

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

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

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

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

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



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

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

X
xuzhihao 已提交
397
创建多个通知通道(callback形式)。
Z
zhaoyuan17 已提交
398

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

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

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

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

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

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



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

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

X
xuzhihao 已提交
432
创建多个通知通道(Promise形式)。
Z
zhaoyuan17 已提交
433

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
464
获取一个通知通道(callback形式)。
Z
zhaoyuan17 已提交
465

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

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

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

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

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



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

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

X
xuzhihao 已提交
492
获取一个通知通道(Promise形式)。
Z
zhaoyuan17 已提交
493

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
626
删除所有通知通道(callback形式)。
Z
zhaoyuan17 已提交
627

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

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

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

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

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



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

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

X
xuzhihao 已提交
651
删除所有通知通道(Promise形式)。
Z
zhaoyuan17 已提交
652

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

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

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



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

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

X
xuzhihao 已提交
669
订阅通知并指定订阅信息(callback形式)。
Z
zhaoyuan17 已提交
670

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

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

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

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

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



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

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

X
xuzhihao 已提交
706
订阅通知并指定订阅信息(callback形式)。
Z
zhaoyuan17 已提交
707

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

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

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

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

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



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

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

X
xuzhihao 已提交
738
订阅通知并指定订阅信息(Promise形式)。
Z
zhaoyuan17 已提交
739

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

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

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

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

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



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

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

X
xuzhihao 已提交
769
取消订阅(callbcak形式)。
Z
zhaoyuan17 已提交
770

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

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

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

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

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



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

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

X
xuzhihao 已提交
801
取消订阅(Promise形式)。
Z
zhaoyuan17 已提交
802

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

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

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

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

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



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

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

X
xuzhihao 已提交
831
设定指定包的通知使能状态(Callback形式)。
Z
zhaoyuan17 已提交
832

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

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

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

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

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



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

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

X
xuzhihao 已提交
861
设定指定包的通知使能状态(Promise形式)。
Z
zhaoyuan17 已提交
862

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
951
获取通知使能状态(Callback形式)。
Z
zhaoyuan17 已提交
952

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

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

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

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

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



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

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

X
xuzhihao 已提交
977
获取通知使能状态(Promise形式)。
Z
zhaoyuan17 已提交
978

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1007
设定指定包的角标使能状态(Callback形式)。
Z
zhaoyuan17 已提交
1008

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

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

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

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

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



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

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

X
xuzhihao 已提交
1037
设定指定包的角标使能状态(Promise形式)。
Z
zhaoyuan17 已提交
1038

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1127
设定指定包的通知通道状态(Callback形式)。
Z
zhaoyuan17 已提交
1128

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

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

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

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

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



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

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

X
xuzhihao 已提交
1160
设定指定包的角标使能状态(Promise形式)。
Z
zhaoyuan17 已提交
1161

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

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

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

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

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



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

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

X
xuzhihao 已提交
1191
获取指定包的通知通道(Callback形式)。
Z
zhaoyuan17 已提交
1192

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

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

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

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

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



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

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

X
xuzhihao 已提交
1220
获取指定包的通知通道(Promise形式)。
Z
zhaoyuan17 已提交
1221

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1253
获取指定包的通知通道数(Callback形式)。
Z
zhaoyuan17 已提交
1254

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

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

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

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

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



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

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

X
xuzhihao 已提交
1282
获取指定包的通知通道数(Promise形式)。
Z
zhaoyuan17 已提交
1283

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1315
删除指定通知(Callback形式)。
Z
zhaoyuan17 已提交
1316

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

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

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

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

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



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

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

X
xuzhihao 已提交
1349
删除指定通知(Promise形式)。
Z
zhaoyuan17 已提交
1350

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

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

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

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

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



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

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

X
xuzhihao 已提交
1381
删除指定通知(Callback形式)。
Z
zhaoyuan17 已提交
1382

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1408
删除指定通知(Promise形式)。
Z
zhaoyuan17 已提交
1409

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

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

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

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

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



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

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

X
xuzhihao 已提交
1432
删除指定包的所有通知(Callback形式)。
Z
zhaoyuan17 已提交
1433

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

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

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

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

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



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

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

X
xuzhihao 已提交
1461
删除所有通知(Callback形式)。
Z
zhaoyuan17 已提交
1462

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

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

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

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

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

Notification.removeAll(removeAllCallback);
```



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

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

X
xuzhihao 已提交
1487
删除所有通知(Promise形式)。
Z
zhaoyuan17 已提交
1488

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

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

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

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

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

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

X
xuzhihao 已提交
1507
removeAll(userId: number, callback: AsyncCallback\<void>): void
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533

删除所有通知(callback形式)。

**系统能力**: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 已提交
1534
removeAll(userId: number): Promise\<void>
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556

删除所有通知(Promise形式)。

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

**参数:**

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

**示例:**

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

var userId = 1

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


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

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

X
xuzhihao 已提交
1563
获取活动通知(Callback形式)。
Z
zhaoyuan17 已提交
1564

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

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

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

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

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

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



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

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

X
xuzhihao 已提交
1589
获取活动通知(Promise形式)。
Z
zhaoyuan17 已提交
1590

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

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

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

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

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



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

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

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

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

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

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

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

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

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



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

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1663
获取当前应用的活动通知(Callback形式)。
Z
zhaoyuan17 已提交
1664

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

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

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

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

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

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



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

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

X
xuzhihao 已提交
1689
获取当前应用的活动通知(Promise形式)。
Z
zhaoyuan17 已提交
1690

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

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

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

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

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



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

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

X
xuzhihao 已提交
1713
取消本应用指定组通知(Callback形式)。
Z
zhaoyuan17 已提交
1714

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

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

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

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

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

var groupName = "GroupName";

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



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

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

X
xuzhihao 已提交
1742
取消本应用指定组通知(Promise形式)。
Z
zhaoyuan17 已提交
1743

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

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

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

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

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



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

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

X
xuzhihao 已提交
1767
删除指定应用指定组通知(Callback形式)。
Z
zhaoyuan17 已提交
1768

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1798
删除指定应用指定组通知(Promise形式)。
Z
zhaoyuan17 已提交
1799

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

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

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

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

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



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

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

X
xuzhihao 已提交
1825
设置免打扰时间(Callback形式)。
Z
zhaoyuan17 已提交
1826

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

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

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

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

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

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

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



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

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

X
xuzhihao 已提交
1858
设置免打扰时间接口(Promise形式)。
Z
zhaoyuan17 已提交
1859

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

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

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

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

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


1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 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 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948
## Notification.setDoNotDisturbDate<sup>8+</sup>

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

指定用户设置免打扰时间(Callback形式)。

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

**参数:**

| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                   |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
| date     | 是   | 否  | DoNotDisturbDate      | 是   | 免打扰时间选项。         |
| 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\>

指定用户设置免打扰时间接口(Promise形式)。

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

**参数:**

| 名称   | 可读 | 可写 | 类型             | 必填 | 描述           |
| ------ | ---- | --- | ---------------- | ---- | -------------- |
| date   | 是   | 否  | DoNotDisturbDate | 是   | 免打扰时间选项。 |
| 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 已提交
1949

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

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

X
xuzhihao 已提交
1954
查询免打扰时间接口(Callback形式)。
Z
zhaoyuan17 已提交
1955

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

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

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

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

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

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



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

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

X
xuzhihao 已提交
1980
查询免打扰时间接口(Promise形式)。
Z
zhaoyuan17 已提交
1981

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

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

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

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

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


1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057
## Notification.getDoNotDisturbDate<sup>8+</sup>

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

指定用户查询免打扰时间接口(Callback形式)。

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

**参数:**

| 名称     | 可读 | 可写 | 类型                              | 必填 | 描述                   |
| -------- | ---- | --- | --------------------------------- | ---- | ---------------------- |
| callback | 是   | 否  | AsyncCallback\<DoNotDisturbDate\> | 是   | 查询免打扰时间回调函数。 |
| 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\>

指定用户查询免打扰时间接口(Promise形式)。

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

**参数:**

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

**返回值:**

| 类型                                                        | 说明                                                         |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<DoNotDisturbDate\> | 以Promise形式返回获取查询免打扰时间接口。 |

**示例:**

```js
var userId = 1

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

Z
zhaoyuan17 已提交
2058

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

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

X
xuzhihao 已提交
2063
查询是否支持勿扰模式功能(Callback形式)。
Z
zhaoyuan17 已提交
2064

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

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

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

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

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

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



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

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

X
xuzhihao 已提交
2089
查询是否支持勿扰模式功能(Promise形式)。
Z
zhaoyuan17 已提交
2090

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

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

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

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

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



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

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

查询模板是否存在。

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

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

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

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

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

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



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

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

查询模板是否存在。

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

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

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

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

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

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

```javascript
var templateName = 'process';

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



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

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

应用请求通知使能。

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

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

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

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

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

Notification.requestEnabledNotification(requestEnabledNotificationCallback);
```



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

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

应用请求通知使能。

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

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

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


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

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

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

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

**参数:**

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

**示例:**

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

2235 2236 2237
var enable = true

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


Z
zengsiyu 已提交
2241

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

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

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

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

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

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

**示例:**

```javascript
var enable = true

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


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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

2345
var enable = true
Z
zengsiyu 已提交
2346

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



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

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

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

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

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

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

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

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

2374
var enable = true
X
xuezhongzhu 已提交
2375

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

2423 2424 2425
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle   | BundleOption             | 是   | 应用的包。                |
Z
zengsiyu 已提交
2426

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

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

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

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

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

X
xuezhongzhu 已提交
2446

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

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

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

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

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

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

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

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

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

X
xuezhongzhu 已提交
2471

Z
zengsiyu 已提交
2472

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

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

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

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

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

2483 2484 2485
| 类型               | 说明            |
| ------------------ | --------------- |
| Promise\<DeviceRemindType\> | Promise方式返回通知的提醒方式的结果。 |
Z
zengsiyu 已提交
2486

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

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

X
xuezhongzhu 已提交
2496

X
xuzhihao 已提交
2497
## DoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
2498

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

2501 2502 2503 2504 2505
| 名称  | 可读 | 可写 | 类型                                  | 描述                     |
| ----- | ---- | --- | ------------------------------------- | ------------------------ |
| type  | 是  | 否  | [DoNotDisturbType](#donotdisturbtype) | 指定免打扰设置的时间类型。 |
| begin | 是  | 否  | Date                                  | 指定免打扰设置的起点时间。 |
| end   | 是  | 否  | Date                                  | 指定免打扰设置的终点时间。 |
Z
zhaoyuan17 已提交
2506 2507 2508



2509
## DoNotDisturbType<sup>8+</sup>
Z
zhaoyuan17 已提交
2510

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


2514 2515 2516 2517 2518 2519
| 名称         | 值               | 说明                                       |
| ------------ | ---------------- | ------------------------------------------ |
| TYPE_NONE    | DoNotDisturbType | 非通知勿扰类型。                           |
| TYPE_ONCE    | DoNotDisturbType | 以设置时间段(只看小时和分钟)一次执行勿扰。 |
| TYPE_DAILY   | DoNotDisturbType | 以设置时间段(只看小时和分钟)每天执行勿扰。 |
| TYPE_CLEARLY | DoNotDisturbType | 以设置时间段(明确年月日时分)执行勿扰。     |
Z
zhaoyuan17 已提交
2520 2521


2522
## ContentType
Z
zhaoyuan17 已提交
2523

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

2526 2527 2528 2529 2530 2531 2532
| 名称                              | 值          | 说明               |
| --------------------------------- | ----------- | ------------------ |
| NOTIFICATION_CONTENT_BASIC_TEXT   | ContentType | 普通类型通知。     |
| NOTIFICATION_CONTENT_LONG_TEXT    | ContentType | 长文本类型通知。   |
| NOTIFICATION_CONTENT_PICTURE      | ContentType | 图片类型通知。     |
| NOTIFICATION_CONTENT_CONVERSATION | ContentType | 社交类型通知。     |
| NOTIFICATION_CONTENT_MULTILINE    | ContentType | 多行文本类型通知。 |
Z
zhaoyuan17 已提交
2533

X
xuzhihao 已提交
2534
## SlotLevel
Z
zhaoyuan17 已提交
2535

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

X
xuzhihao 已提交
2538 2539 2540 2541 2542 2543 2544
| 名称                              | 值          | 说明               |
| --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE                        | 0           | 表示关闭通知功能。     |
| LEVEL_MIN                         | 1           | 启用通知功能,但通知不启用。   |
| LEVEL_LOW                         | 2           | 通知和通止功能都启用。     |
| LEVEL_DEFAULT                     | 3           | 通知和通止功能都启用。     |
| LEVEL_HIGH                        | 4           | 通知和通止功能都启用。     |
Z
zhaoyuan17 已提交
2545 2546


2547
## BundleOption
Z
zhaoyuan17 已提交
2548

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

2551 2552 2553 2554
| 名称   | 可读 | 可写 | 类型   | 必填 | 描述   |
| ------ | ---- | --- | ------ | ---- | ------ |
| bundle | 是  | 是  | string | 是   | 包名。   |
| uid    | 是  | 是  | number | 否   | 用户id。 |
Z
zhaoyuan17 已提交
2555 2556 2557



2558
## NotificationKey
Z
zhaoyuan17 已提交
2559

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

2562 2563 2564
| 名称  | 可读 | 可写 | 类型   | 必填 | 描述     |
| ----- | ---- | --- | ------ | ---- | -------- |
| id    | 是  | 是  | number | 是   | 通知ID。   |
2565
| label | 是  | 是  | string | 否   | 通知标签。 |
Z
zhaoyuan17 已提交
2566 2567


2568
## SlotType
Z
zhaoyuan17 已提交
2569

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

2572 2573 2574 2575 2576 2577
| 名称                 | 值       | 说明       |
| -------------------- | -------- | ---------- |
| UNKNOWN_TYPE         | SlotType | 未知类型。 |
| SOCIAL_COMMUNICATION | SlotType | 社交类型。 |
| SERVICE_INFORMATION  | SlotType | 服务类型。 |
| CONTENT_INFORMATION  | SlotType | 内容类型。 |
X
xuzhihao 已提交
2578
| OTHER_TYPES          | SlotType | 其他类型。 |