提交 07f14a0f 编写于 作者: F fangJinliang1

fix notification api doc

Signed-off-by: NfangJinliang1 <fangjinliang1@huawei.com>
Change-Id: I1105289f7808dcea2eaf6a01e5b2d5cb4a975890
Signed-off-by: NfangJinliang1 <fangjinliang1@huawei.com>
上级 86e30053
...@@ -35,7 +35,7 @@ WantAgent提供了封装行为意图的能力,这里所说的行为意图主 ...@@ -35,7 +35,7 @@ WantAgent提供了封装行为意图的能力,这里所说的行为意图主
``` ```
2. 创建WantAgentInfo信息。 2. 创建WantAgentInfo信息。
场景一:创建拉起Ability的WantAgent的WantAgentInfo信息。 场景一:创建拉起Ability的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。
```ts ```ts
let wantAgentObj = null; // 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。 let wantAgentObj = null; // 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。
...@@ -59,7 +59,7 @@ WantAgent提供了封装行为意图的能力,这里所说的行为意图主 ...@@ -59,7 +59,7 @@ WantAgent提供了封装行为意图的能力,这里所说的行为意图主
} }
``` ```
场景二:创建发布公共事件的WantAgent的WantAgentInfo信息。 场景二:创建发布公共事件的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。
```ts ```ts
let wantAgentObj = null; // 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。 let wantAgentObj = null; // 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
本模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知通道,订阅、取消订阅通知,获取通知的使能状态、角标使能状态,获取通知的相关信息等。 本模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知通道,订阅、取消订阅通知,获取通知的使能状态、角标使能状态,获取通知的相关信息等。
一般情况下,只有系统应用具有通知订阅和取消订阅的权限。
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 通知订阅和取消订阅仅对系统应用开放。
## 导入模块 ## 导入模块
...@@ -26,13 +26,13 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void ...@@ -26,13 +26,13 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- | | -------- | ------------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| callback | AsyncCallback\<void\> | 是 | 被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 发布通知的回调方法。 |
**示例:** **示例:**
```js ```js
//publish回调 // publish回调
function publishCallback(err) { function publishCallback(err) {
if (err.code) { if (err.code) {
console.info("publish failed " + JSON.stringify(err)); console.info("publish failed " + JSON.stringify(err));
...@@ -40,8 +40,8 @@ function publishCallback(err) { ...@@ -40,8 +40,8 @@ function publishCallback(err) {
console.info("publish success"); console.info("publish success");
} }
} }
//通知Request对象 // 通知Request对象
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -51,8 +51,8 @@ var notificationRequest = { ...@@ -51,8 +51,8 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, publishCallback) Notification.publish(notificationRequest, publishCallback);
``` ```
...@@ -69,13 +69,13 @@ publish(request: NotificationRequest): Promise\<void\> ...@@ -69,13 +69,13 @@ publish(request: NotificationRequest): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- | | -------- | ------------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
**示例:** **示例:**
```js ```js
//通知Request对象 // 通知Request对象
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -85,9 +85,9 @@ var notificationRequest = { ...@@ -85,9 +85,9 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest).then(() => { Notification.publish(notificationRequest).then(() => {
console.info("publish sucess"); console.info("publish success");
}); });
``` ```
...@@ -96,7 +96,7 @@ Notification.publish(notificationRequest).then(() => { ...@@ -96,7 +96,7 @@ Notification.publish(notificationRequest).then(() => {
publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
发布通知(callback形式)。 发布通知给指定的用户(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -108,8 +108,8 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v ...@@ -108,8 +108,8 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback\<void\> | 是 | 被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 被指定的回调方法。 |
**示例:** **示例:**
...@@ -123,10 +123,10 @@ function publishCallback(err) { ...@@ -123,10 +123,10 @@ function publishCallback(err) {
console.info("publish success"); console.info("publish success");
} }
} }
// 接收通知的用户ID // 用户ID
var userId = 1 let userId = 1;
//通知Request对象 // 通知Request对象
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -136,7 +136,7 @@ var notificationRequest = { ...@@ -136,7 +136,7 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, userId, publishCallback); Notification.publish(notificationRequest, userId, publishCallback);
``` ```
...@@ -144,7 +144,7 @@ Notification.publish(notificationRequest, userId, publishCallback); ...@@ -144,7 +144,7 @@ Notification.publish(notificationRequest, userId, publishCallback);
publish(request: NotificationRequest, userId: number): Promise\<void\> publish(request: NotificationRequest, userId: number): Promise\<void\>
发布通知(Promise形式)。 发布通知给指定的用户(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -156,13 +156,13 @@ publish(request: NotificationRequest, userId: number): Promise\<void\> ...@@ -156,13 +156,13 @@ publish(request: NotificationRequest, userId: number): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**示例:** **示例:**
```js ```js
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -172,12 +172,12 @@ var notificationRequest = { ...@@ -172,12 +172,12 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
var userId = 1 let userId = 1;
Notification.publish(notificationRequest, userId).then(() => { Notification.publish(notificationRequest, userId).then(() => {
console.info("publish sucess"); console.info("publish success");
}); });
``` ```
...@@ -186,7 +186,7 @@ Notification.publish(notificationRequest, userId).then(() => { ...@@ -186,7 +186,7 @@ Notification.publish(notificationRequest, userId).then(() => {
cancel(id: number, label: string, callback: AsyncCallback\<void\>): void cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
取消与指定id和label相匹配的已发布通知(callback形式)。 通过通知ID和通知标签取消已发布的通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -201,7 +201,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void ...@@ -201,7 +201,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//cancel回调 // cancel回调
function cancelCallback(err) { function cancelCallback(err) {
if (err.code) { if (err.code) {
console.info("cancel failed " + JSON.stringify(err)); console.info("cancel failed " + JSON.stringify(err));
...@@ -209,7 +209,7 @@ function cancelCallback(err) { ...@@ -209,7 +209,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, "label", cancelCallback) Notification.cancel(0, "label", cancelCallback);
``` ```
...@@ -218,7 +218,7 @@ Notification.cancel(0, "label", cancelCallback) ...@@ -218,7 +218,7 @@ Notification.cancel(0, "label", cancelCallback)
cancel(id: number, label?: string): Promise\<void\> cancel(id: number, label?: string): Promise\<void\>
取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 取消与指定通知ID相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -233,7 +233,7 @@ cancel(id: number, label?: string): Promise\<void\> ...@@ -233,7 +233,7 @@ cancel(id: number, label?: string): Promise\<void\>
```js ```js
Notification.cancel(0).then(() => { Notification.cancel(0).then(() => {
console.info("cancel sucess"); console.info("cancel success");
}); });
``` ```
...@@ -243,7 +243,7 @@ Notification.cancel(0).then(() => { ...@@ -243,7 +243,7 @@ Notification.cancel(0).then(() => {
cancel(id: number, callback: AsyncCallback\<void\>): void cancel(id: number, callback: AsyncCallback\<void\>): void
取消与指定id相匹配的已发布通知(callback形式)。 取消与指定通知ID相匹配的已发布通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -257,7 +257,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void ...@@ -257,7 +257,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//cancel回调 // cancel回调
function cancelCallback(err) { function cancelCallback(err) {
if (err.code) { if (err.code) {
console.info("cancel failed " + JSON.stringify(err)); console.info("cancel failed " + JSON.stringify(err));
...@@ -265,7 +265,7 @@ function cancelCallback(err) { ...@@ -265,7 +265,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, cancelCallback) Notification.cancel(0, cancelCallback);
``` ```
...@@ -287,7 +287,7 @@ cancelAll(callback: AsyncCallback\<void\>): void ...@@ -287,7 +287,7 @@ cancelAll(callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//cancel回调 // cancel回调
function cancelAllCallback(err) { function cancelAllCallback(err) {
if (err.code) { if (err.code) {
console.info("cancelAll failed " + JSON.stringify(err)); console.info("cancelAll failed " + JSON.stringify(err));
...@@ -295,7 +295,7 @@ function cancelAllCallback(err) { ...@@ -295,7 +295,7 @@ function cancelAllCallback(err) {
console.info("cancelAll success"); console.info("cancelAll success");
} }
} }
Notification.cancelAll(cancelAllCallback) Notification.cancelAll(cancelAllCallback);
``` ```
...@@ -312,7 +312,7 @@ cancelAll(): Promise\<void\> ...@@ -312,7 +312,7 @@ cancelAll(): Promise\<void\>
```js ```js
Notification.cancelAll().then(() => { Notification.cancelAll().then(() => {
console.info("cancelAll sucess"); console.info("cancelAll success");
}); });
``` ```
...@@ -340,7 +340,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void ...@@ -340,7 +340,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//addslot回调 // addslot回调
function addSlotCallBack(err) { function addSlotCallBack(err) {
if (err.code) { if (err.code) {
console.info("addSlot failed " + JSON.stringify(err)); console.info("addSlot failed " + JSON.stringify(err));
...@@ -348,11 +348,11 @@ function addSlotCallBack(err) { ...@@ -348,11 +348,11 @@ function addSlotCallBack(err) {
console.info("addSlot success"); console.info("addSlot success");
} }
} }
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot, addSlotCallBack) Notification.addSlot(notificationSlot, addSlotCallBack);
``` ```
...@@ -378,12 +378,12 @@ addSlot(slot: NotificationSlot): Promise\<void\> ...@@ -378,12 +378,12 @@ addSlot(slot: NotificationSlot): Promise\<void\>
**示例:** **示例:**
```js ```js
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot).then(() => { Notification.addSlot(notificationSlot).then(() => {
console.info("addSlot sucess"); console.info("addSlot success");
}); });
``` ```
...@@ -393,7 +393,7 @@ Notification.addSlot(notificationSlot).then(() => { ...@@ -393,7 +393,7 @@ Notification.addSlot(notificationSlot).then(() => {
addSlot(type: SlotType, callback: AsyncCallback\<void\>): void addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
创建通知通道(callback形式)。 创建指定类型的通知通道(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -407,7 +407,7 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void ...@@ -407,7 +407,7 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//addslot回调 // addslot回调
function addSlotCallBack(err) { function addSlotCallBack(err) {
if (err.code) { if (err.code) {
console.info("addSlot failed " + JSON.stringify(err)); console.info("addSlot failed " + JSON.stringify(err));
...@@ -415,7 +415,7 @@ function addSlotCallBack(err) { ...@@ -415,7 +415,7 @@ function addSlotCallBack(err) {
console.info("addSlot success"); console.info("addSlot success");
} }
} }
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
``` ```
...@@ -424,7 +424,7 @@ Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack ...@@ -424,7 +424,7 @@ Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack
addSlot(type: SlotType): Promise\<void\> addSlot(type: SlotType): Promise\<void\>
创建通知通道(Promise形式)。 创建指定类型的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -438,7 +438,7 @@ addSlot(type: SlotType): Promise\<void\> ...@@ -438,7 +438,7 @@ addSlot(type: SlotType): Promise\<void\>
```js ```js
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
console.info("addSlot sucess"); console.info("addSlot success");
}); });
``` ```
...@@ -466,7 +466,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi ...@@ -466,7 +466,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
**示例:** **示例:**
```js ```js
//addSlots回调 // addSlots回调
function addSlotsCallBack(err) { function addSlotsCallBack(err) {
if (err.code) { if (err.code) {
console.info("addSlots failed " + JSON.stringify(err)); console.info("addSlots failed " + JSON.stringify(err));
...@@ -474,15 +474,15 @@ function addSlotsCallBack(err) { ...@@ -474,15 +474,15 @@ function addSlotsCallBack(err) {
console.info("addSlots success"); console.info("addSlots success");
} }
} }
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
//通知slot array 对象 // 通知slot array 对象
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray, addSlotsCallBack) Notification.addSlots(notificationSlotArray, addSlotsCallBack);
``` ```
...@@ -508,16 +508,16 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\> ...@@ -508,16 +508,16 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
**示例:** **示例:**
```js ```js
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
//通知slot array 对象 // 通知slot array 对象
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray).then(() => { Notification.addSlots(notificationSlotArray).then(() => {
console.info("addSlots sucess"); console.info("addSlots success");
}); });
``` ```
...@@ -527,7 +527,7 @@ Notification.addSlots(notificationSlotArray).then(() => { ...@@ -527,7 +527,7 @@ Notification.addSlots(notificationSlotArray).then(() => {
getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
获取一个通知通道(callback形式)。 获取一个指定类型的通知通道(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -535,22 +535,22 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void ...@@ -535,22 +535,22 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ----------------------------------------------------------- | | -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型目前分为社交通信、服务提醒、内容咨询和其他类型。 |
| callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 |
**示例:** **示例:**
```js ```js
//getSlot回调 // getSlot回调
function getSlotCallback(err,data) { function getSlotCallback(err, data) {
if (err.code) { if (err.code) {
console.info("getSlot failed " + JSON.stringify(err)); console.info("getSlot failed " + JSON.stringify(err));
} else { } else {
console.info("getSlot success"); console.info("getSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback) Notification.getSlot(slotType, getSlotCallback);
``` ```
...@@ -559,7 +559,7 @@ Notification.getSlot(slotType, getSlotCallback) ...@@ -559,7 +559,7 @@ Notification.getSlot(slotType, getSlotCallback)
getSlot(slotType: SlotType): Promise\<NotificationSlot\> getSlot(slotType: SlotType): Promise\<NotificationSlot\>
获取一个通知通道(Promise形式)。 获取一个指定类型的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -567,7 +567,7 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\> ...@@ -567,7 +567,7 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ----------------------------------------------------------- | | -------- | -------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型目前分为社交通信、服务提醒、内容咨询和其他类型。 |
**返回值:** **返回值:**
...@@ -578,9 +578,9 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\> ...@@ -578,9 +578,9 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
**示例:** **示例:**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => { Notification.getSlot(slotType).then((data) => {
console.info("getSlot sucess, data: " + JSON.stringify(data)); console.info("getSlot success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -598,20 +598,20 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void ...@@ -598,20 +598,20 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | -------------------- | | -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 |
**示例:** **示例:**
```js ```js
//getSlots回调 // getSlots回调
function getSlotsCallback(err,data) { function getSlotsCallback(err, data) {
if (err.code) { if (err.code) {
console.info("getSlots failed " + JSON.stringify(err)); console.info("getSlots failed " + JSON.stringify(err));
} else { } else {
console.info("getSlots success"); console.info("getSlots success");
} }
} }
Notification.getSlots(getSlotsCallback) Notification.getSlots(getSlotsCallback);
``` ```
...@@ -634,7 +634,7 @@ getSlots(): Promise\<Array\<NotificationSlot\>> ...@@ -634,7 +634,7 @@ getSlots(): Promise\<Array\<NotificationSlot\>>
```js ```js
Notification.getSlots().then((data) => { Notification.getSlots().then((data) => {
console.info("getSlots sucess, data: " + JSON.stringify(data)); console.info("getSlots success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -644,7 +644,7 @@ Notification.getSlots().then((data) => { ...@@ -644,7 +644,7 @@ Notification.getSlots().then((data) => {
removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
根据通知通道类型删除创建的通知通道(callback形式)。 删除指定类型的通知通道(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -658,7 +658,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void ...@@ -658,7 +658,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//removeSlot回调 // removeSlot回调
function removeSlotCallback(err) { function removeSlotCallback(err) {
if (err.code) { if (err.code) {
console.info("removeSlot failed " + JSON.stringify(err)); console.info("removeSlot failed " + JSON.stringify(err));
...@@ -666,8 +666,8 @@ function removeSlotCallback(err) { ...@@ -666,8 +666,8 @@ function removeSlotCallback(err) {
console.info("removeSlot success"); console.info("removeSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback) Notification.removeSlot(slotType,removeSlotCallback);
``` ```
...@@ -676,7 +676,7 @@ Notification.removeSlot(slotType,removeSlotCallback) ...@@ -676,7 +676,7 @@ Notification.removeSlot(slotType,removeSlotCallback)
removeSlot(slotType: SlotType): Promise\<void\> removeSlot(slotType: SlotType): Promise\<void\>
根据通知通道类型删除创建的通知通道(Promise形式)。 删除指定类型的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -689,9 +689,9 @@ removeSlot(slotType: SlotType): Promise\<void\> ...@@ -689,9 +689,9 @@ removeSlot(slotType: SlotType): Promise\<void\>
**示例:** **示例:**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then(() => { Notification.removeSlot(slotType).then(() => {
console.info("removeSlot sucess"); console.info("removeSlot success");
}); });
``` ```
...@@ -721,7 +721,7 @@ function removeAllCallBack(err) { ...@@ -721,7 +721,7 @@ function removeAllCallBack(err) {
console.info("removeAllSlots success"); console.info("removeAllSlots success");
} }
} }
Notification.removeAllSlots(removeAllCallBack) Notification.removeAllSlots(removeAllCallBack);
``` ```
...@@ -738,7 +738,7 @@ removeAllSlots(): Promise\<void\> ...@@ -738,7 +738,7 @@ removeAllSlots(): Promise\<void\>
```js ```js
Notification.removeAllSlots().then(() => { Notification.removeAllSlots().then(() => {
console.info("removeAllSlots sucess"); console.info("removeAllSlots success");
}); });
``` ```
...@@ -761,13 +761,13 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c ...@@ -761,13 +761,13 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ---------------- | | ---------- | ------------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 订阅信息。 | | info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 通知订阅信息。 |
| callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 | | callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 |
**示例:** **示例:**
```js ```js
//subscribe回调 // subscribe回调
function subscribeCallback(err) { function subscribeCallback(err) {
if (err.code) { if (err.code) {
console.info("subscribe failed " + JSON.stringify(err)); console.info("subscribe failed " + JSON.stringify(err));
...@@ -778,12 +778,12 @@ function subscribeCallback(err) { ...@@ -778,12 +778,12 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
var info = { let info = {
bundleNames: ["bundleName1","bundleName2"] bundleNames: ["bundleName1", "bundleName2"]
} };
Notification.subscribe(subscriber, info, subscribeCallback); Notification.subscribe(subscriber, info, subscribeCallback);
``` ```
...@@ -793,7 +793,7 @@ Notification.subscribe(subscriber, info, subscribeCallback); ...@@ -793,7 +793,7 @@ Notification.subscribe(subscriber, info, subscribeCallback);
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
订阅通知并指定订阅信息(callback形式)。 订阅当前用户下所有应用的通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -821,9 +821,9 @@ function subscribeCallback(err) { ...@@ -821,9 +821,9 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -846,7 +846,7 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ...@@ -846,7 +846,7 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------ | | ---------- | ------------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 订阅信息。 | | info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 通知订阅信息。 |
**示例:** **示例:**
...@@ -854,11 +854,11 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ...@@ -854,11 +854,11 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
Notification.subscribe(subscriber).then(() => { Notification.subscribe(subscriber).then(() => {
console.info("subscribe sucess"); console.info("subscribe success");
}); });
``` ```
...@@ -893,12 +893,12 @@ function unsubscribeCallback(err) { ...@@ -893,12 +893,12 @@ function unsubscribeCallback(err) {
console.info("unsubscribe success"); console.info("unsubscribe success");
} }
} }
function onCancelCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onDisconnect: onDisconnectCallback
} };
Notification.unsubscribe(subscriber, unsubscribeCallback); Notification.unsubscribe(subscriber, unsubscribeCallback);
``` ```
...@@ -925,14 +925,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> ...@@ -925,14 +925,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**示例:** **示例:**
```js ```js
function onCancelCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onDisconnect: onDisconnectCallback
}; };
Notification.unsubscribe(subscriber).then(() => { Notification.unsubscribe(subscriber).then(() => {
console.info("unsubscribe sucess"); console.info("unsubscribe success");
}); });
``` ```
...@@ -942,7 +942,7 @@ Notification.unsubscribe(subscriber).then(() => { ...@@ -942,7 +942,7 @@ Notification.unsubscribe(subscriber).then(() => {
enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
设定指定的通知使能状态(Callback形式)。 设定指定应用的通知使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -954,7 +954,7 @@ enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallbac ...@@ -954,7 +954,7 @@ enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallbac
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设定通知使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定通知使能回调函数。 |
...@@ -968,9 +968,9 @@ function enableNotificationCallback(err) { ...@@ -968,9 +968,9 @@ function enableNotificationCallback(err) {
console.info("enableNotification success"); console.info("enableNotification success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.enableNotification(bundle, false, enableNotificationCallback); Notification.enableNotification(bundle, false, enableNotificationCallback);
``` ```
...@@ -980,7 +980,7 @@ Notification.enableNotification(bundle, false, enableNotificationCallback); ...@@ -980,7 +980,7 @@ Notification.enableNotification(bundle, false, enableNotificationCallback);
enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\> enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\>
设定指定的通知使能状态(Promise形式)。 设定指定应用的通知使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -992,17 +992,17 @@ enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\> ...@@ -992,17 +992,17 @@ enableNotification(bundle: BundleOption, enable: boolean): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.enableNotification(bundle, false).then(() => { Notification.enableNotification(bundle, false).then(() => {
console.info("enableNotification sucess"); console.info("enableNotification success");
}); });
``` ```
...@@ -1012,7 +1012,7 @@ Notification.enableNotification(bundle, false).then(() => { ...@@ -1012,7 +1012,7 @@ Notification.enableNotification(bundle, false).then(() => {
isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
获取指定的通知使能状态(Callback形式)。 获取指定应用的通知使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1024,7 +1024,7 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): ...@@ -1024,7 +1024,7 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 | | callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 |
**示例:** **示例:**
...@@ -1037,9 +1037,9 @@ function isNotificationEnabledCallback(err, data) { ...@@ -1037,9 +1037,9 @@ function isNotificationEnabledCallback(err, data) {
console.info("isNotificationEnabled success"); console.info("isNotificationEnabled success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
``` ```
...@@ -1049,7 +1049,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); ...@@ -1049,7 +1049,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
获取指定的通知使能状态(Promise形式)。 获取指定应用的通知使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1061,22 +1061,22 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> ...@@ -1061,22 +1061,22 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------ | --------------------------------------------------- |
| Promise\<boolean\> | 以Promise形式返回获取指定的通知使能状态的结果。 | | Promise\<boolean\> | 以Promise形式返回获取指定应用的通知使能状态的结果。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle).then((data) => { Notification.isNotificationEnabled(bundle).then((data) => {
console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1132,7 +1132,7 @@ isNotificationEnabled(): Promise\<boolean\> ...@@ -1132,7 +1132,7 @@ isNotificationEnabled(): Promise\<boolean\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
...@@ -1144,7 +1144,7 @@ isNotificationEnabled(): Promise\<boolean\> ...@@ -1144,7 +1144,7 @@ isNotificationEnabled(): Promise\<boolean\>
```js ```js
Notification.isNotificationEnabled().then((data) => { Notification.isNotificationEnabled().then((data) => {
console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1154,7 +1154,7 @@ Notification.isNotificationEnabled().then((data) => { ...@@ -1154,7 +1154,7 @@ Notification.isNotificationEnabled().then((data) => {
displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
设定指定的角标使能状态(Callback形式)。 设定指定应用的角标使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1166,7 +1166,7 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi ...@@ -1166,7 +1166,7 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设定角标使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定角标使能回调函数。 |
...@@ -1180,9 +1180,9 @@ function displayBadgeCallback(err) { ...@@ -1180,9 +1180,9 @@ function displayBadgeCallback(err) {
console.info("displayBadge success"); console.info("displayBadge success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false, displayBadgeCallback); Notification.displayBadge(bundle, false, displayBadgeCallback);
``` ```
...@@ -1192,7 +1192,7 @@ Notification.displayBadge(bundle, false, displayBadgeCallback); ...@@ -1192,7 +1192,7 @@ Notification.displayBadge(bundle, false, displayBadgeCallback);
displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
设定指定的角标使能状态(Promise形式)。 设定指定应用的角标使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1204,17 +1204,17 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> ...@@ -1204,17 +1204,17 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false).then(() => { Notification.displayBadge(bundle, false).then(() => {
console.info("displayBadge sucess"); console.info("displayBadge success");
}); });
``` ```
...@@ -1224,7 +1224,7 @@ Notification.displayBadge(bundle, false).then(() => { ...@@ -1224,7 +1224,7 @@ Notification.displayBadge(bundle, false).then(() => {
isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
获取指定的角标使能状态(Callback形式)。 获取指定应用的角标使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1236,7 +1236,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void ...@@ -1236,7 +1236,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<void\> | 是 | 获取角标使能状态回调函数。 | | callback | AsyncCallback\<void\> | 是 | 获取角标使能状态回调函数。 |
**示例:** **示例:**
...@@ -1249,9 +1249,9 @@ function isBadgeDisplayedCallback(err, data) { ...@@ -1249,9 +1249,9 @@ function isBadgeDisplayedCallback(err, data) {
console.info("isBadgeDisplayed success"); console.info("isBadgeDisplayed success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
``` ```
...@@ -1261,7 +1261,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); ...@@ -1261,7 +1261,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
获取指定的角标使能状态(Promise形式)。 获取指定应用的角标使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1273,22 +1273,22 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> ...@@ -1273,22 +1273,22 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取指定的角标使能状态。 | | Promise\<boolean\> | 以Promise形式返回获取指定应用的角标使能状态。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle).then((data) => { Notification.isBadgeDisplayed(bundle).then((data) => {
console.info("isBadgeDisplayed sucess, data: " + JSON.stringify(data)); console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1298,7 +1298,7 @@ Notification.isBadgeDisplayed(bundle).then((data) => { ...@@ -1298,7 +1298,7 @@ Notification.isBadgeDisplayed(bundle).then((data) => {
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
设定指定包的通知通道状态(Callback形式)。 设定指定应用的通知通道(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1310,7 +1310,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal ...@@ -1310,7 +1310,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | | slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 |
| callback | AsyncCallback\<void\> | 是 | 设定通知通道回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定通知通道回调函数。 |
...@@ -1324,12 +1324,12 @@ function setSlotByBundleCallback(err) { ...@@ -1324,12 +1324,12 @@ function setSlotByBundleCallback(err) {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
``` ```
...@@ -1339,7 +1339,7 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); ...@@ -1339,7 +1339,7 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
设定指定包的通知通道状态(Promise形式)。 设定指定应用的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1351,20 +1351,20 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> ...@@ -1351,20 +1351,20 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| slot | [NotificationSlot](#notificationslot) | 是 | 使能状态。 | | slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot).then(() => { Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("setSlotByBundle sucess"); console.info("setSlotByBundle success");
}); });
``` ```
...@@ -1374,7 +1374,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1374,7 +1374,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
获取指定包的通知通道(Callback形式)。 获取指定应用的所有通知通道(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1386,7 +1386,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati ...@@ -1386,7 +1386,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | 是 | 获取通知通道回调函数。 | | callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | 是 | 获取通知通道回调函数。 |
**示例:** **示例:**
...@@ -1399,9 +1399,9 @@ function getSlotsByBundleCallback(err, data) { ...@@ -1399,9 +1399,9 @@ function getSlotsByBundleCallback(err, data) {
console.info("getSlotsByBundle success"); console.info("getSlotsByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
``` ```
...@@ -1411,7 +1411,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ...@@ -1411,7 +1411,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
获取指定包的通知通道(Promise形式)。 获取指定应用的所有通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1423,22 +1423,22 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> ...@@ -1423,22 +1423,22 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | 以Promise形式返回获取指定的通知通道。 | | Promise<Array\<[NotificationSlot](#notificationslot)\>> | 以Promise形式返回获取指定应用的通知通道。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle).then((data) => { Notification.getSlotsByBundle(bundle).then((data) => {
console.info("getSlotsByBundle sucess, data: " + JSON.stringify(data)); console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1448,7 +1448,7 @@ Notification.getSlotsByBundle(bundle).then((data) => { ...@@ -1448,7 +1448,7 @@ Notification.getSlotsByBundle(bundle).then((data) => {
getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
获取指定包的通知通道数(Callback形式)。 获取指定应用的通知通道数量(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1460,8 +1460,8 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi ...@@ -1460,8 +1460,8 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------- | | -------- | ------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<number\> | 是 | 获取通知通道数回调函数。 | | callback | AsyncCallback\<number\> | 是 | 获取通知通道数回调函数。 |
**示例:** **示例:**
...@@ -1473,9 +1473,9 @@ function getSlotNumByBundleCallback(err, data) { ...@@ -1473,9 +1473,9 @@ function getSlotNumByBundleCallback(err, data) {
console.info("getSlotNumByBundle success"); console.info("getSlotNumByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
``` ```
...@@ -1485,7 +1485,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); ...@@ -1485,7 +1485,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
getSlotNumByBundle(bundle: BundleOption): Promise\<number\> getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
获取指定包的通知通道数(Promise形式)。 获取指定应用的通知通道数量(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1497,22 +1497,22 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\> ...@@ -1497,22 +1497,22 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | 以Promise形式返回获取指定包的通知通道数。 | | Promise\<number\> | 以Promise形式返回获取指定应用的通知通道数量。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle).then((data) => { Notification.getSlotNumByBundle(bundle).then((data) => {
console.info("getSlotNumByBundle sucess, data: " + JSON.stringify(data)); console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1534,7 +1534,7 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -1534,7 +1534,7 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------- | ----------------------------------| ---- | -------------------- | | --------------- | ----------------------------------| ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 |
| reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 |
...@@ -1549,14 +1549,14 @@ function removeCallback(err) { ...@@ -1549,14 +1549,14 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason, removeCallback); Notification.remove(bundle, notificationKey, reason, removeCallback);
``` ```
...@@ -1578,23 +1578,23 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -1578,23 +1578,23 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------- | --------------- | ---- | ---------- | | --------------- | --------------- | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 |
| reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 |
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason).then(() => { Notification.remove(bundle, notificationKey, reason).then(() => {
console.info("remove sucess"); console.info("remove success");
}); });
``` ```
...@@ -1616,14 +1616,14 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): ...@@ -1616,14 +1616,14 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | 是 | 通知唯一ID。 | | hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](#onconsume)回调的入参[SubscribeCallbackData](#subscribecallbackdata)获取其内部[NotificationRequest](#notificationrequest)对象中的hashCode。 |
| reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 |
**示例:** **示例:**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
function removeCallback(err) { function removeCallback(err) {
if (err.code) { if (err.code) {
...@@ -1632,7 +1632,7 @@ function removeCallback(err) { ...@@ -1632,7 +1632,7 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE; let reason = Notification.RemoveReason.CANCEL_REASON_REMOVE;
Notification.remove(hashCode, reason, removeCallback); Notification.remove(hashCode, reason, removeCallback);
``` ```
...@@ -1660,10 +1660,10 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\> ...@@ -1660,10 +1660,10 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
**示例:** **示例:**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(hashCode, reason).then(() => { Notification.remove(hashCode, reason).then(() => {
console.info("remove sucess"); console.info("remove success");
}); });
``` ```
...@@ -1673,7 +1673,7 @@ Notification.remove(hashCode, reason).then(() => { ...@@ -1673,7 +1673,7 @@ Notification.remove(hashCode, reason).then(() => {
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
删除指定的所有通知(Callback形式)。 删除指定应用的所有通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1685,8 +1685,8 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void ...@@ -1685,8 +1685,8 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------- | | -------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定的所有通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定应用的所有通知回调函数。 |
**示例:** **示例:**
...@@ -1698,9 +1698,9 @@ function removeAllCallback(err) { ...@@ -1698,9 +1698,9 @@ function removeAllCallback(err) {
console.info("removeAll success"); console.info("removeAll success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.removeAll(bundle, removeAllCallback); Notification.removeAll(bundle, removeAllCallback);
``` ```
...@@ -1744,7 +1744,7 @@ Notification.removeAll(removeAllCallback); ...@@ -1744,7 +1744,7 @@ Notification.removeAll(removeAllCallback);
removeAll(bundle?: BundleOption): Promise\<void\> removeAll(bundle?: BundleOption): Promise\<void\>
删除所有通知(Promise形式)。 删除指定应用的所有通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1756,13 +1756,14 @@ removeAll(bundle?: BundleOption): Promise\<void\> ...@@ -1756,13 +1756,14 @@ removeAll(bundle?: BundleOption): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 否 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 否 | 指定应用的包信息。 |
**示例:** **示例:**
```js ```js
// 不指定应用时,删除所有通知
Notification.removeAll().then(() => { Notification.removeAll().then(() => {
console.info("removeAll sucess"); console.info("removeAll success");
}); });
``` ```
...@@ -1770,7 +1771,7 @@ Notification.removeAll().then(() => { ...@@ -1770,7 +1771,7 @@ Notification.removeAll().then(() => {
removeAll(userId: number, callback: AsyncCallback\<void>): void removeAll(userId: number, callback: AsyncCallback\<void>): void
删除所有通知(callback形式)。 删除指定用户下的所有通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1782,8 +1783,8 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void ...@@ -1782,8 +1783,8 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback\<void\> | 是 | 删除所有通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定用户所有通知回调函数。 |
**示例:** **示例:**
...@@ -1796,8 +1797,7 @@ function removeAllCallback(err) { ...@@ -1796,8 +1797,7 @@ function removeAllCallback(err) {
} }
} }
var userId = 1 let userId = 1;
Notification.removeAll(userId, removeAllCallback); Notification.removeAll(userId, removeAllCallback);
``` ```
...@@ -1805,7 +1805,7 @@ Notification.removeAll(userId, removeAllCallback); ...@@ -1805,7 +1805,7 @@ Notification.removeAll(userId, removeAllCallback);
removeAll(userId: number): Promise\<void> removeAll(userId: number): Promise\<void>
删除所有通知(Promise形式)。 删除指定用户下的所有通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1817,22 +1817,15 @@ removeAll(userId: number): Promise\<void> ...@@ -1817,22 +1817,15 @@ removeAll(userId: number): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**示例:** **示例:**
```js ```js
function removeAllCallback(err) { let userId = 1;
if (err.code) { Notification.removeAll(userId).then(() => {
console.info("removeAll failed " + JSON.stringify(err)); console.info("removeAll success");
} else { });
console.info("removeAll success");
}
}
var userId = 1
Notification.removeAll(userId, removeAllCallback);
``` ```
...@@ -1840,7 +1833,7 @@ Notification.removeAll(userId, removeAllCallback); ...@@ -1840,7 +1833,7 @@ Notification.removeAll(userId, removeAllCallback);
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
获取活动通知(Callback形式)。 获取当前未删除的所有通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1874,7 +1867,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ...@@ -1874,7 +1867,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
获取活动通知(Promise形式)。 获取当前未删除的所有通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1892,7 +1885,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notification ...@@ -1892,7 +1885,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notification
```js ```js
Notification.getAllActiveNotifications().then((data) => { Notification.getAllActiveNotifications().then((data) => {
console.info("getAllActiveNotifications sucess, data: " + JSON.stringify(data)); console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1902,7 +1895,7 @@ Notification.getAllActiveNotifications().then((data) => { ...@@ -1902,7 +1895,7 @@ Notification.getAllActiveNotifications().then((data) => {
getActiveNotificationCount(callback: AsyncCallback\<number\>): void getActiveNotificationCount(callback: AsyncCallback\<number\>): void
获取当前应用的活动通知数(Callback形式)。 获取当前应用未删除的通知数(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1910,7 +1903,7 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void ...@@ -1910,7 +1903,7 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<number\> | 是 | 获取活动通知数回调函数。 | | callback | AsyncCallback\<number\> | 是 | 获取未删除通知数回调函数。 |
**示例:** **示例:**
...@@ -1932,21 +1925,21 @@ Notification.getActiveNotificationCount(getActiveNotificationCountCallback); ...@@ -1932,21 +1925,21 @@ Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
getActiveNotificationCount(): Promise\<number\> getActiveNotificationCount(): Promise\<number\>
获取当前应用的活动通知数(Promise形式)。 获取当前应用未删除的通知数(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------- |
| Promise\<number\> | 以Promise形式返回获取当前应用的活动通知数。 | | Promise\<number\> | 以Promise形式返回获取当前应用未删除通知数。 |
**示例:** **示例:**
```js ```js
Notification.getActiveNotificationCount().then((data) => { Notification.getActiveNotificationCount().then((data) => {
console.info("getActiveNotificationCount sucess, data: " + JSON.stringify(data)); console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1956,7 +1949,7 @@ Notification.getActiveNotificationCount().then((data) => { ...@@ -1956,7 +1949,7 @@ Notification.getActiveNotificationCount().then((data) => {
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
获取当前应用的活动通知(Callback形式)。 获取当前应用未删除的通知列表(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1964,7 +1957,7 @@ getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): v ...@@ -1964,7 +1957,7 @@ getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): v
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是 | 获取当前应用的活动通知回调函数。 | | callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是 | 获取当前应用通知列表回调函数。 |
**示例:** **示例:**
...@@ -1986,21 +1979,21 @@ Notification.getActiveNotifications(getActiveNotificationsCallback); ...@@ -1986,21 +1979,21 @@ Notification.getActiveNotifications(getActiveNotificationsCallback);
getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
获取当前应用的活动通知(Promise形式)。 获取当前应用未删除的通知列表(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------------------------------------------------ | --------------------------------------- |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | 以Promise形式返回获取当前应用的活动通知。 | | Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | 以Promise形式返回获取当前应用通知列表。 |
**示例:** **示例:**
```js ```js
Notification.getActiveNotifications().then((data) => { Notification.getActiveNotifications().then((data) => {
console.info("removeGroupByBundle sucess, data: " + JSON.stringify(data)); console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2010,7 +2003,7 @@ Notification.getActiveNotifications().then((data) => { ...@@ -2010,7 +2003,7 @@ Notification.getActiveNotifications().then((data) => {
cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
取消本应用指定组通知(Callback形式)。 取消本应用指定组下的通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2018,8 +2011,8 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void ...@@ -2018,8 +2011,8 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | --------------------- | ---- | ---------------------------- | | --------- | --------------------- | ---- | ---------------------------- |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](#notificationrequest)对象指定。 |
| callback | AsyncCallback\<void\> | 是 | 取消本应用指定组通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 取消本应用指定组下通知的回调函数。 |
**示例:** **示例:**
...@@ -2032,7 +2025,7 @@ function cancelGroupCallback(err) { ...@@ -2032,7 +2025,7 @@ function cancelGroupCallback(err) {
} }
} }
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName, cancelGroupCallback); Notification.cancelGroup(groupName, cancelGroupCallback);
``` ```
...@@ -2043,7 +2036,7 @@ Notification.cancelGroup(groupName, cancelGroupCallback); ...@@ -2043,7 +2036,7 @@ Notification.cancelGroup(groupName, cancelGroupCallback);
cancelGroup(groupName: string): Promise\<void\> cancelGroup(groupName: string): Promise\<void\>
取消本应用指定组通知(Promise形式)。 取消本应用指定组下的通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2051,14 +2044,14 @@ cancelGroup(groupName: string): Promise\<void\> ...@@ -2051,14 +2044,14 @@ cancelGroup(groupName: string): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | -------------- | | --------- | ------ | ---- | -------------- |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称。 |
**示例:** **示例:**
```js ```js
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => { Notification.cancelGroup(groupName).then(() => {
console.info("cancelGroup sucess"); console.info("cancelGroup success");
}); });
``` ```
...@@ -2068,7 +2061,7 @@ Notification.cancelGroup(groupName).then(() => { ...@@ -2068,7 +2061,7 @@ Notification.cancelGroup(groupName).then(() => {
removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
删除指定应用指定组通知(Callback形式)。 删除指定应用的指定组下的通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2080,9 +2073,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall ...@@ -2080,9 +2073,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | --------------------- | ---- | ---------------------------- | | --------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称。 |
| callback | AsyncCallback\<void\> | 是 | 删除本应用指定组通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定应用指定组下通知的回调函数。 |
**示例:** **示例:**
...@@ -2095,8 +2088,8 @@ function removeGroupByBundleCallback(err) { ...@@ -2095,8 +2088,8 @@ function removeGroupByBundleCallback(err) {
} }
} }
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
``` ```
...@@ -2107,7 +2100,7 @@ Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCal ...@@ -2107,7 +2100,7 @@ Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCal
removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
删除指定应用指定组通知(Promise形式)。 删除指定应用的指定组下的通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2119,16 +2112,16 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> ...@@ -2119,16 +2112,16 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------ | ---- | -------------- | | --------- | ------------ | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称。 |
**示例:** **示例:**
```js ```js
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => { Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
console.info("removeGroupByBundle sucess"); console.info("removeGroupByBundle success");
}); });
``` ```
...@@ -2164,11 +2157,11 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2164,11 +2157,11 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
``` ```
...@@ -2179,7 +2172,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); ...@@ -2179,7 +2172,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
设置免打扰时间接口(Promise形式)。 设置免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2196,13 +2189,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> ...@@ -2196,13 +2189,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
**示例:** **示例:**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("setDoNotDisturbDate sucess"); console.info("setDoNotDisturbDate success");
}); });
``` ```
...@@ -2224,7 +2217,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb ...@@ -2224,7 +2217,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------- | | -------- | --------------------- | ---- | ---------------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | | date | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 设置免打扰时间的用户ID。 |
| callback | AsyncCallback\<void\> | 是 | 设置免打扰时间回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置免打扰时间回调函数。 |
**示例:** **示例:**
...@@ -2238,14 +2231,13 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2238,14 +2231,13 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1
let userId = 1
Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
``` ```
...@@ -2255,7 +2247,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCa ...@@ -2255,7 +2247,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCa
setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
指定用户设置免打扰时间接口(Promise形式)。 指定用户设置免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2268,21 +2260,21 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> ...@@ -2268,21 +2260,21 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------- | ---- | -------------- | | ------ | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | | date | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 设置免打扰时间的用户ID。 |
**示例:** **示例:**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1;
Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
console.info("setDoNotDisturbDate sucess"); console.info("setDoNotDisturbDate success");
}); });
``` ```
...@@ -2291,7 +2283,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { ...@@ -2291,7 +2283,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
查询免打扰时间接口(Callback形式)。 查询免打扰时间(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2308,7 +2300,7 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void ...@@ -2308,7 +2300,7 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
**示例:** **示例:**
```js ```js
function getDoNotDisturbDateCallback(err,data) { function getDoNotDisturbDateCallback(err, data) {
if (err.code) { if (err.code) {
console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
} else { } else {
...@@ -2325,7 +2317,7 @@ Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); ...@@ -2325,7 +2317,7 @@ Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
查询免打扰时间接口(Promise形式)。 查询免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2335,15 +2327,15 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> ...@@ -2335,15 +2327,15 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------------------------------------- | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 | | Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询到的免打扰时间。 |
**示例:** **示例:**
```js ```js
Notification.getDoNotDisturbDate().then((data) => { Notification.getDoNotDisturbDate().then((data) => {
console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2352,7 +2344,7 @@ Notification.getDoNotDisturbDate().then((data) => { ...@@ -2352,7 +2344,7 @@ Notification.getDoNotDisturbDate().then((data) => {
getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
指定用户查询免打扰时间接口(Callback形式)。 查询指定用户的免打扰时间(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2365,7 +2357,7 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>) ...@@ -2365,7 +2357,7 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------------------- | | -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | 是 | 查询免打扰时间回调函数。 | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | 是 | 查询免打扰时间回调函数。 |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 用户ID。 |
**示例:** **示例:**
...@@ -2378,7 +2370,7 @@ function getDoNotDisturbDateCallback(err,data) { ...@@ -2378,7 +2370,7 @@ function getDoNotDisturbDateCallback(err,data) {
} }
} }
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
``` ```
...@@ -2389,7 +2381,7 @@ Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); ...@@ -2389,7 +2381,7 @@ Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
指定用户查询免打扰时间接口(Promise形式)。 查询指定用户的免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2401,21 +2393,21 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> ...@@ -2401,21 +2393,21 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------------------- | | -------- | --------------------------------- | ---- | ---------------------- |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 用户ID。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------------------------------------- | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 | | Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询到的免打扰时间。 |
**示例:** **示例:**
```js ```js
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId).then((data) => { Notification.getDoNotDisturbDate(userId).then((data) => {
console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2424,7 +2416,7 @@ Notification.getDoNotDisturbDate(userId).then((data) => { ...@@ -2424,7 +2416,7 @@ Notification.getDoNotDisturbDate(userId).then((data) => {
supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
查询是否支持勿扰模式功能(Callback形式)。 查询是否支持免打扰功能(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2436,7 +2428,7 @@ supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void ...@@ -2436,7 +2428,7 @@ supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------------- | | -------- | ------------------------ | ---- | -------------------------------- |
| callback | AsyncCallback\<boolean\> | 是 | 查询是否支持勿扰模式功能回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 查询是否支持免打扰功能回调函数。 |
**示例:** **示例:**
...@@ -2458,7 +2450,7 @@ Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); ...@@ -2458,7 +2450,7 @@ Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
supportDoNotDisturbMode(): Promise\<boolean\> supportDoNotDisturbMode(): Promise\<boolean\>
查询是否支持勿扰模式功能(Promise形式)。 查询是否支持免打扰功能(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2470,13 +2462,13 @@ supportDoNotDisturbMode(): Promise\<boolean\> ...@@ -2470,13 +2462,13 @@ supportDoNotDisturbMode(): Promise\<boolean\>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取是否支持勿扰模式功能的结果。 | | Promise\<boolean\> | 以Promise形式返回获取是否支持免打扰功能的结果。 |
**示例:** **示例:**
```js ```js
Notification.supportDoNotDisturbMode().then((data) => { Notification.supportDoNotDisturbMode().then((data) => {
console.info("supportDoNotDisturbMode sucess, data: " + JSON.stringify(data)); console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2500,7 +2492,7 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi ...@@ -2500,7 +2492,7 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi
**示例:** **示例:**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
function isSupportTemplateCallback(err, data) { function isSupportTemplateCallback(err, data) {
if (err.code) { if (err.code) {
console.info("isSupportTemplate failed " + JSON.stringify(err)); console.info("isSupportTemplate failed " + JSON.stringify(err));
...@@ -2537,7 +2529,7 @@ isSupportTemplate(templateName: string): Promise\<boolean\> ...@@ -2537,7 +2529,7 @@ isSupportTemplate(templateName: string): Promise\<boolean\>
**示例:** **示例:**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
Notification.isSupportTemplate(templateName).then((data) => { Notification.isSupportTemplate(templateName).then((data) => {
console.info("isSupportTemplate success, data: " + JSON.stringify(data)); console.info("isSupportTemplate success, data: " + JSON.stringify(data));
...@@ -2567,7 +2559,7 @@ function requestEnableNotificationCallback(err) { ...@@ -2567,7 +2559,7 @@ function requestEnableNotificationCallback(err) {
if (err.code) { if (err.code) {
console.info("requestEnableNotification failed " + JSON.stringify(err)); console.info("requestEnableNotification failed " + JSON.stringify(err));
} else { } else {
console.info("requestEnableNotification success");
} }
}; };
...@@ -2587,10 +2579,9 @@ requestEnableNotification(): Promise\<void\> ...@@ -2587,10 +2579,9 @@ requestEnableNotification(): Promise\<void\>
**示例:** **示例:**
```javascript ```javascript
Notification.requestEnableNotification() Notification.requestEnableNotification().then(() => {
.then(() => { console.info("requestEnableNotification success");
console.info("requestEnableNotification sucess"); });
});
``` ```
...@@ -2610,7 +2601,7 @@ enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void ...@@ -2610,7 +2601,7 @@ enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| enable | boolean | 是 | 是否支持。<br/>true 支持。<br/>false 不支持。| | enable | boolean | 是 | 是否支持。 |
| callback | AsyncCallback\<void\> | 是 | 设置设备是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置设备是否支持分布式通知的回调函数。 |
**示例:** **示例:**
...@@ -2624,7 +2615,7 @@ function enabledNotificationCallback(err) { ...@@ -2624,7 +2615,7 @@ function enabledNotificationCallback(err) {
} }
}; };
var enable = true let enable = true;
Notification.enableDistributed(enable, enabledNotificationCallback); Notification.enableDistributed(enable, enabledNotificationCallback);
``` ```
...@@ -2647,17 +2638,15 @@ enableDistributed(enable: boolean): Promise\<void> ...@@ -2647,17 +2638,15 @@ enableDistributed(enable: boolean): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| enable | boolean | 是 | 是否支持。<br/>true 支持。<br/>false 不支持。| | enable | boolean | 是 | 是否支持。 |
**示例:** **示例:**
```javascript ```javascript
var enable = true let enable = true;
Notification.enableDistributed(enable).then(() => {
Notification.enableDistributed(enable) console.info("enableDistributed success");
.then(() => { });
console.info("enableDistributed sucess");
});
``` ```
...@@ -2665,7 +2654,7 @@ Notification.enableDistributed(enable) ...@@ -2665,7 +2654,7 @@ Notification.enableDistributed(enable)
isDistributedEnabled(callback: AsyncCallback\<boolean>): void isDistributedEnabled(callback: AsyncCallback\<boolean>): void
获取设备是否支持分布式通知(Callback形式)。 查询设备是否支持分布式通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2695,23 +2684,22 @@ Notification.isDistributedEnabled(isDistributedEnabledCallback); ...@@ -2695,23 +2684,22 @@ Notification.isDistributedEnabled(isDistributedEnabledCallback);
isDistributedEnabled(): Promise\<boolean> isDistributedEnabled(): Promise\<boolean>
获取设备是否支持分布式通知(Promise形式)。 查询设备是否支持分布式通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------ | --------------- | | ------------------ | --------------------------------------------- |
| Promise\<boolean\> | Promise方式返回设备是否支持分布式通知的结果。<br/>true 支持。<br/>false 不支持。 | | Promise\<boolean\> | Promise方式返回设备是否支持分布式通知的结果。 |
**示例:** **示例:**
```javascript ```javascript
Notification.isDistributedEnabled() Notification.isDistributedEnabled().then((data) => {
.then((data) => { console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
console.info("isDistributedEnabled sucess, data: " + JSON.stringify(data)); });
});
``` ```
...@@ -2719,7 +2707,7 @@ Notification.isDistributedEnabled() ...@@ -2719,7 +2707,7 @@ Notification.isDistributedEnabled()
enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
根据应用的包设置应用程序是否支持分布式通知(Callback形式)。 设置指定应用是否支持分布式通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2731,7 +2719,7 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: Async ...@@ -2731,7 +2719,7 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: Async
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| enable | boolean | 是 | 是否支持。 | | enable | boolean | 是 | 是否支持。 |
| callback | AsyncCallback\<void\> | 是 | 应用程序是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 应用程序是否支持分布式通知的回调函数。 |
...@@ -2746,11 +2734,11 @@ function enableDistributedByBundleCallback(err) { ...@@ -2746,11 +2734,11 @@ function enableDistributedByBundleCallback(err) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true;
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback); Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
``` ```
...@@ -2761,7 +2749,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle ...@@ -2761,7 +2749,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle
enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void> enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
根据应用的包设置应用程序是否支持分布式通知(Promise形式)。 设置指定应用是否支持分布式通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2779,16 +2767,14 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void> ...@@ -2779,16 +2767,14 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
**示例:** **示例:**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true
Notification.enableDistributedByBundle(bundle, enable) let enable = true;
.then(() => { Notification.enableDistributedByBundle(bundle, enable).then(() => {
console.info("enableDistributedByBundle sucess"); console.info("enableDistributedByBundle success");
}); });
``` ```
## Notification.isDistributedEnabledByBundle<sup>8+</sup> ## Notification.isDistributedEnabledByBundle<sup>8+</sup>
...@@ -2808,7 +2794,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool ...@@ -2808,7 +2794,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 |
| callback | AsyncCallback\<boolean\> | 是 | 应用程序是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 查询指定应用是否支持分布式通知的回调函数。 |
**示例:** **示例:**
...@@ -2821,9 +2807,9 @@ function isDistributedEnabledByBundleCallback(err, data) { ...@@ -2821,9 +2807,9 @@ function isDistributedEnabledByBundleCallback(err, data) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
``` ```
...@@ -2834,7 +2820,7 @@ Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCa ...@@ -2834,7 +2820,7 @@ Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCa
isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
根据应用的包获取应用程序是否支持分布式通知(Promise形式)。 查询指定应用是否支持分布式通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2850,21 +2836,20 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> ...@@ -2850,21 +2836,20 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------ | --------------- | | ------------------ | ------------------------------------------------- |
| Promise\<boolean\> | Promise方式返回应用程序是否支持分布式通知的结果。<br/>true 支持。<br/>false 不支持。 | | Promise\<boolean\> | Promise方式返回指定应用是否支持分布式通知的结果。 |
**示例:** **示例:**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle) Notification.isDistributedEnabledByBundle(bundle).then((data) => {
.then((data) => { console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
console.info("isDistributedEnabledByBundle sucess, data: " + JSON.stringify(data)); });
});
``` ```
...@@ -2884,7 +2869,7 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void ...@@ -2884,7 +2869,7 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | -------------------------- | | -------- | --------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | 是 | 获取通知提醒方式的回调函数。 | | callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | 是 | 获取通知提醒方式的回调函数。 |
**示例:** **示例:**
...@@ -2918,15 +2903,14 @@ getDeviceRemindType(): Promise\<DeviceRemindType\> ...@@ -2918,15 +2903,14 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
| 类型 | 说明 | | 类型 | 说明 |
| ------------------ | --------------- | | ------------------ | --------------- |
| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise方式返回通知的提醒方式的结果。 | | Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise方式返回获取通知提醒方式的结果。 |
**示例:** **示例:**
```javascript ```javascript
Notification.getDeviceRemindType() Notification.getDeviceRemindType().then((data) => {
.then((data) => { console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data)); });
});
``` ```
...@@ -2944,18 +2928,18 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ...@@ -2944,18 +2928,18 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | | -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback | 是 | 发布代理通知的回调方法。 | | callback | AsyncCallback | 是 | 发布代理通知的回调方法。 |
**示例:** **示例:**
```js ```js
//publishAsBundle回调 // publishAsBundle回调
function publishAsBundleCallback(err) { function callback(err) {
if (err.code) { if (err.code) {
console.info("publishAsBundle failed " + JSON.stringify(err)); console.info("publishAsBundle failed " + JSON.stringify(err));
} else { } else {
...@@ -2963,11 +2947,11 @@ function publishAsBundleCallback(err) { ...@@ -2963,11 +2947,11 @@ function publishAsBundleCallback(err) {
} }
} }
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
//通知Request对象 // NotificationRequest对象
let notificationRequest = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -2977,9 +2961,9 @@ let notificationRequest = { ...@@ -2977,9 +2961,9 @@ let notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback); Notification.publishAsBundle(request, representativeBundle, userId, callback);
``` ```
## Notification.publishAsBundle<sup>9+</sup> ## Notification.publishAsBundle<sup>9+</sup>
...@@ -2999,19 +2983,19 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ...@@ -2999,19 +2983,19 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**示例:** **示例:**
```js ```js
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
//通知Request对象 // NotificationRequest对象
var notificationRequest = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -3021,10 +3005,10 @@ var notificationRequest = { ...@@ -3021,10 +3005,10 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => { Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle sucess"); console.info("publishAsBundle success");
}); });
``` ```
...@@ -3048,13 +3032,13 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac ...@@ -3048,13 +3032,13 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
| -------------------- | ------------- | ---- | ------------------------ | | -------------------- | ------------- | ---- | ------------------------ |
| id | number | 是 | 通知ID。 | | id | number | 是 | 通知ID。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback | 是 | 取消代理通知的回调方法。 | | callback | AsyncCallback | 是 | 取消代理通知的回调方法。 |
**示例:** **示例:**
```js ```js
//cancelAsBundle // cancelAsBundle
function cancelAsBundleCallback(err) { function cancelAsBundleCallback(err) {
if (err.code) { if (err.code) {
console.info("cancelAsBundle failed " + JSON.stringify(err)); console.info("cancelAsBundle failed " + JSON.stringify(err));
...@@ -3063,9 +3047,9 @@ function cancelAsBundleCallback(err) { ...@@ -3063,9 +3047,9 @@ function cancelAsBundleCallback(err) {
} }
} }
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
``` ```
...@@ -3074,7 +3058,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallb ...@@ -3074,7 +3058,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallb
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\> cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
发布代理通知(Promise形式)。 取消代理通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3090,15 +3074,15 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis ...@@ -3090,15 +3074,15 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis
| -------------------- | ------ | ---- | ------------------ | | -------------------- | ------ | ---- | ------------------ |
| id | number | 是 | 通知ID。 | | id | number | 是 | 通知ID。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**示例:** **示例:**
```js ```js
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success"); console.info("cancelAsBundle success");
...@@ -3109,7 +3093,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { ...@@ -3109,7 +3093,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
定指定类型的渠道使能状态(Callback形式)。 置指定应用的指定渠道类型的使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3121,15 +3105,15 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, ca ...@@ -3121,15 +3105,15 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, ca
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 指定渠道类型。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设渠道使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设渠道使能回调函数。 |
**示例:** **示例:**
```js ```js
//enableNotificationSlot // enableNotificationSlot
function enableSlotCallback(err) { function enableSlotCallback(err) {
if (err.code) { if (err.code) {
console.info("enableNotificationSlot failed " + JSON.stringify(err)); console.info("enableNotificationSlot failed " + JSON.stringify(err));
...@@ -3149,7 +3133,7 @@ Notification.enableNotificationSlot( ...@@ -3149,7 +3133,7 @@ Notification.enableNotificationSlot(
enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void>
定指定类型的渠道使能状态(Promise形式)。 置指定应用的指定渠道类型的使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3161,27 +3145,25 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): P ...@@ -3161,27 +3145,25 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): P
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**示例:** **示例:**
```js ```js
//enableNotificationSlot // enableNotificationSlot
Notification.enableNotificationSlot( Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", },
{ bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => {
Notification.SlotType.SOCIAL_COMMUNICATION, console.info("enableNotificationSlot success");
true).then(() => { });
console.info("enableNotificationSlot sucess");
});
``` ```
## Notification.isNotificationSlotEnabled <sup>9+</sup> ## Notification.isNotificationSlotEnabled <sup>9+</sup>
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
获取指定类型的渠道使能状态(Callback形式)。 获取指定应用的指定渠道类型的使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3193,14 +3175,14 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC ...@@ -3193,14 +3175,14 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
| callback | AsyncCallback\<boolean\> | 是 | 设定渠道使能回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 获取渠道使能状态回调函数。 |
**示例:** **示例:**
```js ```js
//isNotificationSlotEnabled // isNotificationSlotEnabled
function getEnableSlotCallback(err, data) { function getEnableSlotCallback(err, data) {
if (err.code) { if (err.code) {
console.info("isNotificationSlotEnabled failed " + JSON.stringify(err)); console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
...@@ -3219,7 +3201,7 @@ Notification.isNotificationSlotEnabled( ...@@ -3219,7 +3201,7 @@ Notification.isNotificationSlotEnabled(
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\> isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
获取指定类型的渠道使能状态(Promise形式)。 获取指定应用的指定渠道类型的使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3231,25 +3213,23 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea ...@@ -3231,25 +3213,23 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------ | ------------------------------- |
| Promise\<boolean\> | 以Promise形式返回指定类型的渠道使能状态。 | | Promise\<boolean\> | 以Promise形式返回渠道使能状态。 |
**示例:** **示例:**
```js ```js
//isNotificationSlotEnabled // isNotificationSlotEnabled
Notification.isNotificationSlotEnabled( Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
{ bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
Notification.SlotType.SOCIAL_COMMUNICATION console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
).then((data) => { });
console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
``` ```
...@@ -3269,8 +3249,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: ...@@ -3269,8 +3249,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
| enable | boolean | 是 | 是否启用。<br>true:启用。<br>false:禁用。 | | enable | boolean | 是 | 是否启用。 |
| callback | AsyncCallback\<void\> | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。 |
**示例:** **示例:**
...@@ -3279,7 +3259,7 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: ...@@ -3279,7 +3259,7 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
let userId = 100; let userId = 100;
let enable = true; let enable = true;
function setSyncNotificationEnabledWithoutAppCallback(err) { function callback(err) {
if (err.code) { if (err.code) {
console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err)); console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
} else { } else {
...@@ -3287,7 +3267,7 @@ function setSyncNotificationEnabledWithoutAppCallback(err) { ...@@ -3287,7 +3267,7 @@ function setSyncNotificationEnabledWithoutAppCallback(err) {
} }
} }
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback); Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
``` ```
...@@ -3307,8 +3287,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\< ...@@ -3307,8 +3287,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
| enable | boolean | 是 | 是否启用。<br>true:启用。<br>false:禁用。 | | enable | boolean | 是 | 是否启用。 |
**返回值:** **返回值:**
...@@ -3322,13 +3302,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\< ...@@ -3322,13 +3302,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
let userId = 100; let userId = 100;
let enable = true; let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable) Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
.then(() => { console.info('setSyncNotificationEnabledWithoutApp success');
console.info('setSyncNotificationEnabledWithoutApp'); }).catch((err) => {
}) console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
.catch((err) => { });
console.info('setSyncNotificationEnabledWithoutApp, err:', err);
});
``` ```
...@@ -3336,7 +3314,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable) ...@@ -3336,7 +3314,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable)
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
获取是否同步通知到未安装应用程序的设备(callback形式)。 获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3348,19 +3326,19 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo ...@@ -3348,19 +3326,19 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback\<boolean\> | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。<br>true: 是。<br>false: 否。 | | callback | AsyncCallback\<boolean\> | 是 | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数。 |
**示例:** **示例:**
```js ```js
let userId = 100; let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(data, err) { function getSyncNotificationEnabledWithoutAppCallback(err, data) {
if (err) { if (err) {
console.info('getSyncNotificationEnabledWithoutAppCallback, err' + err); console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
} else { } else {
console.info('getSyncNotificationEnabledWithoutAppCallback, data' + data); console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
} }
} }
...@@ -3372,7 +3350,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEna ...@@ -3372,7 +3350,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEna
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean> getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
获取是否同步通知到未安装应用程序的设备(Promise形式)。 获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3384,33 +3362,30 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean> ...@@ -3384,33 +3362,30 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取是否同步通知到未安装应用程序的设备的结果。<br>true: 是。<br>false: 否。 | | Promise\<boolean\> | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果。 |
**示例:** **示例:**
```js ```js
let userId = 100; let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
Notification.getSyncNotificationEnabledWithoutApp(userId) console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
.then((data) => { }).catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, data:', data); console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
}) });
.catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:', err);
});
``` ```
## NotificationSubscriber ## NotificationSubscriber
提供订阅者接收到新通知或取消通知时的回调方法。 作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
...@@ -3418,7 +3393,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3418,7 +3393,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
接收通知回调函数。 接收到新通知的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3428,7 +3403,7 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void ...@@ -3428,7 +3403,7 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | | data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 接收到的通知信息。 |
**示例:** **示例:**
...@@ -3442,12 +3417,11 @@ function subscribeCallback(err) { ...@@ -3442,12 +3417,11 @@ function subscribeCallback(err) {
}; };
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info('===> onConsume in test');
let req = data.request; let req = data.request;
console.info('===> onConsume callback req.id:' + req.id); console.info('===> onConsume callback req.id:' + req.id);
}; };
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
...@@ -3458,7 +3432,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3458,7 +3432,7 @@ Notification.subscribe(subscriber, subscribeCallback);
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
删除通知回调函数。 取消通知的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3468,7 +3442,7 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void ...@@ -3468,7 +3442,7 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | | data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 需要取消的通知信息。 |
**示例:** **示例:**
...@@ -3482,12 +3456,11 @@ function subscribeCallback(err) { ...@@ -3482,12 +3456,11 @@ function subscribeCallback(err) {
}; };
function onCancelCallback(data) { function onCancelCallback(data) {
console.info('===> onCancel in test');
let req = data.request; let req = data.request;
console.info('===> onCancel callback req.id:' + req.id); console.info('===> onCancel callback req.id:' + req.id);
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
...@@ -3498,7 +3471,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3498,7 +3471,7 @@ Notification.subscribe(subscriber, subscribeCallback);
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
更新通知排序回调函数。 更新通知排序回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3508,7 +3481,7 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void ...@@ -3508,7 +3481,7 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 回调返回接收到的通知信息。 | | data | [NotificationSortingMap](#notificationsortingmap) | 是 | 最新的通知排序列表。 |
**示例:** **示例:**
...@@ -3521,11 +3494,11 @@ function subscribeCallback(err) { ...@@ -3521,11 +3494,11 @@ function subscribeCallback(err) {
} }
}; };
function onUpdateCallback() { function onUpdateCallback(map) {
console.info('===> onUpdate in test'); console.info('===> onUpdateCallback map:' + JSON.stringify(map));
} }
var subscriber = { let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
...@@ -3536,7 +3509,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3536,7 +3509,7 @@ Notification.subscribe(subscriber, subscribeCallback);
onConnect?:() => void onConnect?:() => void
注册订阅回调函数。 订阅完成的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3557,7 +3530,7 @@ function onConnectCallback() { ...@@ -3557,7 +3530,7 @@ function onConnectCallback() {
console.info('===> onConnect in test'); console.info('===> onConnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
...@@ -3568,7 +3541,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3568,7 +3541,7 @@ Notification.subscribe(subscriber, subscribeCallback);
onDisconnect?:() => void onDisconnect?:() => void
取消订阅回调函数。 取消订阅回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3584,16 +3557,30 @@ function subscribeCallback(err) { ...@@ -3584,16 +3557,30 @@ function subscribeCallback(err) {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
}; };
function unsubscribeCallback(err) {
if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err));
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() { function onDisconnectCallback() {
console.info('===> onDisconnect in test'); console.info('===> onDisconnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
// 订阅通知后会收到onConnect回调
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
// 取消订阅后会收到onDisconnect回调
Notification.unsubscribe(subscriber, unsubscribeCallback);
``` ```
### onDestroy ### onDestroy
...@@ -3621,7 +3608,7 @@ function onDestroyCallback() { ...@@ -3621,7 +3608,7 @@ function onDestroyCallback() {
console.info('===> onDestroy in test'); console.info('===> onDestroy in test');
} }
var subscriber = { let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
...@@ -3632,7 +3619,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3632,7 +3619,7 @@ Notification.subscribe(subscriber, subscribeCallback);
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void
免打扰时间选项变更回调函数。 免打扰时间选项发生变更时的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3654,15 +3641,24 @@ function subscribeCallback(err) { ...@@ -3654,15 +3641,24 @@ function subscribeCallback(err) {
} }
}; };
function onDoNotDisturbDateChangeCallback() { function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange in test'); console.info('===> onDoNotDisturbDateChange:' + mode);
} }
var subscriber = { let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(),
end: new Date(2021, 11, 15, 18, 0)
}
// 设置一个新的免打扰时间选项时触发onDoNotDisturbDateChange回调
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("setDoNotDisturbDate sucess");
});
``` ```
...@@ -3694,16 +3690,23 @@ function subscribeCallback(err) { ...@@ -3694,16 +3690,23 @@ function subscribeCallback(err) {
}; };
function onEnabledNotificationChangedCallback(callbackData) { function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: ", callbackData.bundle); console.info("bundle: " + callbackData.bundle);
console.info("uid: ", callbackData.uid); console.info("uid: " + callbackData.uid);
console.info("enable: ", callbackData.enable); console.info("enable: " + callbackData.enable);
}; };
var subscriber = { let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
let bundle = {
bundle: "bundleName1",
}
// 设置指定应用通知使能状态触发onEnabledNotificationChanged回调
Notification.enableNotification(bundle, false).then(() => {
console.info("enableNotification sucess");
});
``` ```
## SubscribeCallbackData ## SubscribeCallbackData
...@@ -3715,7 +3718,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3715,7 +3718,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ------------------------------------------------- | ---- | --- | -------- | | --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 否 | 通知内容。 | | request | [NotificationRequest](#notificationrequest) | 是 | 否 | 通知内容。 |
| sortingMap | [NotificationSortingMap](#notificationsortingmap) | 是 | 否 | 排序信息。 | | sortingMap | [NotificationSortingMap](#notificationsortingmap) | 是 | 否 | 通知排序信息。 |
| reason | number | 是 | 否 | 删除原因。 | | reason | number | 是 | 否 | 删除原因。 |
| sound | string | 是 | 否 | 通知声音。 | | sound | string | 是 | 否 | 通知声音。 |
| vibrationValues | Array\<number\> | 是 | 否 | 通知震动。 | | vibrationValues | Array\<number\> | 是 | 否 | 通知震动。 |
...@@ -3740,13 +3743,11 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3740,13 +3743,11 @@ Notification.subscribe(subscriber, subscribeCallback);
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- ------------------------------------- || ---- | --- | ------------------------ | | ----- | -------------------------------------- | ---- | ---- | ---------------------- |
| type | [DoNotDisturbType](#donotdisturbtype8) | 是 | 否 | 指定免打扰设置的时间类型。 | | type | [DoNotDisturbType](#donotdisturbtype8) | 是 | 是 | 免打扰设置的时间类型。 |
| begin | Date | 是 | 否 | 指定免打扰设置的起点时间。 | | begin | Date | 是 | 是 | 免打扰设置的起点时间。 |
| end | Date | 是 | 否 | 指定免打扰设置的终点时间。 | | end | Date | 是 | 是 | 免打扰设置的终点时间。 |
## DoNotDisturbType<sup>8+</sup> ## DoNotDisturbType<sup>8+</sup>
...@@ -3793,8 +3794,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3793,8 +3794,8 @@ Notification.subscribe(subscriber, subscribeCallback);
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ |---- | --- | ------ | | ------ | ------ |---- | --- | ------ |
| bundle | string | 是 | 是 | 包名。 | | bundle | string | 是 | 是 | 应用的包信息。 |
| uid | number | 是 | 是 | 用户id。 | | uid | number | 是 | 是 | 用户ID。 |
...@@ -3830,7 +3831,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3830,7 +3831,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | | --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | 是 | 是 | 按钮标题。 | | title | string | 是 | 是 | 按钮标题。 |
| wantAgent | WantAgent | 是 | 是 | 点击按钮时触发的WantAgent。 | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 点击按钮时触发的WantAgent。 |
| extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 | | extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 |
| userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | 是 | 是 | 用户输入对象实例。 | | userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | 是 | 是 | 用户输入对象实例。 |
...@@ -3845,7 +3846,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3845,7 +3846,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| -------------- | ------ | ---- | ---- | ---------------------------------- | | -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | 是 | 是 | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | string | 是 | 是 | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
## NotificationLongTextContent ## NotificationLongTextContent
...@@ -3858,7 +3859,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3858,7 +3859,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| -------------- | ------ | ---- | --- | -------------------------------- | | -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | 是 | 是 | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | string | 是 | 是 | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| longText | string | 是 | 是 | 通知的长文本。 | | longText | string | 是 | 是 | 通知的长文本。 |
| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | | expandedTitle | string | 是 | 是 | 通知展开时的标题。 |
...@@ -3874,7 +3875,7 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3874,7 +3875,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| -------------- | --------------- | --- | --- | -------------------------------- | | -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | 是 | 是 | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | string | 是 | 是 | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| longTitle | string | 是 | 是 | 通知展开时的标题。 | | longTitle | string | 是 | 是 | 通知展开时的标题。 |
| lines | Array\<string\> | 是 | 是 | 通知的多行文本。 | | lines | Array\<string\> | 是 | 是 | 通知的多行文本。 |
...@@ -3890,10 +3891,10 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3890,10 +3891,10 @@ Notification.subscribe(subscriber, subscribeCallback);
| -------------- | -------------- | ---- | --- | -------------------------------- | | -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | 是 | 是 | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | string | 是 | 是 | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | | expandedTitle | string | 是 | 是 | 通知展开时的标题。 |
| picture | image.PixelMap | 是 | 是 | 通知的图片内容。 | | picture | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知的图片内容。 |
## NotificationContent ## NotificationContent
...@@ -3934,8 +3935,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3934,8 +3935,8 @@ Notification.subscribe(subscriber, subscribeCallback);
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | | ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | NotificationFlagStatus | 是 | 否 | 是否启用声音提示。 | | soundEnabled | [NotificationFlagStatus](#notificationflagstatus8) | 是 | 否 | 是否启用声音提示。 |
| vibrationEnabled | NotificationFlagStatus | 是 | 否 | 是否启用振动提醒功能。 | | vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus8) | 是 | 否 | 是否启用振动提醒功能。 |
## NotificationRequest ## NotificationRequest
...@@ -3954,11 +3955,11 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3954,11 +3955,11 @@ Notification.subscribe(subscriber, subscribeCallback);
| deliveryTime | number | 是 | 是 | 通知发送时间。 | | deliveryTime | number | 是 | 是 | 通知发送时间。 |
| tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 | | tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 |
| autoDeletedTime | number | 是 | 是 | 自动清除的时间。 | | autoDeletedTime | number | 是 | 是 | 自动清除的时间。 |
| wantAgent | WantAgent | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 |
| extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 | | extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 |
| color | number | 是 | 是 | 通知背景颜色。暂不支持。 | | color | number | 是 | 是 | 通知背景颜色。预留能力,暂未支持。 |
| colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。暂不支持。 | | colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。预留能力,暂未支持。 |
| isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知警报。 | | isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知提醒。 |
| isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 | | isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 |
| isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 | | isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 |
| isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 | | isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 |
...@@ -3966,8 +3967,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3966,8 +3967,8 @@ Notification.subscribe(subscriber, subscribeCallback);
| badgeIconStyle | number | 是 | 是 | 通知角标类型。 | | badgeIconStyle | number | 是 | 是 | 通知角标类型。 |
| showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 | | showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 |
| actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | 是 | 是 | 通知按钮,最多两个按钮。 | | actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | 是 | 是 | 通知按钮,最多两个按钮。 |
| smallIcon | PixelMap | 是 | 是 | 通知小图标。 | | smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知小图标。可选字段,大小不超过30KB。 |
| largeIcon | PixelMap | 是 | 是 | 通知大图标。 | | largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知大图标。可选字段,大小不超过30KB。 |
| creatorBundleName | string | 是 | 否 | 创建通知的包名。 | | creatorBundleName | string | 是 | 否 | 创建通知的包名。 |
| creatorUid | number | 是 | 否 | 创建通知的UID。 | | creatorUid | number | 是 | 否 | 创建通知的UID。 |
| creatorPid | number | 是 | 否 | 创建通知的PID。 | | creatorPid | number | 是 | 否 | 创建通知的PID。 |
...@@ -3981,10 +3982,9 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3981,10 +3982,9 @@ Notification.subscribe(subscriber, subscribeCallback);
| distributedOption<sup>8+</sup> | [DistributedOptions](#distributedoptions8) | 是 | 是 | 分布式通知的选项。 | | distributedOption<sup>8+</sup> | [DistributedOptions](#distributedoptions8) | 是 | 是 | 分布式通知的选项。 |
| deviceId<sup>8+</sup> | string | 是 | 否 | 通知源的deviceId。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | | deviceId<sup>8+</sup> | string | 是 | 否 | 通知源的deviceId。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| notificationFlags<sup>8+</sup> | [NotificationFlags](#notificationflags8) | 是 | 否 | 获取NotificationFlags。 | | notificationFlags<sup>8+</sup> | [NotificationFlags](#notificationflags8) | 是 | 否 | 获取NotificationFlags。 |
| removalWantAgent<sup>9+</sup> | WantAgent | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 | | removalWantAgent<sup>9+</sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 |
| badgeNumber<sup>9+</sup> | number | 是 | 是 | 应用程序图标上显示的通知数。 | | badgeNumber<sup>9+</sup> | number | 是 | 是 | 应用程序图标上显示的通知数。 |
## DistributedOptions<sup>8+</sup> ## DistributedOptions<sup>8+</sup>
描述分布式选项。 描述分布式选项。
...@@ -3994,8 +3994,8 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3994,8 +3994,8 @@ Notification.subscribe(subscriber, subscribeCallback);
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed | boolean | 是 | 是 | 是否为分布式通知。 | | isDistributed | boolean | 是 | 是 | 是否为分布式通知。 |
| supportDisplayDevices | Array\<string> | 是 | 是 | 可以同步通知到的设备类型。 | | supportDisplayDevices | Array\<string> | 是 | 是 | 可以同步通知到的设备列表。 |
| supportOperateDevices | Array\<string> | 是 | 是 | 可以打开通知的设备 | | supportOperateDevices | Array\<string> | 是 | 是 | 可以打开通知的设备列表。 |
| remindType | number | 是 | 否 | 通知的提醒方式。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | | remindType | number | 是 | 否 | 通知的提醒方式。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
......
...@@ -22,10 +22,10 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void ...@@ -22,10 +22,10 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- | | -------- | ------------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| callback | AsyncCallback\<void\> | 是 | 被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 发布通知的回调方法。 |
**错误码:** **错误码:**
...@@ -50,7 +50,7 @@ function publishCallback(err) { ...@@ -50,7 +50,7 @@ function publishCallback(err) {
} }
} }
//通知Request对象 //通知Request对象
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -60,8 +60,8 @@ var notificationRequest = { ...@@ -60,8 +60,8 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, publishCallback) Notification.publish(notificationRequest, publishCallback);
``` ```
...@@ -76,9 +76,9 @@ publish(request: NotificationRequest): Promise\<void\> ...@@ -76,9 +76,9 @@ publish(request: NotificationRequest): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ------------------------------------------- | | -------- | ------------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
**错误码:** **错误码:**
...@@ -94,8 +94,8 @@ publish(request: NotificationRequest): Promise\<void\> ...@@ -94,8 +94,8 @@ publish(request: NotificationRequest): Promise\<void\>
**示例:** **示例:**
```js ```js
//通知Request对象 // 通知Request对象
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -105,9 +105,9 @@ var notificationRequest = { ...@@ -105,9 +105,9 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest).then(() => { Notification.publish(notificationRequest).then(() => {
console.info("publish sucess"); console.info("publish success");
}); });
``` ```
...@@ -116,7 +116,7 @@ Notification.publish(notificationRequest).then(() => { ...@@ -116,7 +116,7 @@ Notification.publish(notificationRequest).then(() => {
publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
发布通知(callback形式)。 发布通知给指定的用户(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -126,10 +126,10 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v ...@@ -126,10 +126,10 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback\<void\> | 是 | 被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 被指定的回调方法。 |
**错误码:** **错误码:**
...@@ -147,7 +147,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v ...@@ -147,7 +147,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v
**示例:** **示例:**
```js ```js
//publish回调 // publish回调
function publishCallback(err) { function publishCallback(err) {
if (err) { if (err) {
console.info("publish failed " + JSON.stringify(err)); console.info("publish failed " + JSON.stringify(err));
...@@ -155,10 +155,10 @@ function publishCallback(err) { ...@@ -155,10 +155,10 @@ function publishCallback(err) {
console.info("publish success"); console.info("publish success");
} }
} }
// 接收通知的用户ID // 用户ID
var userId = 1 let userId = 1;
//通知Request对象 // 通知Request对象
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -168,7 +168,7 @@ var notificationRequest = { ...@@ -168,7 +168,7 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, userId, publishCallback); Notification.publish(notificationRequest, userId, publishCallback);
``` ```
...@@ -176,7 +176,7 @@ Notification.publish(notificationRequest, userId, publishCallback); ...@@ -176,7 +176,7 @@ Notification.publish(notificationRequest, userId, publishCallback);
publish(request: NotificationRequest, userId: number): Promise\<void\> publish(request: NotificationRequest, userId: number): Promise\<void\>
发布通知(Promise形式)。 发布通知给指定的用户(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -186,10 +186,10 @@ publish(request: NotificationRequest, userId: number): Promise\<void\> ...@@ -186,10 +186,10 @@ publish(request: NotificationRequest, userId: number): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------- | ---- | ------------------------------------------- | | -------- | ----------------------------------------- | ---- | ------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**错误码:** **错误码:**
...@@ -206,7 +206,7 @@ publish(request: NotificationRequest, userId: number): Promise\<void\> ...@@ -206,7 +206,7 @@ publish(request: NotificationRequest, userId: number): Promise\<void\>
**示例:** **示例:**
```js ```js
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -216,12 +216,12 @@ var notificationRequest = { ...@@ -216,12 +216,12 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
var userId = 1 let userId = 1;
Notification.publish(notificationRequest, userId).then(() => { Notification.publish(notificationRequest, userId).then(() => {
console.info("publish sucess"); console.info("publish success");
}); });
``` ```
...@@ -230,13 +230,13 @@ Notification.publish(notificationRequest, userId).then(() => { ...@@ -230,13 +230,13 @@ Notification.publish(notificationRequest, userId).then(() => {
cancel(id: number, label: string, callback: AsyncCallback\<void\>): void cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
取消与指定id和label相匹配的已发布通知(callback形式)。 通过通知ID和通知标签取消已发布的通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| id | number | 是 | 通知ID。 | | id | number | 是 | 通知ID。 |
| label | string | 是 | 通知标签。 | | label | string | 是 | 通知标签。 |
...@@ -254,7 +254,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void ...@@ -254,7 +254,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//cancel回调 // cancel回调
function cancelCallback(err) { function cancelCallback(err) {
if (err) { if (err) {
console.info("cancel failed " + JSON.stringify(err)); console.info("cancel failed " + JSON.stringify(err));
...@@ -262,7 +262,7 @@ function cancelCallback(err) { ...@@ -262,7 +262,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, "label", cancelCallback) Notification.cancel(0, "label", cancelCallback);
``` ```
...@@ -271,13 +271,13 @@ Notification.cancel(0, "label", cancelCallback) ...@@ -271,13 +271,13 @@ Notification.cancel(0, "label", cancelCallback)
cancel(id: number, label?: string): Promise\<void\> cancel(id: number, label?: string): Promise\<void\>
取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 取消与指定通知ID相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | -------- | | ----- | ------ | ---- | -------- |
| id | number | 是 | 通知ID。 | | id | number | 是 | 通知ID。 |
| label | string | 否 | 通知标签。 | | label | string | 否 | 通知标签。 |
...@@ -295,7 +295,7 @@ cancel(id: number, label?: string): Promise\<void\> ...@@ -295,7 +295,7 @@ cancel(id: number, label?: string): Promise\<void\>
```js ```js
Notification.cancel(0).then(() => { Notification.cancel(0).then(() => {
console.info("cancel sucess"); console.info("cancel success");
}); });
``` ```
...@@ -305,13 +305,13 @@ Notification.cancel(0).then(() => { ...@@ -305,13 +305,13 @@ Notification.cancel(0).then(() => {
cancel(id: number, callback: AsyncCallback\<void\>): void cancel(id: number, callback: AsyncCallback\<void\>): void
取消与指定id相匹配的已发布通知(callback形式)。 取消与指定通知ID相匹配的已发布通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| id | number | 是 | 通知ID。 | | id | number | 是 | 通知ID。 |
| callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 |
...@@ -328,7 +328,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void ...@@ -328,7 +328,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//cancel回调 // cancel回调
function cancelCallback(err) { function cancelCallback(err) {
if (err) { if (err) {
console.info("cancel failed " + JSON.stringify(err)); console.info("cancel failed " + JSON.stringify(err));
...@@ -336,7 +336,7 @@ function cancelCallback(err) { ...@@ -336,7 +336,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, cancelCallback) Notification.cancel(0, cancelCallback);
``` ```
...@@ -359,14 +359,14 @@ cancelAll(callback: AsyncCallback\<void\>): void ...@@ -359,14 +359,14 @@ cancelAll(callback: AsyncCallback\<void\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 |
**示例:** **示例:**
```js ```js
//cancel回调 // cancel回调
function cancelAllCallback(err) { function cancelAllCallback(err) {
if (err) { if (err) {
console.info("cancelAll failed " + JSON.stringify(err)); console.info("cancelAll failed " + JSON.stringify(err));
...@@ -374,7 +374,7 @@ function cancelAllCallback(err) { ...@@ -374,7 +374,7 @@ function cancelAllCallback(err) {
console.info("cancelAll success"); console.info("cancelAll success");
} }
} }
Notification.cancelAll(cancelAllCallback) Notification.cancelAll(cancelAllCallback);
``` ```
...@@ -399,7 +399,7 @@ cancelAll(): Promise\<void\> ...@@ -399,7 +399,7 @@ cancelAll(): Promise\<void\>
```js ```js
Notification.cancelAll().then(() => { Notification.cancelAll().then(() => {
console.info("cancelAll sucess"); console.info("cancelAll success");
}); });
``` ```
...@@ -419,7 +419,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void ...@@ -419,7 +419,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | | slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 |
| callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 |
...@@ -435,7 +435,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void ...@@ -435,7 +435,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//addslot回调 // addslot回调
function addSlotCallBack(err) { function addSlotCallBack(err) {
if (err) { if (err) {
console.info("addSlot failed " + JSON.stringify(err)); console.info("addSlot failed " + JSON.stringify(err));
...@@ -443,11 +443,11 @@ function addSlotCallBack(err) { ...@@ -443,11 +443,11 @@ function addSlotCallBack(err) {
console.info("addSlot success"); console.info("addSlot success");
} }
} }
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot, addSlotCallBack) Notification.addSlot(notificationSlot, addSlotCallBack);
``` ```
...@@ -466,7 +466,7 @@ addSlot(slot: NotificationSlot): Promise\<void\> ...@@ -466,7 +466,7 @@ addSlot(slot: NotificationSlot): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ---------------- | ---- | -------------------- | | ---- | ---------------- | ---- | -------------------- |
| slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | | slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 |
...@@ -481,12 +481,12 @@ addSlot(slot: NotificationSlot): Promise\<void\> ...@@ -481,12 +481,12 @@ addSlot(slot: NotificationSlot): Promise\<void\>
**示例:** **示例:**
```js ```js
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot).then(() => { Notification.addSlot(notificationSlot).then(() => {
console.info("addSlot sucess"); console.info("addSlot success");
}); });
``` ```
...@@ -496,13 +496,13 @@ Notification.addSlot(notificationSlot).then(() => { ...@@ -496,13 +496,13 @@ Notification.addSlot(notificationSlot).then(() => {
addSlot(type: SlotType, callback: AsyncCallback\<void\>): void addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
创建通知通道(callback形式)。 创建指定类型的通知通道(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------- | | -------- | --------------------- | ---- | ---------------------- |
| type | [SlotType](#slottype) | 是 | 要创建的通知通道的类型。 | | type | [SlotType](#slottype) | 是 | 要创建的通知通道的类型。 |
| callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 |
...@@ -518,7 +518,7 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void ...@@ -518,7 +518,7 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//addslot回调 // addslot回调
function addSlotCallBack(err) { function addSlotCallBack(err) {
if (err) { if (err) {
console.info("addSlot failed " + JSON.stringify(err)); console.info("addSlot failed " + JSON.stringify(err));
...@@ -526,7 +526,7 @@ function addSlotCallBack(err) { ...@@ -526,7 +526,7 @@ function addSlotCallBack(err) {
console.info("addSlot success"); console.info("addSlot success");
} }
} }
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
``` ```
...@@ -535,13 +535,13 @@ Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack ...@@ -535,13 +535,13 @@ Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack
addSlot(type: SlotType): Promise\<void\> addSlot(type: SlotType): Promise\<void\>
创建通知通道(Promise形式)。 创建指定类型的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | -------- | ---- | ---------------------- | | ---- | -------- | ---- | ---------------------- |
| type | [SlotType](#slottype) | 是 | 要创建的通知通道的类型。 | | type | [SlotType](#slottype) | 是 | 要创建的通知通道的类型。 |
...@@ -557,7 +557,7 @@ addSlot(type: SlotType): Promise\<void\> ...@@ -557,7 +557,7 @@ addSlot(type: SlotType): Promise\<void\>
```js ```js
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
console.info("addSlot sucess"); console.info("addSlot success");
}); });
``` ```
...@@ -577,7 +577,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi ...@@ -577,7 +577,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------ | | -------- | ------------------------- | ---- | ------------------------ |
| slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | | slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 |
| callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 |
...@@ -593,7 +593,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi ...@@ -593,7 +593,7 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi
**示例:** **示例:**
```js ```js
//addSlots回调 // addSlots回调
function addSlotsCallBack(err) { function addSlotsCallBack(err) {
if (err) { if (err) {
console.info("addSlots failed " + JSON.stringify(err)); console.info("addSlots failed " + JSON.stringify(err));
...@@ -601,15 +601,15 @@ function addSlotsCallBack(err) { ...@@ -601,15 +601,15 @@ function addSlotsCallBack(err) {
console.info("addSlots success"); console.info("addSlots success");
} }
} }
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
//通知slot array 对象 // 通知slot array 对象
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray, addSlotsCallBack) Notification.addSlots(notificationSlotArray, addSlotsCallBack);
``` ```
...@@ -628,7 +628,7 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\> ...@@ -628,7 +628,7 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ----- | ------------------------- | ---- | ------------------------ | | ----- | ------------------------- | ---- | ------------------------ |
| slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | | slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 |
...@@ -643,16 +643,16 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\> ...@@ -643,16 +643,16 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
**示例:** **示例:**
```js ```js
//通知slot对象 // 通知slot对象
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
//通知slot array 对象 // 通知slot array 对象
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray).then(() => { Notification.addSlots(notificationSlotArray).then(() => {
console.info("addSlots sucess"); console.info("addSlots success");
}); });
``` ```
...@@ -662,15 +662,15 @@ Notification.addSlots(notificationSlotArray).then(() => { ...@@ -662,15 +662,15 @@ Notification.addSlots(notificationSlotArray).then(() => {
getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
获取一个通知通道(callback形式)。 获取一个指定类型的通知通道(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ----------------------------------------------------------- | | -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型目前分为社交通信、服务提醒、内容咨询和其他类型。 |
| callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 |
**错误码:** **错误码:**
...@@ -684,7 +684,7 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void ...@@ -684,7 +684,7 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
**示例:** **示例:**
```js ```js
//getSlot回调 // getSlot回调
function getSlotCallback(err,data) { function getSlotCallback(err,data) {
if (err) { if (err) {
console.info("getSlot failed " + JSON.stringify(err)); console.info("getSlot failed " + JSON.stringify(err));
...@@ -692,8 +692,8 @@ function getSlotCallback(err,data) { ...@@ -692,8 +692,8 @@ function getSlotCallback(err,data) {
console.info("getSlot success"); console.info("getSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback) Notification.getSlot(slotType, getSlotCallback);
``` ```
...@@ -702,15 +702,15 @@ Notification.getSlot(slotType, getSlotCallback) ...@@ -702,15 +702,15 @@ Notification.getSlot(slotType, getSlotCallback)
getSlot(slotType: SlotType): Promise\<NotificationSlot\> getSlot(slotType: SlotType): Promise\<NotificationSlot\>
获取一个通知通道(Promise形式)。 获取一个指定类型的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ----------------------------------------------------------- | | -------- | -------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型目前分为社交通信、服务提醒、内容咨询和其他类型。 |
**返回值:** **返回值:**
...@@ -729,9 +729,9 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\> ...@@ -729,9 +729,9 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\>
**示例:** **示例:**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => { Notification.getSlot(slotType).then((data) => {
console.info("getSlot sucess, data: " + JSON.stringify(data)); console.info("getSlot success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -747,9 +747,9 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void ...@@ -747,9 +747,9 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | -------------------- | | -------- | --------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)\>\> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 |
**错误码:** **错误码:**
...@@ -762,7 +762,7 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void ...@@ -762,7 +762,7 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
**示例:** **示例:**
```js ```js
//getSlots回调 // getSlots回调
function getSlotsCallback(err,data) { function getSlotsCallback(err,data) {
if (err) { if (err) {
console.info("getSlots failed " + JSON.stringify(err)); console.info("getSlots failed " + JSON.stringify(err));
...@@ -770,7 +770,7 @@ function getSlotsCallback(err,data) { ...@@ -770,7 +770,7 @@ function getSlotsCallback(err,data) {
console.info("getSlots success"); console.info("getSlots success");
} }
} }
Notification.getSlots(getSlotsCallback) Notification.getSlots(getSlotsCallback);
``` ```
...@@ -801,7 +801,7 @@ getSlots(): Promise\<Array\<NotificationSlot\>> ...@@ -801,7 +801,7 @@ getSlots(): Promise\<Array\<NotificationSlot\>>
```js ```js
Notification.getSlots().then((data) => { Notification.getSlots().then((data) => {
console.info("getSlots sucess, data: " + JSON.stringify(data)); console.info("getSlots success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -811,13 +811,13 @@ Notification.getSlots().then((data) => { ...@@ -811,13 +811,13 @@ Notification.getSlots().then((data) => {
removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
根据通知通道类型删除创建的通知通道(callback形式)。 删除指定类型的通知通道(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ----------------------------------------------------------- | | -------- | --------------------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
| callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 |
...@@ -833,7 +833,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void ...@@ -833,7 +833,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
**示例:** **示例:**
```js ```js
//removeSlot回调 // removeSlot回调
function removeSlotCallback(err) { function removeSlotCallback(err) {
if (err) { if (err) {
console.info("removeSlot failed " + JSON.stringify(err)); console.info("removeSlot failed " + JSON.stringify(err));
...@@ -841,8 +841,8 @@ function removeSlotCallback(err) { ...@@ -841,8 +841,8 @@ function removeSlotCallback(err) {
console.info("removeSlot success"); console.info("removeSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback) Notification.removeSlot(slotType,removeSlotCallback);
``` ```
...@@ -851,13 +851,13 @@ Notification.removeSlot(slotType,removeSlotCallback) ...@@ -851,13 +851,13 @@ Notification.removeSlot(slotType,removeSlotCallback)
removeSlot(slotType: SlotType): Promise\<void\> removeSlot(slotType: SlotType): Promise\<void\>
根据通知通道类型删除创建的通知通道(Promise形式)。 删除指定类型的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ----------------------------------------------------------- | | -------- | -------- | ---- | ----------------------------------------------------------- |
| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 |
...@@ -872,9 +872,9 @@ removeSlot(slotType: SlotType): Promise\<void\> ...@@ -872,9 +872,9 @@ removeSlot(slotType: SlotType): Promise\<void\>
**示例:** **示例:**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then(() => { Notification.removeSlot(slotType).then(() => {
console.info("removeSlot sucess"); console.info("removeSlot success");
}); });
``` ```
...@@ -890,7 +890,7 @@ removeAllSlots(callback: AsyncCallback\<void\>): void ...@@ -890,7 +890,7 @@ removeAllSlots(callback: AsyncCallback\<void\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 | | callback | AsyncCallback\<void\> | 是 | 表示被指定的回调方法。 |
...@@ -912,7 +912,7 @@ function removeAllCallBack(err) { ...@@ -912,7 +912,7 @@ function removeAllCallBack(err) {
console.info("removeAllSlots success"); console.info("removeAllSlots success");
} }
} }
Notification.removeAllSlots(removeAllCallBack) Notification.removeAllSlots(removeAllCallBack);
``` ```
...@@ -937,7 +937,7 @@ removeAllSlots(): Promise\<void\> ...@@ -937,7 +937,7 @@ removeAllSlots(): Promise\<void\>
```js ```js
Notification.removeAllSlots().then(() => { Notification.removeAllSlots().then(() => {
console.info("removeAllSlots sucess"); console.info("removeAllSlots success");
}); });
``` ```
...@@ -947,7 +947,7 @@ Notification.removeAllSlots().then(() => { ...@@ -947,7 +947,7 @@ Notification.removeAllSlots().then(() => {
setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
设定指定的通知使能状态(Callback形式)。 设定指定应用的通知使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -957,9 +957,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall ...@@ -957,9 +957,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设定通知使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定通知使能回调函数。 |
...@@ -982,9 +982,9 @@ function setNotificationEnablenCallback(err) { ...@@ -982,9 +982,9 @@ function setNotificationEnablenCallback(err) {
console.info("setNotificationEnablenCallback success"); console.info("setNotificationEnablenCallback success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback); Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback);
``` ```
...@@ -994,7 +994,7 @@ Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback ...@@ -994,7 +994,7 @@ Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback
setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\> setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
设定指定的通知使能状态(Promise形式)。 设定指定应用的通知使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1004,9 +1004,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\> ...@@ -1004,9 +1004,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**错误码:** **错误码:**
...@@ -1021,11 +1021,11 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\> ...@@ -1021,11 +1021,11 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.setNotificationEnable(bundle, false).then(() => { Notification.setNotificationEnable(bundle, false).then(() => {
console.info("setNotificationEnable sucess"); console.info("setNotificationEnable success");
}); });
``` ```
...@@ -1035,7 +1035,7 @@ Notification.setNotificationEnable(bundle, false).then(() => { ...@@ -1035,7 +1035,7 @@ Notification.setNotificationEnable(bundle, false).then(() => {
isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
获取指定的通知使能状态(Callback形式)。 获取指定应用的通知使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1045,9 +1045,9 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): ...@@ -1045,9 +1045,9 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 | | callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 |
**错误码:** **错误码:**
...@@ -1069,9 +1069,9 @@ function isNotificationEnabledCallback(err, data) { ...@@ -1069,9 +1069,9 @@ function isNotificationEnabledCallback(err, data) {
console.info("isNotificationEnabled success"); console.info("isNotificationEnabled success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
``` ```
...@@ -1081,7 +1081,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); ...@@ -1081,7 +1081,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
获取指定的通知使能状态(Promise形式)。 获取指定应用的通知使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1091,15 +1091,15 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> ...@@ -1091,15 +1091,15 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------ | --------------------------------------------------- |
| Promise\<boolean\> | 以Promise形式返回获取指定的通知使能状态的结果。 | | Promise\<boolean\> | 以Promise形式返回获取指定应用的通知使能状态的结果。 |
**错误码:** **错误码:**
...@@ -1113,11 +1113,11 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> ...@@ -1113,11 +1113,11 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle).then((data) => { Notification.isNotificationEnabled(bundle).then((data) => {
console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1137,7 +1137,7 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void ...@@ -1137,7 +1137,7 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 | | callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 |
...@@ -1179,9 +1179,9 @@ isNotificationEnabled(): Promise\<boolean\> ...@@ -1179,9 +1179,9 @@ isNotificationEnabled(): Promise\<boolean\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
...@@ -1202,7 +1202,7 @@ isNotificationEnabled(): Promise\<boolean\> ...@@ -1202,7 +1202,7 @@ isNotificationEnabled(): Promise\<boolean\>
```js ```js
Notification.isNotificationEnabled().then((data) => { Notification.isNotificationEnabled().then((data) => {
console.info("isNotificationEnabled sucess, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1212,7 +1212,7 @@ Notification.isNotificationEnabled().then((data) => { ...@@ -1212,7 +1212,7 @@ Notification.isNotificationEnabled().then((data) => {
displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
设定指定的角标使能状态(Callback形式)。 设定指定应用的角标使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1222,9 +1222,9 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi ...@@ -1222,9 +1222,9 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设定角标使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定角标使能回调函数。 |
...@@ -1247,9 +1247,9 @@ function displayBadgeCallback(err) { ...@@ -1247,9 +1247,9 @@ function displayBadgeCallback(err) {
console.info("displayBadge success"); console.info("displayBadge success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false, displayBadgeCallback); Notification.displayBadge(bundle, false, displayBadgeCallback);
``` ```
...@@ -1259,7 +1259,7 @@ Notification.displayBadge(bundle, false, displayBadgeCallback); ...@@ -1259,7 +1259,7 @@ Notification.displayBadge(bundle, false, displayBadgeCallback);
displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
设定指定的角标使能状态(Promise形式)。 设定指定应用的角标使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1269,9 +1269,9 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> ...@@ -1269,9 +1269,9 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**错误码:** **错误码:**
...@@ -1286,11 +1286,11 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> ...@@ -1286,11 +1286,11 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false).then(() => { Notification.displayBadge(bundle, false).then(() => {
console.info("displayBadge sucess"); console.info("displayBadge success");
}); });
``` ```
...@@ -1300,7 +1300,7 @@ Notification.displayBadge(bundle, false).then(() => { ...@@ -1300,7 +1300,7 @@ Notification.displayBadge(bundle, false).then(() => {
isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
获取指定的角标使能状态(Callback形式)。 获取指定应用的角标使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1310,9 +1310,9 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void ...@@ -1310,9 +1310,9 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ | | -------- | --------------------- | ---- | ------------------------ |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<void\> | 是 | 获取角标使能状态回调函数。 | | callback | AsyncCallback\<void\> | 是 | 获取角标使能状态回调函数。 |
**错误码:** **错误码:**
...@@ -1334,9 +1334,9 @@ function isBadgeDisplayedCallback(err, data) { ...@@ -1334,9 +1334,9 @@ function isBadgeDisplayedCallback(err, data) {
console.info("isBadgeDisplayed success"); console.info("isBadgeDisplayed success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
``` ```
...@@ -1346,7 +1346,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); ...@@ -1346,7 +1346,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
获取指定的角标使能状态(Promise形式)。 获取指定应用的角标使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1356,15 +1356,15 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> ...@@ -1356,15 +1356,15 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取指定的角标使能状态。 | | Promise\<boolean\> | 以Promise形式返回获取指定应用的角标使能状态。 |
**错误码:** **错误码:**
...@@ -1378,11 +1378,11 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> ...@@ -1378,11 +1378,11 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle).then((data) => { Notification.isBadgeDisplayed(bundle).then((data) => {
console.info("isBadgeDisplayed sucess, data: " + JSON.stringify(data)); console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1392,7 +1392,7 @@ Notification.isBadgeDisplayed(bundle).then((data) => { ...@@ -1392,7 +1392,7 @@ Notification.isBadgeDisplayed(bundle).then((data) => {
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
设定指定包的通知通道状态(Callback形式)。 设定指定应用的通知通道(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1402,9 +1402,9 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal ...@@ -1402,9 +1402,9 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | | slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 |
| callback | AsyncCallback\<void\> | 是 | 设定通知通道回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定通知通道回调函数。 |
...@@ -1429,12 +1429,12 @@ function setSlotByBundleCallback(err) { ...@@ -1429,12 +1429,12 @@ function setSlotByBundleCallback(err) {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
``` ```
...@@ -1444,7 +1444,7 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); ...@@ -1444,7 +1444,7 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
设定指定包的通知通道状态(Promise形式)。 设定指定应用的通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1454,10 +1454,10 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> ...@@ -1454,10 +1454,10 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| slot | [NotificationSlot](#notificationslot) | 是 | 使能状态。 | | slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 |
**错误码:** **错误码:**
...@@ -1471,14 +1471,14 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> ...@@ -1471,14 +1471,14 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot).then(() => { Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("setSlotByBundle sucess"); console.info("setSlotByBundle success");
}); });
``` ```
...@@ -1488,7 +1488,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { ...@@ -1488,7 +1488,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
获取指定包的通知通道(Callback形式)。 获取指定应用的所有通知通道(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1498,9 +1498,9 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati ...@@ -1498,9 +1498,9 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | 是 | 获取通知通道回调函数。 | | callback | AsyncCallback<Array\<[NotificationSlot](#notificationslot)\>> | 是 | 获取通知通道回调函数。 |
**错误码:** **错误码:**
...@@ -1522,9 +1522,9 @@ function getSlotsByBundleCallback(err, data) { ...@@ -1522,9 +1522,9 @@ function getSlotsByBundleCallback(err, data) {
console.info("getSlotsByBundle success"); console.info("getSlotsByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
``` ```
...@@ -1534,7 +1534,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ...@@ -1534,7 +1534,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
获取指定包的通知通道(Promise形式)。 获取指定应用的所有通知通道(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1544,15 +1544,15 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> ...@@ -1544,15 +1544,15 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<Array\<[NotificationSlot](#notificationslot)\>> | 以Promise形式返回获取指定的通知通道。 | | Promise<Array\<[NotificationSlot](#notificationslot)\>> | 以Promise形式返回获取指定应用的通知通道。 |
**错误码:** **错误码:**
...@@ -1566,11 +1566,11 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> ...@@ -1566,11 +1566,11 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle).then((data) => { Notification.getSlotsByBundle(bundle).then((data) => {
console.info("getSlotsByBundle sucess, data: " + JSON.stringify(data)); console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1580,7 +1580,7 @@ Notification.getSlotsByBundle(bundle).then((data) => { ...@@ -1580,7 +1580,7 @@ Notification.getSlotsByBundle(bundle).then((data) => {
getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
获取指定包的通知通道数(Callback形式)。 获取指定应用的通知通道数量(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1590,10 +1590,10 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi ...@@ -1590,10 +1590,10 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------- | | -------- | ------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<number\> | 是 | 获取通知通道数回调函数。 | | callback | AsyncCallback\<number\> | 是 | 获取通知通道数回调函数。 |
**错误码:** **错误码:**
...@@ -1614,9 +1614,9 @@ function getSlotNumByBundleCallback(err, data) { ...@@ -1614,9 +1614,9 @@ function getSlotNumByBundleCallback(err, data) {
console.info("getSlotNumByBundle success"); console.info("getSlotNumByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
``` ```
...@@ -1626,7 +1626,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); ...@@ -1626,7 +1626,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
getSlotNumByBundle(bundle: BundleOption): Promise\<number\> getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
获取指定包的通知通道数(Promise形式)。 获取指定应用的通知通道数量(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1636,15 +1636,15 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\> ...@@ -1636,15 +1636,15 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | 以Promise形式返回获取指定包的通知通道数。 | | Promise\<number\> | 以Promise形式返回获取指定应用的通知通道数量。 |
**错误码:** **错误码:**
...@@ -1658,11 +1658,11 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\> ...@@ -1658,11 +1658,11 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle).then((data) => { Notification.getSlotNumByBundle(bundle).then((data) => {
console.info("getSlotNumByBundle sucess, data: " + JSON.stringify(data)); console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1673,7 +1673,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => { ...@@ -1673,7 +1673,7 @@ Notification.getSlotNumByBundle(bundle).then((data) => {
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
获取活动通知(Callback形式)。 获取当前未删除的所有通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1683,7 +1683,7 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>) ...@@ -1683,7 +1683,7 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>)
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | -------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------- |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是 | 获取活动通知回调函数。 | | callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是 | 获取活动通知回调函数。 |
...@@ -1715,7 +1715,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ...@@ -1715,7 +1715,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback);
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
获取活动通知(Promise形式)。 获取当前未删除的所有通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1741,7 +1741,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notification ...@@ -1741,7 +1741,7 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notification
```js ```js
Notification.getAllActiveNotifications().then((data) => { Notification.getAllActiveNotifications().then((data) => {
console.info("getAllActiveNotifications sucess, data: " + JSON.stringify(data)); console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1751,15 +1751,15 @@ Notification.getAllActiveNotifications().then((data) => { ...@@ -1751,15 +1751,15 @@ Notification.getAllActiveNotifications().then((data) => {
getActiveNotificationCount(callback: AsyncCallback\<number\>): void getActiveNotificationCount(callback: AsyncCallback\<number\>): void
获取当前应用的活动通知数(Callback形式)。 获取当前应用未删除的通知数(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------- | | -------- | ---------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<number\> | 是 | 获取活动通知数回调函数。 | | callback | AsyncCallback\<number\> | 是 | 获取未删除通知数回调函数。 |
**错误码:** **错误码:**
...@@ -1789,15 +1789,15 @@ Notification.getActiveNotificationCount(getActiveNotificationCountCallback); ...@@ -1789,15 +1789,15 @@ Notification.getActiveNotificationCount(getActiveNotificationCountCallback);
getActiveNotificationCount(): Promise\<number\> getActiveNotificationCount(): Promise\<number\>
获取当前应用的活动通知数(Promise形式)。 获取当前应用未删除的通知数(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------- |
| Promise\<number\> | 以Promise形式返回获取当前应用的活动通知数。 | | Promise\<number\> | 以Promise形式返回获取当前应用未删除通知数。 |
**错误码:** **错误码:**
...@@ -1811,7 +1811,7 @@ getActiveNotificationCount(): Promise\<number\> ...@@ -1811,7 +1811,7 @@ getActiveNotificationCount(): Promise\<number\>
```js ```js
Notification.getActiveNotificationCount().then((data) => { Notification.getActiveNotificationCount().then((data) => {
console.info("getActiveNotificationCount sucess, data: " + JSON.stringify(data)); console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1821,15 +1821,15 @@ Notification.getActiveNotificationCount().then((data) => { ...@@ -1821,15 +1821,15 @@ Notification.getActiveNotificationCount().then((data) => {
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
获取当前应用的活动通知(Callback形式)。 获取当前应用未删除的通知列表(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是 | 获取当前应用的活动通知回调函数。 | | callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | 是 | 获取当前应用通知列表回调函数。 |
**错误码:** **错误码:**
...@@ -1859,15 +1859,15 @@ Notification.getActiveNotifications(getActiveNotificationsCallback); ...@@ -1859,15 +1859,15 @@ Notification.getActiveNotifications(getActiveNotificationsCallback);
getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
获取当前应用的活动通知(Promise形式)。 获取当前应用未删除的通知列表(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------------------------------------------------ | --------------------------------------- |
| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | 以Promise形式返回获取当前应用的活动通知。 | | Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | 以Promise形式返回获取当前应用通知列表。 |
**错误码:** **错误码:**
...@@ -1881,7 +1881,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationreq ...@@ -1881,7 +1881,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationreq
```js ```js
Notification.getActiveNotifications().then((data) => { Notification.getActiveNotifications().then((data) => {
console.info("removeGroupByBundle sucess, data: " + JSON.stringify(data)); console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -1891,16 +1891,16 @@ Notification.getActiveNotifications().then((data) => { ...@@ -1891,16 +1891,16 @@ Notification.getActiveNotifications().then((data) => {
cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
取消本应用指定组通知(Callback形式)。 取消本应用指定组下的通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | --------------------- | ---- | ---------------------------- | | --------- | --------------------- | ---- | ---------------------------- |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](#notificationrequest)对象指定。 |
| callback | AsyncCallback\<void\> | 是 | 取消本应用指定组通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 取消本应用指定组下通知的回调函数。 |
**错误码:** **错误码:**
...@@ -1921,7 +1921,7 @@ function cancelGroupCallback(err) { ...@@ -1921,7 +1921,7 @@ function cancelGroupCallback(err) {
} }
} }
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName, cancelGroupCallback); Notification.cancelGroup(groupName, cancelGroupCallback);
``` ```
...@@ -1932,15 +1932,15 @@ Notification.cancelGroup(groupName, cancelGroupCallback); ...@@ -1932,15 +1932,15 @@ Notification.cancelGroup(groupName, cancelGroupCallback);
cancelGroup(groupName: string): Promise\<void\> cancelGroup(groupName: string): Promise\<void\>
取消本应用指定组通知(Promise形式)。 取消本应用指定组下的通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | -------------- | | --------- | ------ | ---- | -------------- |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称。 |
**错误码:** **错误码:**
...@@ -1953,9 +1953,9 @@ cancelGroup(groupName: string): Promise\<void\> ...@@ -1953,9 +1953,9 @@ cancelGroup(groupName: string): Promise\<void\>
**示例:** **示例:**
```js ```js
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => { Notification.cancelGroup(groupName).then(() => {
console.info("cancelGroup sucess"); console.info("cancelGroup success");
}); });
``` ```
...@@ -1965,7 +1965,7 @@ Notification.cancelGroup(groupName).then(() => { ...@@ -1965,7 +1965,7 @@ Notification.cancelGroup(groupName).then(() => {
removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
删除指定应用指定组通知(Callback形式)。 删除指定应用的指定组下的通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -1975,11 +1975,11 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall ...@@ -1975,11 +1975,11 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | --------------------- | ---- | ---------------------------- | | --------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称。 |
| callback | AsyncCallback\<void\> | 是 | 删除本应用指定组通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定应用指定组下通知的回调函数。 |
**错误码:** **错误码:**
...@@ -2001,8 +2001,8 @@ function removeGroupByBundleCallback(err) { ...@@ -2001,8 +2001,8 @@ function removeGroupByBundleCallback(err) {
} }
} }
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
``` ```
...@@ -2013,7 +2013,7 @@ Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCal ...@@ -2013,7 +2013,7 @@ Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCal
removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
删除指定应用指定组通知(Promise形式)。 删除指定应用的指定组下的通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2023,10 +2023,10 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> ...@@ -2023,10 +2023,10 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------ | ---- | -------------- | | --------- | ------------ | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| groupName | string | 是 | 指定通知组名称。 | | groupName | string | 是 | 通知组名称。 |
**错误码:** **错误码:**
...@@ -2040,10 +2040,10 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> ...@@ -2040,10 +2040,10 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
**示例:** **示例:**
```js ```js
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => { Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
console.info("removeGroupByBundle sucess"); console.info("removeGroupByBundle success");
}); });
``` ```
...@@ -2063,7 +2063,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo ...@@ -2063,7 +2063,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------- | | -------- | --------------------- | ---- | ---------------------- |
| date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 |
| callback | AsyncCallback\<void\> | 是 | 设置免打扰时间回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置免打扰时间回调函数。 |
...@@ -2087,11 +2087,11 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2087,11 +2087,11 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
``` ```
...@@ -2102,7 +2102,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); ...@@ -2102,7 +2102,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
设置免打扰时间接口(Promise形式)。 设置免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2112,7 +2112,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> ...@@ -2112,7 +2112,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ---------------- | ---- | -------------- | | ---- | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 |
...@@ -2127,13 +2127,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> ...@@ -2127,13 +2127,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
**示例:** **示例:**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("setDoNotDisturbDate sucess"); console.info("setDoNotDisturbDate success");
}); });
``` ```
...@@ -2152,10 +2152,10 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb ...@@ -2152,10 +2152,10 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------- | | -------- | --------------------- | ---- | ---------------------- |
| date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 设置免打扰时间的用户ID。 |
| callback | AsyncCallback\<void\> | 是 | 设置免打扰时间回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置免打扰时间回调函数。 |
**错误码:** **错误码:**
...@@ -2178,13 +2178,13 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2178,13 +2178,13 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1;
Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
``` ```
...@@ -2195,7 +2195,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCa ...@@ -2195,7 +2195,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCa
setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
指定用户设置免打扰时间接口(Promise形式)。 指定用户设置免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2205,10 +2205,10 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> ...@@ -2205,10 +2205,10 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------- | ---- | -------------- | | ------ | ---------------- | ---- | -------------- |
| date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 设置免打扰时间的用户ID。 |
**错误码:** **错误码:**
...@@ -2222,16 +2222,16 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> ...@@ -2222,16 +2222,16 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
**示例:** **示例:**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1;
Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
console.info("setDoNotDisturbDate sucess"); console.info("setDoNotDisturbDate success");
}); });
``` ```
...@@ -2240,7 +2240,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { ...@@ -2240,7 +2240,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
查询免打扰时间接口(Callback形式)。 查询免打扰时间(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2250,7 +2250,7 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void ...@@ -2250,7 +2250,7 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------------------- | | -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是 | 查询免打扰时间回调函数。 | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是 | 查询免打扰时间回调函数。 |
...@@ -2282,7 +2282,7 @@ Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); ...@@ -2282,7 +2282,7 @@ Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback);
getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
查询免打扰时间接口(Promise形式)。 查询免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2294,7 +2294,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> ...@@ -2294,7 +2294,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------------------ | ----------------------------------------- | | ------------------------------------------------ | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询免打扰时间接口。 | | Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
**错误码:** **错误码:**
...@@ -2308,7 +2308,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> ...@@ -2308,7 +2308,7 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
```js ```js
Notification.getDoNotDisturbDate().then((data) => { Notification.getDoNotDisturbDate().then((data) => {
console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2317,7 +2317,7 @@ Notification.getDoNotDisturbDate().then((data) => { ...@@ -2317,7 +2317,7 @@ Notification.getDoNotDisturbDate().then((data) => {
getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
指定用户查询免打扰时间接口(Callback形式)。 查询指定用户的免打扰时间(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2327,10 +2327,10 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>) ...@@ -2327,10 +2327,10 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>)
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------------------- | | -------- | --------------------------------- | ---- | ---------------------- |
| callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是 | 查询免打扰时间回调函数。 | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是 | 查询免打扰时间回调函数。 |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 用户ID。 |
**错误码:** **错误码:**
...@@ -2352,7 +2352,7 @@ function getDoNotDisturbDateCallback(err,data) { ...@@ -2352,7 +2352,7 @@ function getDoNotDisturbDateCallback(err,data) {
} }
} }
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
``` ```
...@@ -2363,7 +2363,7 @@ Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); ...@@ -2363,7 +2363,7 @@ Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
指定用户查询免打扰时间接口(Promise形式)。 查询指定用户的免打扰时间(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2373,15 +2373,15 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> ...@@ -2373,15 +2373,15 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | ---------------------- | | -------- | --------------------------------- | ---- | ---------------------- |
| userId | number | 是 | 设置免打扰事件的用户ID。 | | userId | number | 是 | 用户ID。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------------------------------------ | ----------------------------------------- | | ------------------------------------------------ | ----------------------------------------- |
| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询免打扰时间接口。 | | Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 |
**错误码:** **错误码:**
...@@ -2395,10 +2395,10 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> ...@@ -2395,10 +2395,10 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
**示例:** **示例:**
```js ```js
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId).then((data) => { Notification.getDoNotDisturbDate(userId).then((data) => {
console.info("getDoNotDisturbDate sucess, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2407,7 +2407,7 @@ Notification.getDoNotDisturbDate(userId).then((data) => { ...@@ -2407,7 +2407,7 @@ Notification.getDoNotDisturbDate(userId).then((data) => {
supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
查询是否支持勿扰模式功能(Callback形式)。 查询是否支持免打扰功能(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2417,9 +2417,9 @@ supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void ...@@ -2417,9 +2417,9 @@ supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------------- | | -------- | ------------------------ | ---- | -------------------------------- |
| callback | AsyncCallback\<boolean\> | 是 | 查询是否支持勿扰模式功能回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 查询是否支持免打扰功能回调函数。 |
**错误码:** **错误码:**
...@@ -2461,7 +2461,7 @@ supportDoNotDisturbMode(): Promise\<boolean\> ...@@ -2461,7 +2461,7 @@ supportDoNotDisturbMode(): Promise\<boolean\>
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取是否支持勿扰模式功能的结果。 | | Promise\<boolean\> | 以Promise形式返回获取是否支持免打扰功能的结果。 |
**错误码:** **错误码:**
...@@ -2475,7 +2475,7 @@ supportDoNotDisturbMode(): Promise\<boolean\> ...@@ -2475,7 +2475,7 @@ supportDoNotDisturbMode(): Promise\<boolean\>
```js ```js
Notification.supportDoNotDisturbMode().then((data) => { Notification.supportDoNotDisturbMode().then((data) => {
console.info("supportDoNotDisturbMode sucess, data: " + JSON.stringify(data)); console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2508,7 +2508,7 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi ...@@ -2508,7 +2508,7 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi
**示例:** **示例:**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
function isSupportTemplateCallback(err, data) { function isSupportTemplateCallback(err, data) {
if (err) { if (err) {
console.info("isSupportTemplate failed " + JSON.stringify(err)); console.info("isSupportTemplate failed " + JSON.stringify(err));
...@@ -2554,7 +2554,7 @@ isSupportTemplate(templateName: string): Promise\<boolean\> ...@@ -2554,7 +2554,7 @@ isSupportTemplate(templateName: string): Promise\<boolean\>
**示例:** **示例:**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
Notification.isSupportTemplate(templateName).then((data) => { Notification.isSupportTemplate(templateName).then((data) => {
console.info("isSupportTemplate success, data: " + JSON.stringify(data)); console.info("isSupportTemplate success, data: " + JSON.stringify(data));
...@@ -2620,10 +2620,9 @@ requestEnableNotification(): Promise\<void\> ...@@ -2620,10 +2620,9 @@ requestEnableNotification(): Promise\<void\>
**示例:** **示例:**
```javascript ```javascript
Notification.requestEnableNotification() Notification.requestEnableNotification().then(() => {
.then(() => { console.info("requestEnableNotification success");
console.info("requestEnableNotification sucess"); });
});
``` ```
...@@ -2644,7 +2643,7 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void ...@@ -2644,7 +2643,7 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| enable | boolean | 是 | 是否支持。<br/>true 支持。<br/>false 不支持。| | enable | boolean | 是 | 是否支持。 |
| callback | AsyncCallback\<void\> | 是 | 设置设备是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置设备是否支持分布式通知的回调函数。 |
**错误码:** **错误码:**
...@@ -2667,7 +2666,7 @@ function setDistributedEnableCallback() { ...@@ -2667,7 +2666,7 @@ function setDistributedEnableCallback() {
} }
}; };
var enable = true let enable = true;
Notification.setDistributedEnable(enable, setDistributedEnableCallback); Notification.setDistributedEnable(enable, setDistributedEnableCallback);
``` ```
...@@ -2690,7 +2689,7 @@ setDistributedEnable(enable: boolean): Promise\<void> ...@@ -2690,7 +2689,7 @@ setDistributedEnable(enable: boolean): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| enable | boolean | 是 | 是否支持。<br/>true 支持。<br/>false 不支持。| | enable | boolean | 是 | 是否支持。 |
**错误码:** **错误码:**
...@@ -2704,11 +2703,10 @@ setDistributedEnable(enable: boolean): Promise\<void> ...@@ -2704,11 +2703,10 @@ setDistributedEnable(enable: boolean): Promise\<void>
**示例:** **示例:**
```javascript ```javascript
var enable = true let enable = true;
Notification.setDistributedEnable(enable) Notification.setDistributedEnable(enable).then(() => {
.then(() => { console.info("setDistributedEnable success");
console.info("setDistributedEnable sucess");
}); });
``` ```
...@@ -2717,7 +2715,7 @@ Notification.setDistributedEnable(enable) ...@@ -2717,7 +2715,7 @@ Notification.setDistributedEnable(enable)
isDistributedEnabled(callback: AsyncCallback\<boolean>): void isDistributedEnabled(callback: AsyncCallback\<boolean>): void
获取设备是否支持分布式通知(Callback形式)。 查询设备是否支持分布式通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2739,11 +2737,11 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void ...@@ -2739,11 +2737,11 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void
**示例:** **示例:**
```javascript ```javascript
function isDistributedEnabledCallback(err) { function isDistributedEnabledCallback(err, data) {
if (err) { if (err) {
console.info("isDistributedEnabled failed " + JSON.stringify(err)); console.info("isDistributedEnabled failed " + JSON.stringify(err));
} else { } else {
console.info("isDistributedEnabled success"); console.info("isDistributedEnabled success " + JSON.stringify(data));
} }
}; };
...@@ -2756,15 +2754,15 @@ Notification.isDistributedEnabled(isDistributedEnabledCallback); ...@@ -2756,15 +2754,15 @@ Notification.isDistributedEnabled(isDistributedEnabledCallback);
isDistributedEnabled(): Promise\<boolean> isDistributedEnabled(): Promise\<boolean>
获取设备是否支持分布式通知(Promise形式)。 查询设备是否支持分布式通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------ | --------------- | | ------------------ | --------------------------------------------- |
| Promise\<boolean\> | Promise方式返回设备是否支持分布式通知的结果。<br/>true 支持。<br/>false 不支持。 | | Promise\<boolean\> | Promise方式返回设备是否支持分布式通知的结果。 |
**错误码:** **错误码:**
...@@ -2780,7 +2778,7 @@ isDistributedEnabled(): Promise\<boolean> ...@@ -2780,7 +2778,7 @@ isDistributedEnabled(): Promise\<boolean>
```javascript ```javascript
Notification.isDistributedEnabled() Notification.isDistributedEnabled()
.then((data) => { .then((data) => {
console.info("isDistributedEnabled sucess, data: " + JSON.stringify(data)); console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
...@@ -2789,7 +2787,7 @@ Notification.isDistributedEnabled() ...@@ -2789,7 +2787,7 @@ Notification.isDistributedEnabled()
setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
根据应用的包设置应用程序是否支持分布式通知(Callback形式)。 设置指定应用是否支持分布式通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2801,7 +2799,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As ...@@ -2801,7 +2799,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| enable | boolean | 是 | 是否支持。 | | enable | boolean | 是 | 是否支持。 |
| callback | AsyncCallback\<void\> | 是 | 应用程序是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 应用程序是否支持分布式通知的回调函数。 |
...@@ -2826,11 +2824,11 @@ function setDistributedEnableByBundleCallback(err) { ...@@ -2826,11 +2824,11 @@ function setDistributedEnableByBundleCallback(err) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true
Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback); Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback);
``` ```
...@@ -2841,7 +2839,7 @@ Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableBy ...@@ -2841,7 +2839,7 @@ Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableBy
setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void> setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
根据应用的包设置应用程序是否支持分布式通知(Promise形式)。 设置指定应用是否支持分布式通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2869,15 +2867,14 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo ...@@ -2869,15 +2867,14 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo
**示例:** **示例:**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true
Notification.setDistributedEnableByBundle(bundle, enable) Notification.setDistributedEnableByBundle(bundle, enable).then(() => {
.then(() => { console.info("setDistributedEnableByBundle success");
console.info("setDistributedEnableByBundle sucess");
}); });
``` ```
...@@ -2898,7 +2895,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool ...@@ -2898,7 +2895,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 |
| callback | AsyncCallback\<boolean\> | 是 | 应用程序是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 查询指定应用是否支持分布式通知的回调函数。 |
**错误码:** **错误码:**
...@@ -2917,13 +2914,13 @@ function isDistributedEnabledByBundleCallback(data) { ...@@ -2917,13 +2914,13 @@ function isDistributedEnabledByBundleCallback(data) {
if (err) { if (err) {
console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err)); console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
} else { } else {
console.info("isDistributedEnabledByBundle success"); console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
``` ```
...@@ -2934,7 +2931,7 @@ Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCa ...@@ -2934,7 +2931,7 @@ Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCa
isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
根据应用的包获取应用程序是否支持分布式通知(Promise形式)。 查询指定应用是否支持分布式通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2950,9 +2947,9 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> ...@@ -2950,9 +2947,9 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ------------------ | --------------- | | ------------------ | ------------------------------------------------- |
| Promise\<boolean\> | Promise方式返回应用程序是否支持分布式通知的结果。<br/>true 支持。<br/>false 不支持。 | | Promise\<boolean\> | Promise方式返回指定应用是否支持分布式通知的结果。 |
**错误码:** **错误码:**
...@@ -2967,14 +2964,13 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> ...@@ -2967,14 +2964,13 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
**示例:** **示例:**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle) Notification.isDistributedEnabledByBundle(bundle).then((data) => {
.then((data) => { console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
console.info("isDistributedEnabledByBundle sucess, data: " + JSON.stringify(data)); });
});
``` ```
...@@ -2994,7 +2990,7 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void ...@@ -2994,7 +2990,7 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------- | ---- | -------------------------- | | -------- | --------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | 是 | 获取通知提醒方式的回调函数。 | | callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | 是 | 获取通知提醒方式的回调函数。 |
**错误码:** **错误码:**
...@@ -3036,7 +3032,7 @@ getDeviceRemindType(): Promise\<DeviceRemindType\> ...@@ -3036,7 +3032,7 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
| 类型 | 说明 | | 类型 | 说明 |
| ------------------ | --------------- | | ------------------ | --------------- |
| Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise方式返回通知的提醒方式的结果。 | | Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise方式返回获取通知提醒方式的结果。 |
**错误码:** **错误码:**
...@@ -3049,10 +3045,9 @@ getDeviceRemindType(): Promise\<DeviceRemindType\> ...@@ -3049,10 +3045,9 @@ getDeviceRemindType(): Promise\<DeviceRemindType\>
**示例:** **示例:**
```javascript ```javascript
Notification.getDeviceRemindType() Notification.getDeviceRemindType().then((data) => {
.then((data) => { console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data)); });
});
``` ```
...@@ -3070,12 +3065,12 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ...@@ -3070,12 +3065,12 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | | -------------------- | ------------------------------------------- | ---- | ---------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback | 是 | 发布代理通知的回调方法。 | | callback | AsyncCallback | 是 | 发布代理通知的回调方法。 |
**错误码:** **错误码:**
...@@ -3093,7 +3088,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ...@@ -3093,7 +3088,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
```js ```js
//publishAsBundle回调 //publishAsBundle回调
function publishAsBundleCallback(err) { function callback(err) {
if (err) { if (err) {
console.info("publishAsBundle failed " + JSON.stringify(err)); console.info("publishAsBundle failed " + JSON.stringify(err));
} else { } else {
...@@ -3101,11 +3096,11 @@ function publishAsBundleCallback(err) { ...@@ -3101,11 +3096,11 @@ function publishAsBundleCallback(err) {
} }
} }
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
//通知Request对象 // NotificationRequest对象
let notificationRequest = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -3115,9 +3110,9 @@ let notificationRequest = { ...@@ -3115,9 +3110,9 @@ let notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback); Notification.publishAsBundle(request, representativeBundle, userId, callback);
``` ```
## Notification.publishAsBundle ## Notification.publishAsBundle
...@@ -3137,9 +3132,9 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ...@@ -3137,9 +3132,9 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | | request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**错误码:** **错误码:**
...@@ -3157,11 +3152,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ...@@ -3157,11 +3152,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user
```js ```js
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
//通知Request对象 // NotificationRequest对象
var notificationRequest = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -3171,10 +3166,10 @@ var notificationRequest = { ...@@ -3171,10 +3166,10 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => { Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle sucess"); console.info("publishAsBundle success");
}); });
``` ```
...@@ -3198,7 +3193,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac ...@@ -3198,7 +3193,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
| -------------------- | ------------- | ---- | ------------------------ | | -------------------- | ------------- | ---- | ------------------------ |
| id | number | 是 | 通知ID。 | | id | number | 是 | 通知ID。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback | 是 | 取消代理通知的回调方法。 | | callback | AsyncCallback | 是 | 取消代理通知的回调方法。 |
**错误码:** **错误码:**
...@@ -3214,7 +3209,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac ...@@ -3214,7 +3209,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac
**示例:** **示例:**
```js ```js
//cancelAsBundle // cancelAsBundle
function cancelAsBundleCallback(err) { function cancelAsBundleCallback(err) {
if (err) { if (err) {
console.info("cancelAsBundle failed " + JSON.stringify(err)); console.info("cancelAsBundle failed " + JSON.stringify(err));
...@@ -3223,9 +3218,9 @@ function cancelAsBundleCallback(err) { ...@@ -3223,9 +3218,9 @@ function cancelAsBundleCallback(err) {
} }
} }
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
``` ```
...@@ -3234,7 +3229,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallb ...@@ -3234,7 +3229,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallb
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\> cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
发布代理通知(Promise形式)。 取消代理通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3250,7 +3245,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis ...@@ -3250,7 +3245,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis
| -------------------- | ------ | ---- | ------------------ | | -------------------- | ------ | ---- | ------------------ |
| id | number | 是 | 通知ID。 | | id | number | 是 | 通知ID。 |
| representativeBundle | string | 是 | 被代理应用的包名。 | | representativeBundle | string | 是 | 被代理应用的包名。 |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**错误码:** **错误码:**
...@@ -3266,9 +3261,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis ...@@ -3266,9 +3261,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis
```js ```js
// 被代理应用的包名 // 被代理应用的包名
let representativeBundle = "com.example.demo" let representativeBundle = "com.example.demo";
// 接收通知的用户ID // 用户ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success"); console.info("cancelAsBundle success");
...@@ -3279,7 +3274,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { ...@@ -3279,7 +3274,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
定指定类型的渠道使能状态(Callback形式)。 置指定应用的指定渠道类型的使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3291,10 +3286,10 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, ...@@ -3291,10 +3286,10 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean,
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 指定渠道类型。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设渠道使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设渠道使能回调函数。 |
**错误码:** **错误码:**
...@@ -3308,7 +3303,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, ...@@ -3308,7 +3303,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean,
**示例:** **示例:**
```js ```js
//setNotificationEnableSlot // setNotificationEnableSlot
function setNotificationEnableSlotCallback(err) { function setNotificationEnableSlotCallback(err) {
if (err) { if (err) {
console.info("setNotificationEnableSlot failed " + JSON.stringify(err)); console.info("setNotificationEnableSlot failed " + JSON.stringify(err));
...@@ -3328,7 +3323,7 @@ Notification.setNotificationEnableSlot( ...@@ -3328,7 +3323,7 @@ Notification.setNotificationEnableSlot(
setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void>
定指定类型的渠道使能状态(Promise形式)。 置指定应用的指定渠道类型的使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3340,8 +3335,8 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean) ...@@ -3340,8 +3335,8 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**错误码:** **错误码:**
...@@ -3356,12 +3351,12 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean) ...@@ -3356,12 +3351,12 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean)
**示例:** **示例:**
```js ```js
//setNotificationEnableSlot // setNotificationEnableSlot
Notification.setNotificationEnableSlot( Notification.setNotificationEnableSlot(
{ bundle: "ohos.samples.notification", }, { bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION, Notification.SlotType.SOCIAL_COMMUNICATION,
true).then(() => { true).then(() => {
console.info("setNotificationEnableSlot sucess"); console.info("setNotificationEnableSlot success");
}); });
``` ```
...@@ -3369,7 +3364,7 @@ Notification.setNotificationEnableSlot( ...@@ -3369,7 +3364,7 @@ Notification.setNotificationEnableSlot(
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
获取指定类型的渠道使能状态(Callback形式)。 获取指定应用的指定渠道类型的使能状态(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3381,9 +3376,9 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC ...@@ -3381,9 +3376,9 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
| callback | AsyncCallback\<boolean\> | 是 | 设定渠道使能回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 获取渠道使能状态回调函数。 |
**错误码:** **错误码:**
...@@ -3397,7 +3392,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC ...@@ -3397,7 +3392,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
**示例:** **示例:**
```js ```js
//isNotificationSlotEnabled // isNotificationSlotEnabled
function getEnableSlotCallback(err, data) { function getEnableSlotCallback(err, data) {
if (err) { if (err) {
console.info("isNotificationSlotEnabled failed " + JSON.stringify(err)); console.info("isNotificationSlotEnabled failed " + JSON.stringify(err));
...@@ -3416,7 +3411,7 @@ Notification.isNotificationSlotEnabled( ...@@ -3416,7 +3411,7 @@ Notification.isNotificationSlotEnabled(
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\> isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
获取指定类型的渠道使能状态(Promise形式)。 获取指定应用的指定渠道类型的使能状态(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3428,8 +3423,8 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea ...@@ -3428,8 +3423,8 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 |
| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
**返回值:** **返回值:**
...@@ -3449,13 +3444,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea ...@@ -3449,13 +3444,11 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
**示例:** **示例:**
```js ```js
//isNotificationSlotEnabled // isNotificationSlotEnabled
Notification.isNotificationSlotEnabled( Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
{ bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => {
Notification.SlotType.SOCIAL_COMMUNICATION console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
).then((data) => { });
console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
});
``` ```
...@@ -3475,8 +3468,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: ...@@ -3475,8 +3468,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
| enable | boolean | 是 | 是否启用。<br>true:启用。<br>false:禁用。 | | enable | boolean | 是 | 是否启用。 |
| callback | AsyncCallback\<void\> | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。 |
**错误码:** **错误码:**
...@@ -3494,7 +3487,7 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: ...@@ -3494,7 +3487,7 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback:
let userId = 100; let userId = 100;
let enable = true; let enable = true;
function setSyncNotificationEnabledWithoutAppCallback(err) { function callback(err) {
if (err) { if (err) {
console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err)); console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err));
} else { } else {
...@@ -3502,7 +3495,7 @@ function setSyncNotificationEnabledWithoutAppCallback(err) { ...@@ -3502,7 +3495,7 @@ function setSyncNotificationEnabledWithoutAppCallback(err) {
} }
} }
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback); Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
``` ```
...@@ -3522,8 +3515,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\< ...@@ -3522,8 +3515,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
| enable | boolean | 是 | 是否启用。<br>true:启用。<br>false:禁用。 | | enable | boolean | 是 | 是否启用。 |
**返回值:** **返回值:**
...@@ -3546,13 +3539,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\< ...@@ -3546,13 +3539,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<
let userId = 100; let userId = 100;
let enable = true; let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable) Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
.then(() => { console.info('setSyncNotificationEnabledWithoutApp success');
console.info('setSyncNotificationEnabledWithoutApp'); }).catch((err) => {
}) console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
.catch((err) => { });
console.info('setSyncNotificationEnabledWithoutApp, err:', err);
});
``` ```
...@@ -3560,7 +3551,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable) ...@@ -3560,7 +3551,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable)
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
获取是否同步通知到未安装应用程序的设备(callback形式)。 获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3572,8 +3563,8 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo ...@@ -3572,8 +3563,8 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback\<boolean\> | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。<br>true: 是。<br>false: 否。 | | callback | AsyncCallback\<boolean\> | 是 | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数。 |
**错误码:** **错误码:**
...@@ -3589,11 +3580,11 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo ...@@ -3589,11 +3580,11 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo
```js ```js
let userId = 100; let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(data, err) { function getSyncNotificationEnabledWithoutAppCallback(err, data) {
if (err) { if (err) {
console.info('getSyncNotificationEnabledWithoutAppCallback, err' + err); console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err);
} else { } else {
console.info('getSyncNotificationEnabledWithoutAppCallback, data' + data); console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data);
} }
} }
...@@ -3605,7 +3596,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEna ...@@ -3605,7 +3596,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEna
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean> getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
获取是否同步通知到未安装应用程序的设备(Promise形式)。 获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -3617,13 +3608,13 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean> ...@@ -3617,13 +3608,13 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| userId | number | 是 | 用户Id。 | | userId | number | 是 | 用户ID。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | 以Promise形式返回获取是否同步通知到未安装应用程序的设备的结果。<br>true: 是。<br>false: 否。 | | Promise\<boolean\> | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果。 |
**错误码:** **错误码:**
...@@ -3638,11 +3629,11 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean> ...@@ -3638,11 +3629,11 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
```js ```js
let userId = 100; let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
Notification.getSyncNotificationEnabledWithoutApp(userId) console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
.then((data) => { }).catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, data:', data); console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
}) });
.catch((err) => { .catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:', err); console.info('getSyncNotificationEnabledWithoutApp, err:', err);
}); });
...@@ -3657,11 +3648,11 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3657,11 +3648,11 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ---- | --- | ------------------------------------- | ------------------------ | | ----- | ------------------------------------- | ---- | ---- | ---------------------- |
| type | 是 | 否 | [DoNotDisturbType](#donotdisturbtype) | 指定免打扰设置的时间类型。 | | type | [DoNotDisturbType](#donotdisturbtype) | 是 | 是 | 免打扰设置的时间类型。 |
| begin | 是 | 否 | Date | 指定免打扰设置的起点时间。 | | begin | Date | 是 | 是 | 免打扰设置的起点时间。 |
| end | 是 | 否 | Date | 指定免打扰设置的终点时间。 | | end | Date | 是 | 是 | 免打扰设置的终点时间。 |
...@@ -3708,10 +3699,10 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3708,10 +3699,10 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ---- | --- | ------ | ------ | | ------ | ------ |---- | --- | ------ |
| bundle | 是 | 是 | string | 包名。 | | bundle | string | 是 | 是 | 应用的包信息。 |
| uid | 是 | 是 | number | 用户id。 | | uid | number | 是 | 是 | 用户ID。 |
## SlotType ## SlotType
...@@ -3733,12 +3724,12 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3733,12 +3724,12 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | --- | ---- | ----------------------------------------------- | ------------------------- | | --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | 是 | 是 | string | 按钮标题。 | | title | string | 是 | 是 | 按钮标题。 |
| wantAgent | 是 | 是 | WantAgent | 点击按钮时触发的WantAgent。 | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 点击按钮时触发的WantAgent。 |
| extras | 是 | 是 | { [key: string]: any } | 按钮扩展信息。 | | extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 |
| userInput | 是 | 是 | [NotificationUserInput](#notificationuserinput) | 用户输入对象实例。 | | userInput | [NotificationUserInput](#notificationuserinput) | 是 | 是 | 用户输入对象实例。 |
## NotificationBasicContent ## NotificationBasicContent
...@@ -3747,11 +3738,11 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3747,11 +3738,11 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ---- | ---- | ------ | ---------------------------------- | | -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | 是 | 是 | string | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | 是 | 是 | string | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
## NotificationLongTextContent ## NotificationLongTextContent
...@@ -3760,14 +3751,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3760,14 +3751,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ---- | --- | ------ | -------------------------------- | | -------------- | ------ | ---- | --- | -------------------------------- |
| title | 是 | 是 | string | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | 是 | 是 | string | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| longText | 是 | 是 | string | 通知的长文本。 | | longText | string | 是 | 是 | 通知的长文本。 |
| briefText | 是 | 是 | string | 通知概要内容,是对通知内容的总结。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | 是 | 是 | string | 通知展开时的标题。 | | expandedTitle | string | 是 | 是 | 通知展开时的标题。 |
## NotificationMultiLineContent ## NotificationMultiLineContent
...@@ -3776,14 +3767,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3776,14 +3767,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | --- | --- | --------------- | -------------------------------- | | -------------- | --------------- | --- | --- | -------------------------------- |
| title | 是 | 是 | string | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | 是 | 是 | string | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| briefText | 是 | 是 | string | 通知概要内容,是对通知内容的总结。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| longTitle | 是 | 是 | string | 通知展开时的标题。 | | longTitle | string | 是 | 是 | 通知展开时的标题。 |
| lines | 是 | 是 | Array\<string\> | 通知的多行文本。 | | lines | Array\<string\> | 是 | 是 | 通知的多行文本。 |
## NotificationPictureContent ## NotificationPictureContent
...@@ -3792,14 +3783,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3792,14 +3783,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ---- | --- | -------------- | -------------------------------- | | -------------- | -------------- | ---- | --- | -------------------------------- |
| title | 是 | 是 | string | 通知标题。 | | title | string | 是 | 是 | 通知标题。 |
| text | 是 | 是 | string | 通知内容。 | | text | string | 是 | 是 | 通知内容。 |
| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | | additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 |
| briefText | 是 | 是 | string | 通知概要内容,是对通知内容的总结。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 |
| expandedTitle | 是 | 是 | string | 通知展开时的标题。 | | expandedTitle | string | 是 | 是 | 通知展开时的标题。 |
| picture | 是 | 是 | image.PixelMap | 通知的图片内容。 | | picture | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知的图片内容。 |
## NotificationContent ## NotificationContent
...@@ -3808,13 +3799,13 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3808,13 +3799,13 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | ---- | --- | ------------------------------------------------------------ | ------------------ | | ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | 是 | 是 | [ContentType](#contenttype) | 通知内容类型。 | | contentType | [ContentType](#contenttype) | 是 | 是 | 通知内容类型。 |
| normal | 是 | 是 | [NotificationBasicContent](#notificationbasiccontent) | 基本类型通知内容。 | | normal | [NotificationBasicContent](#notificationbasiccontent) | 是 | 是 | 基本类型通知内容。 |
| longText | 是 | 是 | [NotificationLongTextContent](#notificationlongtextcontent) | 长文本类型通知内容。 | | longText | [NotificationLongTextContent](#notificationlongtextcontent) | 是 | 是 | 长文本类型通知内容。 |
| multiLine | 是 | 是 | [NotificationMultiLineContent](#notificationmultilinecontent) | 多行类型通知内容。 | | multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | 是 | 是 | 多行类型通知内容。 |
| picture | 是 | 是 | [NotificationPictureContent](#notificationpicturecontent) | 图片类型通知内容。 | | picture | [NotificationPictureContent](#notificationpicturecontent) | 是 | 是 | 图片类型通知内容。 |
## NotificationFlagStatus ## NotificationFlagStatus
...@@ -3825,7 +3816,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3825,7 +3816,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统接口**:此接口为系统接口,三方应用不支持调用。 **系统接口**:此接口为系统接口,三方应用不支持调用。
| 名称 | 值 | 描述 | | 名称 | 值 | 说明 |
| -------------- | --- | --------------------------------- | | -------------- | --- | --------------------------------- |
| TYPE_NONE | 0 | 默认标志。 | | TYPE_NONE | 0 | 默认标志。 |
| TYPE_OPEN | 1 | 通知标志打开。 | | TYPE_OPEN | 1 | 通知标志打开。 |
...@@ -3838,10 +3829,10 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3838,10 +3829,10 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------------- | ---- | ---- | ---------------------- | --------------------------------- | | ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | 是 | 否 | NotificationFlagStatus | 是否启用声音提示。 | | soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用声音提示。 |
| vibrationEnabled | 是 | 否 | NotificationFlagStatus | 是否启用振动提醒功能。 | | vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用振动提醒功能。 |
## NotificationRequest ## NotificationRequest
...@@ -3850,45 +3841,45 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3850,45 +3841,45 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------- | ---- | --- | --------------------------------------------- | -------------------------- | | --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | 是 | 是 | [NotificationContent](#notificationcontent) | 通知内容。 | | content | [NotificationContent](#notificationcontent) | 是 | 是 | 通知内容。 |
| id | 是 | 是 | number | 通知ID。 | | id | number | 是 | 是 | 通知ID。 |
| slotType | 是 | 是 | [SlotType](#slottype) | 通道类型。 | | slotType | [SlotType](#slottype) | 是 | 是 | 通道类型。 |
| isOngoing | 是 | 是 | boolean | 是否进行时通知。 | | isOngoing | boolean | 是 | 是 | 是否进行时通知。 |
| isUnremovable | 是 | 是 | boolean | 是否可移除。 | | isUnremovable | boolean | 是 | 是 | 是否可移除。 |
| deliveryTime | 是 | 是 | number | 通知发送时间。 | | deliveryTime | number | 是 | 是 | 通知发送时间。 |
| tapDismissed | 是 | 是 | boolean | 通知是否自动清除。 | | tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 |
| autoDeletedTime | 是 | 是 | number | 自动清除的时间。 | | autoDeletedTime | number | 是 | 是 | 自动清除的时间。 |
| wantAgent | 是 | 是 | WantAgent | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | | wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 |
| extraInfo | 是 | 是 | {[key: string]: any} | 扩展参数。 | | extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 |
| color | 是 | 是 | number | 通知背景颜色。暂不支持。 | | color | number | 是 | 是 | 通知背景颜色。预留能力,暂未支持。 |
| colorEnabled | 是 | 是 | boolean | 通知背景颜色是否使能。暂不支持。 | | colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。预留能力,暂未支持。 |
| isAlertOnce | 是 | 是 | boolean | 设置是否仅有一次此通知警报。 | | isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知提醒。 |
| isStopwatch | 是 | 是 | boolean | 是否显示已用时间。 | | isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 |
| isCountDown | 是 | 是 | boolean | 是否显示倒计时时间。 | | isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 |
| isFloatingIcon | 是 | 是 | boolean | 是否显示状态栏图标。 | | isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 |
| label | 是 | 是 | string | 通知标签。 | | label | string | 是 | 是 | 通知标签。 |
| badgeIconStyle | 是 | 是 | number | 通知角标类型。 | | badgeIconStyle | number | 是 | 是 | 通知角标类型。 |
| showDeliveryTime | 是 | 是 | boolean | 是否显示分发时间。 | | showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 |
| actionButtons | 是 | 是 | Array\<[NotificationActionButton](#notificationactionbutton)\> | 通知按钮,最多两个按钮。 | | actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | 是 | 是 | 通知按钮,最多两个按钮。 |
| smallIcon | 是 | 是 | PixelMap | 通知小图标。 | | smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知小图标。可选字段,大小不超过30KB。 |
| largeIcon | 是 | 是 | PixelMap | 通知大图标。 | | largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知大图标。可选字段,大小不超过30KB。 |
| creatorBundleName | 是 | 否 | string | 创建通知的包名。 | | creatorBundleName | string | 是 | 否 | 创建通知的包名。 |
| creatorUid | 是 | 否 | number | 创建通知的UID。 | | creatorUid | number | 是 | 否 | 创建通知的UID。 |
| creatorPid | 是 | 否 | number | 创建通知的PID。 | | creatorPid | number | 是 | 否 | 创建通知的PID。 |
| creatorUserId | 是 | 否 | number | 创建通知的UserId。 | | creatorUserId| number | 是 | 否 | 创建通知的UserId。 |
| hashCode | 是 | 否 | string | 通知唯一标识。 | | hashCode | string | 是 | 否 | 通知唯一标识。 |
| classification | 是 | 是 | string | 通知分类。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | | classification | string | 是 | 是 | 通知分类。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| groupName | 是 | 是 | string | 组通知名称。 | | groupName| string | 是 | 是 | 组通知名称。 |
| template | 是 | 是 | [NotificationTemplate](#notificationtemplate) | 通知模板。 | | template | [NotificationTemplate](#notificationtemplate) | 是 | 是 | 通知模板。 |
| isRemoveAllowed | 是 | 否 | boolean | 通知是否能被移除。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | | isRemoveAllowed | boolean | 是 | 否 | 通知是否能被移除。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| source | 是 | 否 | number | 通知源。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | | source | number | 是 | 否 | 通知源。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| distributedOption | 是 | 是 | [DistributedOptions](#distributedoptions) | 分布式通知的选项。 | | distributedOption | [DistributedOptions](#distributedoptions) | 是 | 是 | 分布式通知的选项。 |
| deviceId | 是 | 否 | string | 通知源的deviceId。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | | deviceId | string | 是 | 否 | 通知源的deviceId。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
| notificationFlags | 是 | 否 | [NotificationFlags](#notificationflags) | 获取NotificationFlags。 | | notificationFlags | [NotificationFlags](#notificationflags) | 是 | 否 | 获取NotificationFlags。 |
| removalWantAgent | 是 | 是 | WantAgent | 当移除通知时,通知将被重定向到的WantAgent实例。 | | removalWantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 |
| badgeNumber | 是 | 是 | number | 应用程序图标上显示的通知数。 | | badgeNumber | number | 是 | 是 | 应用程序图标上显示的通知数。 |
## DistributedOptions ## DistributedOptions
...@@ -3897,12 +3888,12 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3897,12 +3888,12 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------------------- | ---- | ---- | -------------- | ---------------------------------- | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed | 是 | 是 | boolean | 是否为分布式通知。 | | isDistributed | boolean | 是 | 是 | 是否为分布式通知。 |
| supportDisplayDevices | 是 | 是 | Array\<string> | 可以同步通知到的设备类型。 | | supportDisplayDevices | Array\<string> | 是 | 是 | 可以同步通知到的设备列表。 |
| supportOperateDevices | 是 | 是 | Array\<string> | 可以打开通知的设备。 | | supportOperateDevices | Array\<string> | 是 | 是 | 可以打开通知的设备列表。 |
| remindType | 是 | 否 | number | 通知的提醒方式。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | | remindType | number | 是 | 否 | 通知的提醒方式。<br>**系统API**: 此接口为系统接口,三方应用不支持调用。 |
## NotificationSlot ## NotificationSlot
...@@ -3911,20 +3902,20 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3911,20 +3902,20 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------------- | ---- | --- | --------------------- | ------------------------------------------ | | -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | 是 | 是 | [SlotType](#slottype) | 通道类型。 | | type | [SlotType](#slottype) | 是 | 是 | 通道类型。 |
| level | 是 | 是 | number | 通知级别,不设置则根据通知渠道类型有默认值。 | | level | number | 是 | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 |
| desc | 是 | 是 | string | 通知渠道描述信息。 | | desc | string | 是 | 是 | 通知渠道描述信息。 |
| badgeFlag | 是 | 是 | boolean | 是否显示角标。 | | badgeFlag | boolean | 是 | 是 | 是否显示角标。 |
| bypassDnd | 是 | 是 | boolean | 置是否在系统中绕过免打扰模式。 | | bypassDnd | boolean | 是 | 是 | 置是否在系统中绕过免打扰模式。 |
| lockscreenVisibility | 是 | 是 | number | 在锁定屏幕上显示通知的模式。 | | lockscreenVisibility | number | 是 | 是 | 在锁定屏幕上显示通知的模式。 |
| vibrationEnabled | 是 | 是 | boolean | 是否可振动。 | | vibrationEnabled | boolean | 是 | 是 | 是否可振动。 |
| sound | 是 | 是 | string | 通知提示音。 | | sound | string | 是 | 是 | 通知提示音。 |
| lightEnabled | 是 | 是 | boolean | 是否闪灯。 | | lightEnabled | boolean | 是 | 是 | 是否闪灯。 |
| lightColor | 是 | 是 | number | 通知灯颜色。 | | lightColor | number | 是 | 是 | 通知灯颜色。 |
| vibrationValues | 是 | 是 | Array\<number\> | 通知振动样式。 | | vibrationValues | Array\<number\> | 是 | 是 | 通知振动样式。 |
| enabled<sup>9+</sup> | 是 | 否 | boolean | 此通知插槽中的启停状态。 | | enabled<sup>9+</sup> | boolean | 是 | 否 | 此通知插槽中的启停状态。 |
## NotificationTemplate ## NotificationTemplate
...@@ -3933,7 +3924,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3933,7 +3924,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ---- | ---------------------- | ---- | ---- | ---------- | | ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | 是 | 是 | 模板名称。 | | name | string | 是 | 是 | 模板名称。 |
| data | {[key:string]: Object} | 是 | 是 | 模板数据。 | | data | {[key:string]: Object} | 是 | 是 | 模板数据。 |
...@@ -3945,9 +3936,9 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3945,9 +3936,9 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | --- | ---- | ------ | ----------------------------- | | -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | 是 | 是 | string | 用户输入时用于标识此输入的key。 | | inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 |
## DeviceRemindType ## DeviceRemindType
...@@ -3956,7 +3947,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3956,7 +3947,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 值 | 描述 | | 名称 | 值 | 说明 |
| -------------------- | --- | --------------------------------- | | -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND | 0 | 设备未被使用,无需提醒。 | | IDLE_DONOT_REMIND | 0 | 设备未被使用,无需提醒。 |
| IDLE_REMIND | 1 | 提醒设备未被使用。 | | IDLE_REMIND | 1 | 提醒设备未被使用。 |
...@@ -3970,7 +3961,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3970,7 +3961,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 值 | 描述 | | 名称 | 值 | 说明 |
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| TYPE_NORMAL | 0 | 一般通知。 | | TYPE_NORMAL | 0 | 一般通知。 |
| TYPE_CONTINUOUS | 1 | 连续通知。 | | TYPE_CONTINUOUS | 1 | 连续通知。 |
......
...@@ -28,10 +28,10 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c ...@@ -28,10 +28,10 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ---------------- | | ---------- | ------------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 订阅信息。 | | info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 通知订阅信息。 |
| callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 | | callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 |
**错误码:** **错误码:**
...@@ -56,12 +56,12 @@ function subscribeCallback(err) { ...@@ -56,12 +56,12 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
var info = { let info = {
bundleNames: ["bundleName1","bundleName2"] bundleNames: ["bundleName1","bundleName2"]
} };
NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); NotificationSubscribe.subscribe(subscriber, info, subscribeCallback);
``` ```
...@@ -71,7 +71,7 @@ NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); ...@@ -71,7 +71,7 @@ NotificationSubscribe.subscribe(subscriber, info, subscribeCallback);
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
订阅通知并指定订阅信息(callback形式)。 订阅当前用户下所有应用的通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -81,7 +81,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): ...@@ -81,7 +81,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------- | ---- | ---------------- | | ---------- | ---------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 |
| callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 | | callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 |
...@@ -107,9 +107,9 @@ function subscribeCallback(err) { ...@@ -107,9 +107,9 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); NotificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -129,10 +129,10 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ...@@ -129,10 +129,10 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------ | | ---------- | ------------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 订阅信息。 | | info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 通知订阅信息。 |
**错误码:** **错误码:**
...@@ -146,17 +146,13 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ...@@ -146,17 +146,13 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
```js ```js
function onConsumeCallback(data) { function onConsumeCallback(data) {
if (err) { console.info("Consume callback: " + JSON.stringify(data));
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe success");
}
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber).then(() => { NotificationSubscribe.subscribe(subscriber).then(() => {
console.info("subscribe sucess"); console.info("subscribe success");
}); });
``` ```
...@@ -176,7 +172,7 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>) ...@@ -176,7 +172,7 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------- | ---- | -------------------- | | ---------- | ---------------------- | ---- | -------------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 |
| callback | AsyncCallback\<void\> | 是 | 取消订阅动作回调函数。 | | callback | AsyncCallback\<void\> | 是 | 取消订阅动作回调函数。 |
...@@ -199,12 +195,12 @@ function unsubscribeCallback(err) { ...@@ -199,12 +195,12 @@ function unsubscribeCallback(err) {
console.info("unsubscribe success"); console.info("unsubscribe success");
} }
} }
function onCancelCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onDisconnect: onDisconnectCallback
} };
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
...@@ -224,7 +220,7 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> ...@@ -224,7 +220,7 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------- | ---- | ------------ | | ---------- | ---------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 |
...@@ -239,14 +235,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> ...@@ -239,14 +235,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**示例:** **示例:**
```js ```js
function onCancelCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onDisconnect: onDisconnectCallback
}; };
NotificationSubscribe.unsubscribe(subscriber).then(() => { NotificationSubscribe.unsubscribe(subscriber).then(() => {
console.info("unsubscribe sucess"); console.info("unsubscribe success");
}); });
``` ```
...@@ -266,9 +262,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -266,9 +262,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------- | ----------------------------------| ---- | -------------------- | | --------------- | ----------------------------------| ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 |
...@@ -293,14 +289,14 @@ function removeCallback(err) { ...@@ -293,14 +289,14 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
``` ```
...@@ -320,9 +316,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -320,9 +316,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------- | --------------- | ---- | ---------- | | --------------- | --------------- | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
...@@ -339,16 +335,16 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -339,16 +335,16 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
**示例:** **示例:**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => { NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove sucess"); console.info("remove success");
}); });
``` ```
...@@ -368,9 +364,9 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): ...@@ -368,9 +364,9 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | 是 | 通知唯一ID。 | | hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](#onconsume)回调的入参[SubscribeCallbackData](#subscribecallbackdata)获取其内部[NotificationRequest](#notificationrequest)对象中的hashCode。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 |
...@@ -386,7 +382,7 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): ...@@ -386,7 +382,7 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
**示例:** **示例:**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
function removeCallback(err) { function removeCallback(err) {
if (err) { if (err) {
...@@ -395,7 +391,7 @@ function removeCallback(err) { ...@@ -395,7 +391,7 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason, removeCallback); NotificationSubscribe.remove(hashCode, reason, removeCallback);
``` ```
...@@ -415,7 +411,7 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\> ...@@ -415,7 +411,7 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------- | ---- | ---------- | | -------- | ---------- | ---- | ---------- |
| hashCode | string | 是 | 通知唯一ID。 | | hashCode | string | 是 | 通知唯一ID。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
...@@ -432,10 +428,10 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\> ...@@ -432,10 +428,10 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
**示例:** **示例:**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason).then(() => { NotificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove sucess"); console.info("remove success");
}); });
``` ```
...@@ -445,7 +441,7 @@ NotificationSubscribe.remove(hashCode, reason).then(() => { ...@@ -445,7 +441,7 @@ NotificationSubscribe.remove(hashCode, reason).then(() => {
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
删除指定的所有通知(Callback形式)。 删除指定应用的所有通知(Callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -455,10 +451,10 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void ...@@ -455,10 +451,10 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------- | | -------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定的所有通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定应用的所有通知回调函数。 |
**错误码:** **错误码:**
...@@ -479,9 +475,9 @@ function removeAllCallback(err) { ...@@ -479,9 +475,9 @@ function removeAllCallback(err) {
console.info("removeAll success"); console.info("removeAll success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
NotificationSubscribe.removeAll(bundle, removeAllCallback); NotificationSubscribe.removeAll(bundle, removeAllCallback);
``` ```
...@@ -501,7 +497,7 @@ removeAll(callback: AsyncCallback\<void\>): void ...@@ -501,7 +497,7 @@ removeAll(callback: AsyncCallback\<void\>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void\> | 是 | 删除所有通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除所有通知回调函数。 |
...@@ -533,7 +529,7 @@ NotificationSubscribe.removeAll(removeAllCallback); ...@@ -533,7 +529,7 @@ NotificationSubscribe.removeAll(removeAllCallback);
removeAll(bundle?: BundleOption): Promise\<void\> removeAll(bundle?: BundleOption): Promise\<void\>
删除所有通知(Promise形式)。 删除指定应用的所有通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -543,9 +539,9 @@ removeAll(bundle?: BundleOption): Promise\<void\> ...@@ -543,9 +539,9 @@ removeAll(bundle?: BundleOption): Promise\<void\>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 否 | 指定包信息。 | | bundle | [BundleOption](#bundleoption) | 否 | 指定应用的包信息。 |
**错误码:** **错误码:**
...@@ -559,8 +555,9 @@ removeAll(bundle?: BundleOption): Promise\<void\> ...@@ -559,8 +555,9 @@ removeAll(bundle?: BundleOption): Promise\<void\>
**示例:** **示例:**
```js ```js
// 不指定应用时,删除所有通知
NotificationSubscribe.removeAll().then(() => { NotificationSubscribe.removeAll().then(() => {
console.info("removeAll sucess"); console.info("removeAll success");
}); });
``` ```
...@@ -568,7 +565,7 @@ NotificationSubscribe.removeAll().then(() => { ...@@ -568,7 +565,7 @@ NotificationSubscribe.removeAll().then(() => {
removeAll(userId: number, callback: AsyncCallback\<void>): void removeAll(userId: number, callback: AsyncCallback\<void>): void
删除所有通知(callback形式)。 删除指定用户下的所有通知(callback形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -578,10 +575,10 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void ...@@ -578,10 +575,10 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
| callback | AsyncCallback\<void\> | 是 | 删除所有通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定用户所有通知回调函数。 |
**错误码:** **错误码:**
...@@ -603,7 +600,7 @@ function removeAllCallback(err) { ...@@ -603,7 +600,7 @@ function removeAllCallback(err) {
} }
} }
var userId = 1 let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); NotificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
...@@ -612,7 +609,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback); ...@@ -612,7 +609,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback);
removeAll(userId: number): Promise\<void> removeAll(userId: number): Promise\<void>
删除所有通知(Promise形式)。 删除指定用户下的所有通知(Promise形式)。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -622,9 +619,9 @@ removeAll(userId: number): Promise\<void> ...@@ -622,9 +619,9 @@ removeAll(userId: number): Promise\<void>
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| userId | number | 是 | 接收通知用户的Id。 | | userId | number | 是 | 用户ID。 |
**错误码:** **错误码:**
...@@ -646,7 +643,7 @@ function removeAllCallback(err) { ...@@ -646,7 +643,7 @@ function removeAllCallback(err) {
} }
} }
var userId = 1 let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); NotificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
...@@ -655,7 +652,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback); ...@@ -655,7 +652,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback);
## NotificationSubscriber ## NotificationSubscriber
提供订阅者接收到新通知或取消通知时的回调方法。 作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
...@@ -663,7 +660,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback); ...@@ -663,7 +660,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback);
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
接收通知回调函数。 接收到新通知的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -673,7 +670,7 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void ...@@ -673,7 +670,7 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | | data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 接收到的通知信息。 |
**示例:** **示例:**
...@@ -692,7 +689,7 @@ function onConsumeCallback(data) { ...@@ -692,7 +689,7 @@ function onConsumeCallback(data) {
console.info('===> onConsume callback req.id:' + req.id); console.info('===> onConsume callback req.id:' + req.id);
}; };
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
...@@ -703,7 +700,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -703,7 +700,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
删除通知回调函数。 取消通知的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -713,7 +710,7 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void ...@@ -713,7 +710,7 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | | data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 需要取消的通知信息。 |
**示例:** **示例:**
...@@ -732,7 +729,7 @@ function onCancelCallback(data) { ...@@ -732,7 +729,7 @@ function onCancelCallback(data) {
console.info('===> onCancel callback req.id:' + req.id); console.info('===> onCancel callback req.id:' + req.id);
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
...@@ -743,7 +740,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -743,7 +740,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
更新通知排序回调函数。 更新通知排序回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -753,7 +750,7 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void ...@@ -753,7 +750,7 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 回调返回接收到的通知信息。 | | data | [NotificationSortingMap](#notificationsortingmap) | 是 | 最新的通知排序列表。 |
**示例:** **示例:**
...@@ -766,11 +763,11 @@ function subscribeCallback(err) { ...@@ -766,11 +763,11 @@ function subscribeCallback(err) {
} }
}; };
function onUpdateCallback() { function onUpdateCallback(map) {
console.info('===> onUpdate in test'); console.info('===> onUpdateCallback map:' + JSON.stringify(map));
} }
var subscriber = { let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
...@@ -781,7 +778,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -781,7 +778,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
onConnect?:() => void onConnect?:() => void
注册订阅回调函数。 订阅完成的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -802,7 +799,7 @@ function onConnectCallback() { ...@@ -802,7 +799,7 @@ function onConnectCallback() {
console.info('===> onConnect in test'); console.info('===> onConnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
...@@ -813,7 +810,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -813,7 +810,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
onDisconnect?:() => void onDisconnect?:() => void
取消订阅回调函数。 取消订阅回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -829,16 +826,30 @@ function subscribeCallback(err) { ...@@ -829,16 +826,30 @@ function subscribeCallback(err) {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
}; };
function unsubscribeCallback(err) {
if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err));
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() { function onDisconnectCallback() {
console.info('===> onDisconnect in test'); console.info('===> onDisconnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
// 订阅通知后会收到onConnect回调
NotificationSubscribe.subscribe(subscriber, subscribeCallback); NotificationSubscribe.subscribe(subscriber, subscribeCallback);
// 取消订阅后会收到onDisconnect回调
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
### onDestroy ### onDestroy
...@@ -866,7 +877,7 @@ function onDestroyCallback() { ...@@ -866,7 +877,7 @@ function onDestroyCallback() {
console.info('===> onDestroy in test'); console.info('===> onDestroy in test');
} }
var subscriber = { let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
...@@ -877,7 +888,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -877,7 +888,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void
免打扰时间选项变更回调函数。 免打扰时间选项发生变更时的回调函数。
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -900,11 +911,11 @@ function subscribeCallback(err) { ...@@ -900,11 +911,11 @@ function subscribeCallback(err) {
} }
}; };
function onDoNotDisturbDateChangeCallback() { function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange in test'); console.info('===> onDoNotDisturbDateChange:' + mode);
} }
var subscriber = { let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
...@@ -945,7 +956,7 @@ function onEnabledNotificationChangedCallback(callbackData) { ...@@ -945,7 +956,7 @@ function onEnabledNotificationChangedCallback(callbackData) {
console.info("enable: ", callbackData.enable); console.info("enable: ", callbackData.enable);
}; };
var subscriber = { let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
...@@ -956,19 +967,19 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -956,19 +967,19 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ---- | ---- | ------ | -------- | | ------ | ------ |---- | --- | ------ |
| bundle | 是 | 是 | string | 包名。 | | bundle | string | 是 | 是 | 应用的包信息。 |
| uid | 是 | 是 | number | 用户id。 | | uid | number | 是 | 是 | 用户ID。 |
## NotificationKey ## NotificationKey
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ---- | ---- | ------ | ---------- | | ----- | ------ | ---- | --- | -------- |
| id | 是 | 是 | number | 通知ID。 | | id | number | 是 | 是 | 通知ID。 |
| label | 是 | 是 | string | 通知标签。 | | label | string | 是 | 是 | 通知标签。 |
## SubscribeCallbackData ## SubscribeCallbackData
...@@ -976,13 +987,13 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -976,13 +987,13 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ---- | --- | ------------------------------------------------- | -------- | | --------------- | ------------------------------------------------- | -------- | -------- | -------- |
| request | 是 | 否 | [NotificationRequest](js-apis-notificationManager.md#notificationrequest) | 通知内容。 | | request | [NotificationRequest](js-apis-notificationManager.md#notificationrequest) | 是 | 否 | 通知内容。 |
| sortingMap | 是 | 否 | [NotificationSortingMap](#notificationsortingmap) | 排序信息。 | | sortingMap | [NotificationSortingMap](#notificationsortingmap) | 是 | 否 | 排序信息。 |
| reason | 是 | 否 | number | 删除原因。 | | reason | number | 是 | 否 | 删除原因。 |
| sound | 是 | 否 | string | 通知声音。 | | sound | string | 是 | 否 | 通知声音。 |
| vibrationValues | 是 | 否 | Array\<number\> | 通知震动。 | | vibrationValues | Array\<number\> | 是 | 否 | 通知震动。 |
## EnabledNotificationCallbackData ## EnabledNotificationCallbackData
...@@ -991,11 +1002,11 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -991,11 +1002,11 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 描述 |
| ------ | ---- | --- | ------- | ---------------- | | ------ | ------- | ---------------- | ---------------- | ---------------- |
| bundle | 是 | 否 | string | 应用的包名。 | | bundle | string | 是 | 否 | 应用的包名。 |
| uid | 是 | 否 | number | 应用的uid。 | | uid | number | 是 | 否 | 应用的uid。 |
| enable | 是 | 否 | boolean | 应用通知使能状态。 | | enable | boolean | 是 | 否 | 应用通知使能状态。 |
## NotificationSorting ## NotificationSorting
...@@ -1006,11 +1017,11 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1006,11 +1017,11 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ---- | --- | ------------------------------------- | ------------ | | -------- | ------------------------------------- | ---- | --- | ------------ |
| slot | 是 | 否 | [NotificationSlot](js-apis-notificationManager.md#notificationslot) | 通知通道内容。 | | slot | [NotificationSlot](js-apis-notificationManager.md#notificationslot) | 是 | 否 | 通知通道内容。 |
| hashCode | 是 | 否 | string | 通知唯一标识。 | | hashCode | string | 是 | 否 | 通知唯一标识。 |
| ranking | 是 | 否 | number | 通知排序序号。 | | ranking | number | 是 | 否 | 通知排序序号。 |
## NotificationSortingMap ## NotificationSortingMap
...@@ -1021,10 +1032,10 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1021,10 +1032,10 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---------------- | | -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- |
| sortings | 是 | 否 | {[key: string]: [NotificationSorting](#notificationsorting)} | 通知排序信息数组。 | | sortings | {[key: string]: [NotificationSorting](#notificationsorting)} | 是 | 否 | 通知排序信息数组。 |
| sortedHashCode | 是 | 否 | Array\<string\> | 通知唯一标识数组。 | | sortedHashCode | Array\<string\> | 是 | 否 | 通知唯一标识数组。 |
## NotificationSubscribeInfo ## NotificationSubscribeInfo
...@@ -1035,10 +1046,10 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1035,10 +1046,10 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | --- | ---- | --------------- | ------------------------------- | | ----------- | --------------- | --- | ---- | ------------------------------- |
| bundleNames | 是 | 是 | Array\<string\> | 指定订阅哪些包名的APP发来的通知。 | | bundleNames | Array\<string\> | 是 | 是 | 指定订阅哪些包名的APP发来的通知。 |
| userId | 是 | 是 | number | 指定订阅哪个用户下发来的通知。 | | userId | number | 是 | 是 | 指定订阅哪个用户下发来的通知。 |
## NotificationUserInput ## NotificationUserInput
...@@ -1047,9 +1058,9 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1047,9 +1058,9 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 描述 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | --- | ---- | ------ | ----------------------------- | | -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | 是 | 是 | string | 用户输入时用于标识此输入的key。 | | inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 |
## RemoveReason ## RemoveReason
...@@ -1057,7 +1068,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1057,7 +1068,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 值 | 描述 | | 名称 | 值 | 说明 |
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | 点击通知后删除通知。 | | CLICK_REASON_REMOVE | 1 | 点击通知后删除通知。 |
| CANCEL_REASON_REMOVE | 2 | 用户删除通知。 | | CANCEL_REASON_REMOVE | 2 | 用户删除通知。 |
\ No newline at end of file
...@@ -59,9 +59,9 @@ export default { ...@@ -59,9 +59,9 @@ export default {
clickAction: { clickAction: {
bundleName: 'com.example.testapp', bundleName: 'com.example.testapp',
abilityName: 'notificationDemo', abilityName: 'notificationDemo',
uri: '/path/to/notification', uri: '/path/to/notification'
}, }
}); });
}, }
} }
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册