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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

```

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

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

发布通知(callback形式)。

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

**参数:**

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

**示例:**

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

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

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

发布通知(Promise形式)。

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

**参数:**

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

**示例:**

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

var userId = 1

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


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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

Notification.addSlots(notificationSlotArray, addSlotsCallBack)
```



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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

X
xuzhihao 已提交
748
**示例:**
Z
zhaoyuan17 已提交
749 750

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

X
xuzhihao 已提交
810
**示例:**
Z
zhaoyuan17 已提交
811 812

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

Notification.isNotificationEnabled(isNotificationEnabledCallback);
```



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

F
fangjinliang 已提交
1159
设定指定包的通知通道状态(Promise形式)。
Z
zhaoyuan17 已提交
1160

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

X
xuzhihao 已提交
1263
**示例:**
Z
zhaoyuan17 已提交
1264 1265

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



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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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



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

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

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

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

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

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

X
xuzhihao 已提交
1391
**示例:**
Z
zhaoyuan17 已提交
1392 1393

```js
1394 1395
var hashCode = 'hashCode'

Z
zhaoyuan17 已提交
1396 1397 1398 1399 1400 1401 1402 1403 1404
function removeCallback(err) {
	console.info("==========================>removeCallback=======================>");
}

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



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

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

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

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

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

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

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

```js
1422 1423
var hashCode = 'hashCode'

Z
zengsiyu 已提交
1424
Notification.remove(hashCode).then(() => {
Z
zhaoyuan17 已提交
1425 1426 1427 1428 1429 1430
	console.info("==========================>removeCallback=======================>");
});
```



X
xuzhihao 已提交
1431
## Notification.removeAll
Z
zhaoyuan17 已提交
1432

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

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

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

X
xuzhihao 已提交
1439
**参数:**
Z
zhaoyuan17 已提交
1440

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

X
xuzhihao 已提交
1446
**示例:**
Z
zhaoyuan17 已提交
1447 1448 1449 1450 1451 1452

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



X
xuzhihao 已提交
1460
## Notification.removeAll
Z
zhaoyuan17 已提交
1461

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

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

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

X
xuzhihao 已提交
1468
**参数:**
Z
zhaoyuan17 已提交
1469

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

X
xuzhihao 已提交
1474
**示例:**
Z
zhaoyuan17 已提交
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485

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

Notification.removeAll(removeAllCallback);
```



X
xuzhihao 已提交
1486
## Notification.removeAll
Z
zhaoyuan17 已提交
1487

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

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

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

X
xuzhihao 已提交
1494
**参数:**
Z
zhaoyuan17 已提交
1495

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

X
xuzhihao 已提交
1500
**示例:**
Z
zhaoyuan17 已提交
1501 1502

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

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

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

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

**系统能力**: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 已提交
1537
removeAll(userId: number): Promise\<void>
1538

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

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

**参数:**

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

**示例:**

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

var userId = 1

Notification.removeAll(userId, removeAllCallback);
```
Z
zhaoyuan17 已提交
1560 1561


X
xuzhihao 已提交
1562
## Notification.getAllActiveNotifications
Z
zhaoyuan17 已提交
1563

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

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

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

X
xuzhihao 已提交
1570
**参数:**
Z
zhaoyuan17 已提交
1571

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

X
xuzhihao 已提交
1576
**示例:**
Z
zhaoyuan17 已提交
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587

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

Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
```



X
xuzhihao 已提交
1588
## Notification.getAllActiveNotifications
Z
zhaoyuan17 已提交
1589

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

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

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

X
xuzhihao 已提交
1596
**返回值:**
Z
zhaoyuan17 已提交
1597

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

X
xuzhihao 已提交
1602
**示例:**
Z
zhaoyuan17 已提交
1603 1604 1605 1606 1607 1608 1609 1610 1611

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



X
xuzhihao 已提交
1612
## Notification.getActiveNotificationCount
Z
zhaoyuan17 已提交
1613

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

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

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

X
xuzhihao 已提交
1620
**参数:**
Z
zhaoyuan17 已提交
1621

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

X
xuzhihao 已提交
1626
**示例:**
Z
zhaoyuan17 已提交
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637

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

Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
```



X
xuzhihao 已提交
1638
## Notification.getActiveNotificationCount
Z
zhaoyuan17 已提交
1639

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

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

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

X
xuzhihao 已提交
1646
**返回值:**
Z
zhaoyuan17 已提交
1647

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

X
xuzhihao 已提交
1652
**示例:**
Z
zhaoyuan17 已提交
1653 1654 1655 1656 1657 1658 1659 1660 1661

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



X
xuzhihao 已提交
1662
## Notification.getActiveNotifications
Z
zhaoyuan17 已提交
1663

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

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

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

X
xuzhihao 已提交
1670
**参数:**
Z
zhaoyuan17 已提交
1671

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

X
xuzhihao 已提交
1676
**示例:**
Z
zhaoyuan17 已提交
1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687

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

Notification.getActiveNotifications(getActiveNotificationsCallback);
```



X
xuzhihao 已提交
1688
## Notification.getActiveNotifications
Z
zhaoyuan17 已提交
1689

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

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

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

X
xuzhihao 已提交
1696
**返回值:**
Z
zhaoyuan17 已提交
1697

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

X
xuzhihao 已提交
1702
**示例:**
Z
zhaoyuan17 已提交
1703 1704 1705 1706 1707 1708 1709 1710 1711

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



1712
## Notification.cancelGroup<sup>8+</sup>
Z
zhaoyuan17 已提交
1713

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

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

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

X
xuzhihao 已提交
1720
**参数:**
Z
zhaoyuan17 已提交
1721

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

X
xuzhihao 已提交
1727
**示例:**
Z
zhaoyuan17 已提交
1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740

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

var groupName = "GroupName";

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



1741
## Notification.cancelGroup<sup>8+</sup>
Z
zhaoyuan17 已提交
1742

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

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

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

X
xuzhihao 已提交
1749
**参数:**
Z
zhaoyuan17 已提交
1750

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

X
xuzhihao 已提交
1755
**示例:**
Z
zhaoyuan17 已提交
1756 1757 1758 1759 1760 1761 1762 1763 1764 1765

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



1766
## Notification.removeGroupByBundle<sup>8+</sup>
Z
zhaoyuan17 已提交
1767

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

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

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

X
xuzhihao 已提交
1774
**参数:**
Z
zhaoyuan17 已提交
1775

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

X
xuzhihao 已提交
1782
**示例:**
Z
zhaoyuan17 已提交
1783 1784 1785 1786 1787 1788

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

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

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



1797
## Notification.removeGroupByBundle<sup>8+</sup>
Z
zhaoyuan17 已提交
1798

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

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

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

X
xuzhihao 已提交
1805
**参数:**
Z
zhaoyuan17 已提交
1806

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

X
xuzhihao 已提交
1812
**示例:**
Z
zhaoyuan17 已提交
1813 1814

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



1824
## Notification.setDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1825

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

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

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

X
xuzhihao 已提交
1832
**参数:**
Z
zhaoyuan17 已提交
1833

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

X
xuzhihao 已提交
1839
**示例:**
Z
zhaoyuan17 已提交
1840 1841 1842 1843 1844 1845 1846

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

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

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



1857
## Notification.setDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1858

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

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

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

X
xuzhihao 已提交
1865
**参数:**
Z
zhaoyuan17 已提交
1866

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

X
xuzhihao 已提交
1871
**示例:**
Z
zhaoyuan17 已提交
1872 1873 1874

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


1885 1886 1887 1888
## Notification.setDoNotDisturbDate<sup>8+</sup>

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

R
RayShih 已提交
1889
指定用户设置免打扰时间(Callback形式)。
1890 1891 1892 1893 1894 1895 1896

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

**参数:**

| 名称     | 可读 | 可写 | 类型                  | 必填 | 描述                   |
| -------- | ---- | --- | --------------------- | ---- | ---------------------- |
1897
| date     | 是   | 否  | [DoNotDisturbDate](#donotdisturbdate8)      | 是   | 免打扰时间选项。         |
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
| userId   | 是   | 否  | number                | 是   | 设置免打扰事件的用户ID。 |
| callback | 是   | 否  | AsyncCallback\<void\> | 是   | 设置免打扰时间回调函数。 |

**示例:**

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

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

var userId = 1

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



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

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

R
RayShih 已提交
1925
指定用户设置免打扰时间接口(Promise形式)。
1926 1927 1928 1929 1930 1931 1932

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

**参数:**

| 名称   | 可读 | 可写 | 类型             | 必填 | 描述           |
| ------ | ---- | --- | ---------------- | ---- | -------------- |
1933
| date   | 是   | 否  | [DoNotDisturbDate](#donotdisturbdate8) | 是   | 免打扰时间选项。 |
1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951
| 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 已提交
1952

1953
## Notification.getDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1954

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

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

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

X
xuzhihao 已提交
1961
**参数:**
Z
zhaoyuan17 已提交
1962

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

X
xuzhihao 已提交
1967
**示例:**
Z
zhaoyuan17 已提交
1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978

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

Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
```



1979
## Notification.getDoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
1980

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

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

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

X
xuzhihao 已提交
1987
**返回值:**
Z
zhaoyuan17 已提交
1988

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

X
xuzhihao 已提交
1993
**示例:**
Z
zhaoyuan17 已提交
1994 1995 1996 1997 1998 1999 2000 2001

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


2002 2003 2004 2005
## Notification.getDoNotDisturbDate<sup>8+</sup>

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

R
RayShih 已提交
2006
指定用户查询免打扰时间接口(Callback形式)。
2007 2008 2009 2010 2011 2012 2013

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

**参数:**

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

**示例:**

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

var userId = 1

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



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

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

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

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

**参数:**

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

**返回值:**

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

**示例:**

```js
var userId = 1

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

Z
zhaoyuan17 已提交
2061

2062
## Notification.supportDoNotDisturbMode<sup>8+</sup>
Z
zhaoyuan17 已提交
2063

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

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

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

X
xuzhihao 已提交
2070
**参数:**
Z
zhaoyuan17 已提交
2071

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

X
xuzhihao 已提交
2076
**示例:**
Z
zhaoyuan17 已提交
2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087

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

Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
```



2088
## Notification.supportDoNotDisturbMode<sup>8+</sup>
Z
zhaoyuan17 已提交
2089

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

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

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

X
xuzhihao 已提交
2096
**返回值:**
Z
zhaoyuan17 已提交
2097

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

X
xuzhihao 已提交
2102
**示例:**
Z
zhaoyuan17 已提交
2103 2104 2105 2106 2107 2108 2109 2110 2111

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



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

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

F
fangjinliang 已提交
2116
查询模板是否存在(Callback形式)。
Z
zengsiyu 已提交
2117

X
xuzhihao 已提交
2118 2119 2120
**系统能力**:SystemCapability.Notification.Notification

**参数:**
Z
zengsiyu 已提交
2121 2122 2123

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

X
xuzhihao 已提交
2127
**示例:**
Z
zengsiyu 已提交
2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139

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

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



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

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

F
fangjinliang 已提交
2144
查询模板是否存在(Promise形式)。
Z
zengsiyu 已提交
2145

X
xuzhihao 已提交
2146 2147 2148
**系统能力**:SystemCapability.Notification.Notification

**参数:**
Z
zengsiyu 已提交
2149 2150 2151

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

X
xuzhihao 已提交
2154
**返回值:**
Z
zengsiyu 已提交
2155 2156 2157

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

X
xuzhihao 已提交
2160
**示例:**
Z
zengsiyu 已提交
2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171

```javascript
var templateName = 'process';

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



2172
## Notification.requestEnableNotification<sup>8+</sup>
Z
zengsiyu 已提交
2173

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

F
fangjinliang 已提交
2176
应用请求通知使能(Callback形式)。
Z
zengsiyu 已提交
2177

X
xuzhihao 已提交
2178 2179 2180
**系统能力**:SystemCapability.Notification.Notification

**参数:**
Z
zengsiyu 已提交
2181 2182 2183

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

X
xuzhihao 已提交
2186
**示例:**
Z
zengsiyu 已提交
2187 2188

```javascript
2189
function requestEnableNotificationCallback() {
2190
    console.log('------------- requestEnabledNotification --------------');
Z
zengsiyu 已提交
2191 2192
};

2193
Notification.requestEnableNotification(requestEnableNotificationCallback);
Z
zengsiyu 已提交
2194 2195 2196 2197
```



2198
## Notification.requestEnableNotification<sup>8+</sup>
Z
zengsiyu 已提交
2199

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

F
fangjinliang 已提交
2202
应用请求通知使能(Promise形式)。
Z
zengsiyu 已提交
2203

X
xuzhihao 已提交
2204 2205 2206
**系统能力**:SystemCapability.Notification.Notification

**示例:**
Z
zengsiyu 已提交
2207 2208

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


2216
## Notification.enableDistributed<sup>8+</sup>
X
xuzhihao 已提交
2217

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

F
fangjinliang 已提交
2220
设置设备是否支持分布式通知(Callback形式)。
X
xuzhihao 已提交
2221 2222 2223 2224 2225

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

**参数:**

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

**示例:**

```javascript
2234 2235
function enabledNotificationCallback() {
    console.log('----------- enableDistributed ------------');
X
xuzhihao 已提交
2236 2237
};

2238 2239 2240
var enable = true

Notification.enableDistributed(enable, enabledNotificationCallback);
X
xuzhihao 已提交
2241 2242 2243
```


Z
zengsiyu 已提交
2244

2245
## Notification.enableDistributed<sup>8+</sup>
Z
zengsiyu 已提交
2246

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

F
fangjinliang 已提交
2249
设置设备是否支持分布式通知(Promise形式)。
Z
zengsiyu 已提交
2250

2251
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2252

2253
**参数:**
Z
zengsiyu 已提交
2254

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

**示例:**

```javascript
var enable = true

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


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

X
xuzhihao 已提交
2273
isDistributedEnabled(callback: AsyncCallback\<boolean>): void
2274

F
fangjinliang 已提交
2275
获取设备是否支持分布式通知(Callback形式)。
Z
zengsiyu 已提交
2276

X
xuzhihao 已提交
2277 2278 2279
**系统能力**:SystemCapability.Notification.Notification

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

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

X
xuzhihao 已提交
2285
**示例:**
Z
zengsiyu 已提交
2286 2287

```javascript
2288 2289
function isDistributedEnabledCallback() {
    console.log('----------- isDistributedEnabled ------------');
Z
zengsiyu 已提交
2290 2291
};

2292
Notification.isDistributedEnabled(isDistributedEnabledCallback);
Z
zengsiyu 已提交
2293 2294 2295 2296
```



2297
## Notification.isDistributedEnabled<sup>8+</sup>
X
xuezhongzhu 已提交
2298

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

F
fangjinliang 已提交
2301
获取设备是否支持分布式通知(Promise形式)。
Z
zengsiyu 已提交
2302

2303
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2304

2305
**返回值:**
Z
zengsiyu 已提交
2306

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

2311
**示例:**
X
xuezhongzhu 已提交
2312

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


2321
## Notification.enableDistributedByBundle<sup>8+</sup>
Z
zengsiyu 已提交
2322

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

F
fangjinliang 已提交
2325
根据应用的包设置应用程序是否支持分布式通知(Callback形式)。
X
xuezhongzhu 已提交
2326

2327
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2328

2329
**参数:**
Z
zengsiyu 已提交
2330

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

2337
**示例:**
Z
zengsiyu 已提交
2338

2339 2340 2341 2342
```javascript
function enableDistributedByBundleCallback() {
    console.log('----------- enableDistributedByBundle ------------');
};
Z
zengsiyu 已提交
2343

2344 2345 2346
var bundle = {
    bundle: "bundleName1",
}
X
xuezhongzhu 已提交
2347

2348
var enable = true
Z
zengsiyu 已提交
2349

2350 2351
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
```
Z
zengsiyu 已提交
2352 2353 2354



2355
## Notification.enableDistributedByBundle<sup>8+</sup>
X
xuezhongzhu 已提交
2356

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

F
fangjinliang 已提交
2359
根据应用的包设置应用程序是否支持分布式通知(Promise形式)。
Z
zengsiyu 已提交
2360

2361
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2362

2363
**参数:**
Z
zengsiyu 已提交
2364

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

2370
**示例:**
Z
zengsiyu 已提交
2371

2372 2373 2374 2375
```javascript
var bundle = {
    bundle: "bundleName1",
}
Z
zengsiyu 已提交
2376

2377
var enable = true
X
xuezhongzhu 已提交
2378

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

2385
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
Z
zengsiyu 已提交
2386

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

F
fangjinliang 已提交
2389
根据应用的包获取应用程序是否支持分布式通知(Callback形式)。
Z
zengsiyu 已提交
2390

2391
**系统能力**:SystemCapability.Notification.Notification
X
xuezhongzhu 已提交
2392

2393
**参数:**
Z
zengsiyu 已提交
2394

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

2400
**示例:**
Z
zengsiyu 已提交
2401

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

2407 2408 2409
var bundle = {
    bundle: "bundleName1",
}
X
xuezhongzhu 已提交
2410

2411
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
2412
```
Z
zengsiyu 已提交
2413 2414 2415



2416
## Notification.isDistributedEnabledByBundle<sup>8+</sup>
Z
zengsiyu 已提交
2417

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

F
fangjinliang 已提交
2420
根据应用的包获取应用程序是否支持分布式通知(Promise形式)。
Z
zengsiyu 已提交
2421

2422
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2423

2424
**参数:**
Z
zengsiyu 已提交
2425

2426 2427
| 参数名   | 类型                     | 必填 | 说明                       |
| -------- | ------------------------ | ---- | -------------------------- |
2428
| bundle   | [BundleOption](#bundleoption)             | 是   | 应用的包。                |
Z
zengsiyu 已提交
2429

2430
**返回值:**
X
xuezhongzhu 已提交
2431

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

2436
**示例:**
Z
zengsiyu 已提交
2437

2438 2439 2440 2441
```javascript
var bundle = {
    bundle: "bundleName1",
}
Z
zengsiyu 已提交
2442

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

X
xuezhongzhu 已提交
2449

2450
## Notification.getDeviceRemindType<sup>8+</sup>
Z
zengsiyu 已提交
2451

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

F
fangjinliang 已提交
2454
获取通知的提醒方式(Callback形式)。
Z
zengsiyu 已提交
2455

2456
**系统能力**:SystemCapability.Notification.Notification
Z
zengsiyu 已提交
2457

2458
**参数:**
X
xuezhongzhu 已提交
2459

2460 2461
| 参数名   | 类型                               | 必填 | 说明                       |
| -------- | --------------------------------- | ---- | -------------------------- |
R
RayShih 已提交
2462
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | 是   | 获取通知的提醒方式的回调函数。 |
Z
zengsiyu 已提交
2463

2464
**示例:**
Z
zengsiyu 已提交
2465

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

2471 2472
Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
```
Z
zengsiyu 已提交
2473

X
xuezhongzhu 已提交
2474

Z
zengsiyu 已提交
2475

2476
## Notification.getDeviceRemindType<sup>8+</sup>
Z
zengsiyu 已提交
2477

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

F
fangjinliang 已提交
2480
获取通知的提醒方式(Promise形式)。
Z
zengsiyu 已提交
2481

2482
**系统能力**:SystemCapability.Notification.Notification
X
xuezhongzhu 已提交
2483

2484
**返回值:**
Z
zengsiyu 已提交
2485

2486 2487
| 类型               | 说明            |
| ------------------ | --------------- |
R
RayShih 已提交
2488
| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise方式返回通知的提醒方式的结果。 |
Z
zengsiyu 已提交
2489

2490
**示例:**
Z
zengsiyu 已提交
2491

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

2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540
## Notification.publishAsBundle<sup>9+</sup>

publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void

发布代理通知(callback形式)。

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

**参数:**


| 参数名               | 类型                                        | 必填 | 说明                                          |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request              | [NotificationRequest](#notificationrequest) | 是   | 设置要发布通知内容的NotificationRequest对象。 |
| representativeBundle | string                                      | 是   | 被代理应用的包名。                            |
| userId               | number                                      | 是   | 接收通知用户的Id。                            |
| callback             | AsyncCallback                               | 是   | 发布代理通知的回调方法。                      |

**示例:**

```js
//publishAsBundle回调
function publishAsBundleCallback(err) {
	console.info("==========================>publishAsBundleCallback=======================>");
}
// 被代理应用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用户ID
let userId = 100
//通知Request对象
let notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

2541
Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback);
2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615
```

## Notification.publishAsBundle<sup>9+</sup>

publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>

发布代理通知(Promise形式)。

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

**参数:**


| 参数名               | 类型                                        | 必填 | 说明                                          |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request              | [NotificationRequest](#notificationrequest) | 是   | 设置要发布通知内容的NotificationRequest对象。 |
| representativeBundle | string                                      | 是   | 被代理应用的包名。                            |
| userId               | number                                      | 是   | 接收通知用户的Id。                            |

**示例:**

```js
// 被代理应用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用户ID
let userId = 100
//通知Request对象
var notificationRequest = {
    id: 1,
    content: {
        contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
        normal: {
            title: "test_title",
            text: "test_text",
            additionalText: "test_additionalText"
        }
    }
}

Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => {
	console.info("==========================>publishAsBundleCallback=======================>");
});
```

## Notification.cancelAsBundle<sup>9+</sup>

cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void

取消代理通知(callback形式)。

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

**参数:**


| 参数名               | 类型          | 必填 | 说明                     |
| -------------------- | ------------- | ---- | ------------------------ |
| id                   | number        | 是   | 通知ID。                 |
| representativeBundle | string        | 是   | 被代理应用的包名。       |
| userId               | number        | 是   | 接收通知用户的Id。       |
| callback             | AsyncCallback | 是   | 取消代理通知的回调方法。 |

**示例:**

```js
//cancelAsBundle
function cancelAsBundleCallback(err) {
	console.info("==========================>cancelAsBundleCallback=======================>");
}
// 被代理应用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用户ID
let userId = 100

2616
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
2617 2618 2619 2620
```

## Notification.cancelAsBundle<sup>9+</sup>

X
xuzhihao 已提交
2621
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648

发布代理通知(Promise形式)。

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

**参数:**


| 参数名               | 类型   | 必填 | 说明               |
| -------------------- | ------ | ---- | ------------------ |
| id                   | number | 是   | 通知ID。           |
| representativeBundle | string | 是   | 被代理应用的包名。 |
| userId               | number | 是   | 接收通知用户的Id。 |

**示例:**

```js
// 被代理应用的包名
let representativeBundle = "com.example.demo"
// 接收通知的用户ID
let userId = 100

Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
	console.info("==========================>cancelAsBundleCallback=======================>");
});
```

F
fangjinliang 已提交
2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765
### Notification.enableNotificationSlot <sup>9+</sup>

enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback<void>): void

设定指定类型的渠道使能状态(Callback形式)。

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

**参数:**

| 参数名   | 类型                          | 必填 | 说明                   |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | 是   | 指定包信息。           |
| type     | [SlotType](#slottype)         | 是   | 指定渠道类型。         |
| enable   | boolean                       | 是   | 使能状态。             |
| callback | AsyncCallback\<void\>         | 是   | 设定渠道使能回调函数。 |

**示例:**

```js
//enableNotificationSlot
function enableSlotCallback(err) {
    console.log('===================>enableSlotCallback==================>');
};

Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    true,
    enableSlotCallback);
```

### Notification.enableNotificationSlot <sup>9+</sup>

enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise<void> 

设定指定类型的渠道使能状态(Promise形式)。

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

**参数:**

| 参数名 | 类型                          | 必填 | 说明           |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是   | 指定包信息。   |
| type   | [SlotType](#slottype)         | 是   | 指定渠道类型。 |
| enable | boolean                       | 是   | 使能状态。     |

**示例:**

```js
//enableNotificationSlot
Notification.enableNotificationSlot(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    true).then(() => {
        console.log('====================>enableNotificationSlot====================>');
    });
```

### Notification.isNotificationSlotEnabled <sup>9+</sup>

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback<boolean>): void

获取指定类型的渠道使能状态(Callback形式)。

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

**参数:**

| 参数名   | 类型                          | 必填 | 说明                   |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle   | [BundleOption](#bundleoption) | 是   | 指定包信息。           |
| type     | [SlotType](#slottype)         | 是   | 指定渠道类型。         |
| callback | AsyncCallback\<void\>         | 是   | 设定渠道使能回调函数。 |

**示例:**

```js
//isNotificationSlotEnabled
function getEnableSlotCallback(err, data) {
    console.log('===================>getEnableSlotCallback==================');
};

Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    getEnableSlotCallback);
```

### Notification.isNotificationSlotEnabled <sup>9+</sup>

isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise<boolean>  

获取指定类型的渠道使能状态(Promise形式)。

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

**参数:**

| 参数名 | 类型                          | 必填 | 说明           |
| ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是   | 指定包信息。   |
| type   | [SlotType](#slottype)         | 是   | 指定渠道类型。 |

**示例:**

```js
//isNotificationSlotEnabled
Notification.isNotificationSlotEnabled(
    { bundle: "ohos.samples.notification", },
    notify.SlotType.SOCIAL_COMMUNICATION,
    true).then((data) => {
      console.log('====================>isNotificationSlotEnabled====================>');
    });
```

2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799
## NotificationSubscriber

### onConsume

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

接收通知回调函数。

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

**参数:**

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

**示例:**

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

function onConsumeCallback(data) {
    console.info('===> onConsume in test');
    let req = data.request;
    console.info('===> onConsume callback req.id:' + req.id);
    let wantAgent = data.wantAgent;
    wantAgent .getWant(wantAgent)
        .then((data1) => {
2800
            console.log('===> getWant success want:' + JSON.stringify(data1));
2801 2802
        })
        .catch((err) => {
2803
            console.error('===> getWant failed because' + JSON.stringify(err));
2804
        });
2805
    console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016
};

var subscriber = {
    onConsume: onConsumeCallback
};

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

### onCancel

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

删除通知回调函数。

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

**参数:**

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

**示例:**

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

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

var subscriber = {
    onCancel: onCancelCallback
};

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

### onUpdate

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

更新通知排序回调函数。

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

**参数:**

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

**示例:**

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

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

var subscriber = {
    onUpdate: onUpdateCallback
};

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

### onConnect

onConnect?:void

注册订阅回调函数。

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

**示例:**

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

function onConnectCallback() {
    console.info('===> onConnect in test');
}

var subscriber = {
    onConnect: onConnectCallback
};

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

### onDisconnect

onDisconnect?:void

取消订阅回调函数。

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

**示例:**

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

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

var subscriber = {
    onDisconnect: onDisconnectCallback
};

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

### onDestroy

onDestroy?:void

服务失联回调函数。

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

**示例:**

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

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

var subscriber = {
    onDestroy: onDestroyCallback
};

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

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

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

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

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

**参数:**

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

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

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

var subscriber = {
    onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};

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


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

R
RayShih 已提交
3017
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8))
3018 3019 3020 3021 3022 3023 3024 3025 3026

监听应用通知使能变化。

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

**参数:**

| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- |
R
RayShih 已提交
3027
| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata8)\> | 是 | 回调返回监听到的应用信息。 |
3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039

**示例:**

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

3040 3041 3042 3043
function onEnabledNotificationChangedCallback(callbackData) {
    console.info("bundle: ", callbackData.bundle);
    console.info("uid: ", callbackData.uid);
    console.info("enable: ", callbackData.enable);
3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075
};

var subscriber = {
    onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};

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

## SubscribeCallbackData

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

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


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

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

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

X
xuezhongzhu 已提交
3076

X
xuzhihao 已提交
3077
## DoNotDisturbDate<sup>8+</sup>
Z
zhaoyuan17 已提交
3078

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

3081 3082
| 名称  | 可读 | 可写 | 类型                                  | 描述                     |
| ----- | ---- | --- | ------------------------------------- | ------------------------ |
3083
| type  | 是  | 否  | [DoNotDisturbType](#donotdisturbtype8) | 指定免打扰设置的时间类型。 |
3084 3085
| begin | 是  | 否  | Date                                  | 指定免打扰设置的起点时间。 |
| end   | 是  | 否  | Date                                  | 指定免打扰设置的终点时间。 |
Z
zhaoyuan17 已提交
3086 3087 3088



3089
## DoNotDisturbType<sup>8+</sup>
Z
zhaoyuan17 已提交
3090

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


3094 3095 3096 3097 3098 3099
| 名称         | 值               | 说明                                       |
| ------------ | ---------------- | ------------------------------------------ |
| TYPE_NONE    | DoNotDisturbType | 非通知勿扰类型。                           |
| TYPE_ONCE    | DoNotDisturbType | 以设置时间段(只看小时和分钟)一次执行勿扰。 |
| TYPE_DAILY   | DoNotDisturbType | 以设置时间段(只看小时和分钟)每天执行勿扰。 |
| TYPE_CLEARLY | DoNotDisturbType | 以设置时间段(明确年月日时分)执行勿扰。     |
Z
zhaoyuan17 已提交
3100 3101


3102
## ContentType
Z
zhaoyuan17 已提交
3103

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

3106 3107 3108 3109 3110 3111 3112
| 名称                              | 值          | 说明               |
| --------------------------------- | ----------- | ------------------ |
| NOTIFICATION_CONTENT_BASIC_TEXT   | ContentType | 普通类型通知。     |
| NOTIFICATION_CONTENT_LONG_TEXT    | ContentType | 长文本类型通知。   |
| NOTIFICATION_CONTENT_PICTURE      | ContentType | 图片类型通知。     |
| NOTIFICATION_CONTENT_CONVERSATION | ContentType | 社交类型通知。     |
| NOTIFICATION_CONTENT_MULTILINE    | ContentType | 多行文本类型通知。 |
Z
zhaoyuan17 已提交
3113

X
xuzhihao 已提交
3114
## SlotLevel
Z
zhaoyuan17 已提交
3115

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

X
xuzhihao 已提交
3118 3119 3120
| 名称                              | 值          | 说明               |
| --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE                        | 0           | 表示关闭通知功能。     |
F
fangjinliang 已提交
3121 3122 3123 3124
| LEVEL_MIN                         | 1           | 表示通知功能已启用,但状态栏中不显示通知图标,且没有横幅或提示音。 |
| LEVEL_LOW                         | 2           | 表示通知功能已启用,且状态栏中显示通知图标,但没有横幅或提示音。 |
| LEVEL_DEFAULT                     | 3           | 表示通知功能已启用,状态栏中显示通知图标,没有横幅但有提示音。 |
| LEVEL_HIGH                        | 4           | 表示通知功能已启用,状态栏中显示通知图标,有横幅和提示音。 |
Z
zhaoyuan17 已提交
3125 3126


3127
## BundleOption
Z
zhaoyuan17 已提交
3128

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

3131 3132 3133 3134
| 名称   | 可读 | 可写 | 类型   | 必填 | 描述   |
| ------ | ---- | --- | ------ | ---- | ------ |
| bundle | 是  | 是  | string | 是   | 包名。   |
| uid    | 是  | 是  | number | 否   | 用户id。 |
Z
zhaoyuan17 已提交
3135 3136 3137



3138
## NotificationKey
Z
zhaoyuan17 已提交
3139

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

3142 3143 3144
| 名称  | 可读 | 可写 | 类型   | 必填 | 描述     |
| ----- | ---- | --- | ------ | ---- | -------- |
| id    | 是  | 是  | number | 是   | 通知ID。   |
3145
| label | 是  | 是  | string | 否   | 通知标签。 |
Z
zhaoyuan17 已提交
3146 3147


3148
## SlotType
Z
zhaoyuan17 已提交
3149

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

3152 3153 3154 3155 3156 3157
| 名称                 | 值       | 说明       |
| -------------------- | -------- | ---------- |
| UNKNOWN_TYPE         | SlotType | 未知类型。 |
| SOCIAL_COMMUNICATION | SlotType | 社交类型。 |
| SERVICE_INFORMATION  | SlotType | 服务类型。 |
| CONTENT_INFORMATION  | SlotType | 内容类型。 |
3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169
| OTHER_TYPES          | SlotType | 其他类型。 |


## NotificationActionButton

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

| 名称      | 可读 | 可写 | 类型                                            | 必填 | 描述                      |
| --------- | --- | ---- | ----------------------------------------------- | ---- | ------------------------- |
| title     | 是  | 是  | string                                          | 是   | 按钮标题。                  |
| wantAgent | 是  | 是  | WantAgent                                       | 是   | 点击按钮时触发的WantAgent。 |
| extras    | 是  | 是  | { [key: string]: any }                          | 否   | 按钮扩展信息。              |
R
RayShih 已提交
3170
| userInput<sup>9+</sup> | 是  | 是  | [NotificationUserInput](#notificationuserinput8) | 否   | 用户输入对象实例。          |
3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294


## NotificationBasicContent

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

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


## NotificationLongTextContent

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

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


## NotificationMultiLineContent

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

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


## NotificationPictureContent

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

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


## NotificationContent

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

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


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

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

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


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

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

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


## NotificationRequest

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

| 名称                  | 可读 | 可写 | 类型                                          | 必填 | 描述                       |
| --------------------- | ---- | --- | --------------------------------------------- | ---- | -------------------------- |
| content               | 是  | 是  | [NotificationContent](#notificationcontent)   | 是   | 通知内容。                   |
| id                    | 是  | 是  | number                                        | 否   | 通知ID。                     |
| slotType              | 是  | 是  | [SlotType](#slottype)                                      | 否   | 通道类型。                   |
| isOngoing             | 是  | 是  | boolean                                       | 否   | 是否进行时通知。             |
| isUnremovable         | 是  | 是  | boolean                                       | 否   | 是否可移除。                 |
| deliveryTime          | 是  | 是  | number                                        | 否   | 通知发送时间。               |
| tapDismissed          | 是  | 是  | boolean                                       | 否   | 通知是否自动清除。           |
| autoDeletedTime       | 是  | 是  | number                                        | 否   | 自动清除的时间。             |
| wantAgent             | 是  | 是  | WantAgent                                     | 否   | 点击跳转的WantAgent。        |
| extraInfo             | 是  | 是  | {[key: string]: any}                          | 否   | 扩展参数。                   |
| color                 | 是  | 是  | number                                        | 否   | 通知背景颜色。               |
| colorEnabled          | 是  | 是  | boolean                                       | 否   | 通知背景颜色是否使能。       |
| isAlertOnce           | 是  | 是  | boolean                                       | 否   | 设置是否仅有一次此通知警报。 |
| isStopwatch           | 是  | 是  | boolean                                       | 否   | 是否显示已用时间。           |
| isCountDown           | 是  | 是  | boolean                                       | 否   | 是否显示倒计时时间。         |
| isFloatingIcon        | 是  | 是  | boolean                                       | 否   | 是否显示状态栏图标。         |
| label                 | 是  | 是  | string                                        | 否   | 通知标签。                   |
| badgeIconStyle        | 是  | 是  | number                                        | 否   | 通知角标类型。               |
| showDeliveryTime      | 是  | 是  | boolean                                       | 否   | 是否显示分发时间。           |
| actionButtons         | 是  | 是  | Array\<[NotificationActionButton](#notificationactionbutton)\>             | 否   | 通知按钮,最多两个按钮。     |
| smallIcon             | 是  | 是  | PixelMap                                      | 否   | 通知小图标。                 |
| largeIcon             | 是  | 是  | PixelMap                                      | 否   | 通知大图标。                 |
| creatorBundleName     | 是  | 否  | string                                        | 否   | 创建通知的包名。             |
| creatorUid            | 是  | 否  | number                                        | 否   | 创建通知的UID。              |
| creatorPid            | 是  | 否  | number                                        | 否   | 创建通知的PID。              |
| creatorUserId<sup>8+</sup>| 是  | 否  | number                                    | 否   | 创建通知的UserId。           |
| hashCode              | 是  | 否  | string                                        | 否   | 通知唯一标识。               |
| classification        | 是  | 是  | string                                        | 否   | 通知分类。                   |
| groupName<sup>8+</sup>| 是  | 是  | string                                        | 否   | 组通知名称。                 |
R
RayShih 已提交
3295
| template<sup>8+</sup> | 是  | 是  | [NotificationTemplate](#notificationtemplate8) | 否   | 通知模板。                   |
3296 3297
| isRemoveAllowed<sup>8+</sup> | 是  | 否  | boolean                                | 否   | 通知是否能被移除。                   |
| source<sup>8+</sup>   | 是  | 否  | number                                        | 否   | 通知源。                   |
R
RayShih 已提交
3298
| distributedOption<sup>8+</sup>   | 是  | 是  | [DistributedOptions](#distributedoptions8)                 | 否   | 分布式通知的选项。          |
3299
| deviceId<sup>8+</sup> | 是  | 否  | string                                        | 否   | 通知源的deviceId。          |
R
RayShih 已提交
3300
| notificationFlags<sup>8+</sup> | 是  | 否  | [NotificationFlags](#notificationflags8)                    | 否   | 获取NotificationFlags。          |
3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331


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

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

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


## NotificationSlot

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

| 名称                 | 可读 | 可写 | 类型                  | 必填 | 描述                                       |
| -------------------- | ---- | --- | --------------------- | ---- | ------------------------------------------ |
| type                 | 是  | 是  | [SlotType](#slottype) | 是   | 通道类型。                                   |
| level                | 是  | 是  | number                | 否   | 通知级别,不设置则根据通知渠道类型有默认值。 |
| desc                 | 是  | 是  | string                | 否   | 通知渠道描述信息。                           |
| badgeFlag            | 是  | 是  | boolean               | 否   | 是否显示角标。                               |
| bypassDnd            | 是  | 是  | boolean               | 否   | 置是否在系统中绕过免打扰模式。               |
| lockscreenVisibility | 是  | 是  | boolean               | 否   | 在锁定屏幕上显示通知的模式。                 |
| vibrationEnabled     | 是  | 是  | boolean               | 否   | 是否可振动。                                 |
| sound                | 是  | 是  | string                | 否   | 通知提示音。                                 |
| lightEnabled         | 是  | 是  | boolean               | 否   | 是否闪灯。                                   |
| lightColor           | 是  | 是  | number                | 否   | 通知灯颜色。                                 |
| vibrationValues      | 是  | 是  | Array\<number\>       | 否   | 通知振动样式。                               |
3332
| enabled<sup>9+</sup> | 是  | 否  | boolean               | 否   | 此通知插槽中的启停状态。                      |
3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393


## NotificationSorting

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

| 名称     | 可读 | 可写 | 类型                                  | 必填 | 描述         |
| -------- | ---- | --- | ------------------------------------- | ---- | ------------ |
| slot     | 是  | 否  | [NotificationSlot](#notificationslot) | 是   | 通知通道内容。 |
| hashCode | 是  | 否  | string                                | 是   | 通知唯一标识。 |
| ranking  | 是  | 否  | number                                | 是   | 通知排序序号。 |


## NotificationSortingMap

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

| 名称           | 可读 | 可写 | 类型                                                         | 必填 | 描述             |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- |
| sortings       | 是  | 否  | {[key: string]: [NotificationSorting](#notificationsorting)} | 是   | 通知排序信息数组。 |
| sortedHashCode | 是  | 否  | Array\<string\>                                              | 是   | 通知唯一标识数组。 |


## NotificationSubscribeInfo

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

| 名称        | 可读 | 可写 | 类型            | 必填 | 描述                            |
| ----------- | --- | ---- | --------------- | ---- | ------------------------------- |
| bundleNames | 是  | 是  | Array\<string\> | 否   | 指定订阅哪些包名的APP发来的通知。 |
| userId      | 是  | 是  | number          | 否   | 指定订阅哪个用户下发来的通知。    |


## NotificationTemplate<sup>8+</sup>

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

| 名称 | 参数类型               | 可读 | 可写 | 说明       |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string                 | 是   | 是   | 模板名称。 |
| data | {[key:string]: Object} | 是   | 是   | 模板数据。 |


## NotificationUserInput<sup>8+</sup>

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

| 名称     | 可读 | 可写 | 类型   | 必填 | 描述                          |
| -------- | --- | ---- | ------ | ---- | ----------------------------- |
| inputKey | 是  | 是  | string | 是   | 用户输入时用于标识此输入的key。 |


## DeviceRemindType<sup>8+</sup>

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

| 名称                 | 值  | 描述                               |
| -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND    | 0   | 设备未被使用,无需提醒。            |
| IDLE_REMIND          | 1   | 提醒设备未被使用。                 |
| ACTIVE_DONOT_REMIND  | 2   | 设备正在使用,无需提醒。            |
3394
| ACTIVE_REMIND        | 3   | 提醒设备正在使用。                 |