diff --git a/zh-cn/application-dev/notification/notification-with-wantagent.md b/zh-cn/application-dev/notification/notification-with-wantagent.md index f3c5d56e3d68e137fdf23add81feff70233967ec..51e2029aa0cbfc209d3f2567741e4b8a9fb4d6b6 100644 --- a/zh-cn/application-dev/notification/notification-with-wantagent.md +++ b/zh-cn/application-dev/notification/notification-with-wantagent.md @@ -35,7 +35,7 @@ WantAgent提供了封装行为意图的能力,这里所说的行为意图主 ``` 2. 创建WantAgentInfo信息。 - 场景一:创建拉起Ability的WantAgent的WantAgentInfo信息。 + 场景一:创建拉起Ability的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。 ```ts let wantAgentObj = null; // 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。 @@ -59,7 +59,7 @@ WantAgent提供了封装行为意图的能力,这里所说的行为意图主 } ``` - 场景二:创建发布公共事件的WantAgent的WantAgentInfo信息。 + 场景二:创建发布公共事件的WantAgent的[WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md)信息。 ```ts let wantAgentObj = null; // 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index f92852c7271372e65e035a413f7712952a4906b1..5dd2d435904ed85ce1f21329d384c260d8e7dc06 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -2,11 +2,11 @@ 本模块提供通知管理的能力,包括发布、取消发布通知,创建、获取、移除通知通道,订阅、取消订阅通知,获取通知的使能状态、角标使能状态,获取通知的相关信息等。 -一般情况下,只有系统应用具有通知订阅和取消订阅的权限。 - > **说明:** > > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 通知订阅和取消订阅仅对系统应用开放。 ## 导入模块 @@ -26,13 +26,13 @@ publish(request: NotificationRequest, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | -| callback | AsyncCallback\ | 是 | 被指定的回调方法。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| callback | AsyncCallback\ | 是 | 发布通知的回调方法。 | **示例:** ```js -//publish回调 +// publish回调 function publishCallback(err) { if (err.code) { console.info("publish failed " + JSON.stringify(err)); @@ -40,8 +40,8 @@ function publishCallback(err) { console.info("publish success"); } } -//通知Request对象 -var notificationRequest = { +// 通知Request对象 +let notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -51,8 +51,8 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} -Notification.publish(notificationRequest, publishCallback) +}; +Notification.publish(notificationRequest, publishCallback); ``` @@ -69,13 +69,13 @@ publish(request: NotificationRequest): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | **示例:** ```js -//通知Request对象 -var notificationRequest = { +// 通知Request对象 +let notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -85,9 +85,9 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; Notification.publish(notificationRequest).then(() => { - console.info("publish sucess"); + console.info("publish success"); }); ``` @@ -96,7 +96,7 @@ Notification.publish(notificationRequest).then(() => { publish(request: NotificationRequest, userId: number, callback: AsyncCallback\): void -发布通知(callback形式)。 +发布通知给指定的用户(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -108,14 +108,14 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\ | 是 | 被指定的回调方法。 | **示例:** ```js -//publish回调 +// publish回调 function publishCallback(err) { if (err.code) { console.info("publish failed " + JSON.stringify(err)); @@ -123,10 +123,10 @@ function publishCallback(err) { console.info("publish success"); } } -// 接收通知的用户ID -var userId = 1 -//通知Request对象 -var notificationRequest = { +// 用户ID +let userId = 1; +// 通知Request对象 +let notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -136,7 +136,7 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; Notification.publish(notificationRequest, userId, publishCallback); ``` @@ -144,7 +144,7 @@ Notification.publish(notificationRequest, userId, publishCallback); publish(request: NotificationRequest, userId: number): Promise\ -发布通知(Promise形式)。 +发布通知给指定的用户(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -156,13 +156,13 @@ publish(request: NotificationRequest, userId: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | -| userId | number | 是 | 接收通知用户的Id。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| userId | number | 是 | 用户ID。 | **示例:** ```js -var notificationRequest = { +let notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -172,12 +172,12 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; -var userId = 1 +let userId = 1; Notification.publish(notificationRequest, userId).then(() => { - console.info("publish sucess"); + console.info("publish success"); }); ``` @@ -186,7 +186,7 @@ Notification.publish(notificationRequest, userId).then(() => { cancel(id: number, label: string, callback: AsyncCallback\): void -取消与指定id和label相匹配的已发布通知(callback形式)。 +通过通知ID和通知标签取消已发布的通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -201,7 +201,7 @@ cancel(id: number, label: string, callback: AsyncCallback\): void **示例:** ```js -//cancel回调 +// cancel回调 function cancelCallback(err) { if (err.code) { console.info("cancel failed " + JSON.stringify(err)); @@ -209,7 +209,7 @@ function cancelCallback(err) { console.info("cancel success"); } } -Notification.cancel(0, "label", cancelCallback) +Notification.cancel(0, "label", cancelCallback); ``` @@ -218,7 +218,7 @@ Notification.cancel(0, "label", cancelCallback) cancel(id: number, label?: string): Promise\ -取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 +取消与指定通知ID相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -233,7 +233,7 @@ cancel(id: number, label?: string): Promise\ ```js Notification.cancel(0).then(() => { - console.info("cancel sucess"); + console.info("cancel success"); }); ``` @@ -243,7 +243,7 @@ Notification.cancel(0).then(() => { cancel(id: number, callback: AsyncCallback\): void -取消与指定id相匹配的已发布通知(callback形式)。 +取消与指定通知ID相匹配的已发布通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -257,7 +257,7 @@ cancel(id: number, callback: AsyncCallback\): void **示例:** ```js -//cancel回调 +// cancel回调 function cancelCallback(err) { if (err.code) { console.info("cancel failed " + JSON.stringify(err)); @@ -265,7 +265,7 @@ function cancelCallback(err) { console.info("cancel success"); } } -Notification.cancel(0, cancelCallback) +Notification.cancel(0, cancelCallback); ``` @@ -287,7 +287,7 @@ cancelAll(callback: AsyncCallback\): void **示例:** ```js -//cancel回调 +// cancel回调 function cancelAllCallback(err) { if (err.code) { console.info("cancelAll failed " + JSON.stringify(err)); @@ -295,7 +295,7 @@ function cancelAllCallback(err) { console.info("cancelAll success"); } } -Notification.cancelAll(cancelAllCallback) +Notification.cancelAll(cancelAllCallback); ``` @@ -312,7 +312,7 @@ cancelAll(): Promise\ ```js Notification.cancelAll().then(() => { - console.info("cancelAll sucess"); + console.info("cancelAll success"); }); ``` @@ -340,7 +340,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\): void **示例:** ```js -//addslot回调 +// addslot回调 function addSlotCallBack(err) { if (err.code) { console.info("addSlot failed " + JSON.stringify(err)); @@ -348,11 +348,11 @@ function addSlotCallBack(err) { console.info("addSlot success"); } } -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} -Notification.addSlot(notificationSlot, addSlotCallBack) +}; +Notification.addSlot(notificationSlot, addSlotCallBack); ``` @@ -378,12 +378,12 @@ addSlot(slot: NotificationSlot): Promise\ **示例:** ```js -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.addSlot(notificationSlot).then(() => { - console.info("addSlot sucess"); + console.info("addSlot success"); }); ``` @@ -393,7 +393,7 @@ Notification.addSlot(notificationSlot).then(() => { addSlot(type: SlotType, callback: AsyncCallback\): void -创建通知通道(callback形式)。 +创建指定类型的通知通道(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -407,7 +407,7 @@ addSlot(type: SlotType, callback: AsyncCallback\): void **示例:** ```js -//addslot回调 +// addslot回调 function addSlotCallBack(err) { if (err.code) { console.info("addSlot failed " + JSON.stringify(err)); @@ -415,7 +415,7 @@ function addSlotCallBack(err) { 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 addSlot(type: SlotType): Promise\ -创建通知通道(Promise形式)。 +创建指定类型的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -438,7 +438,7 @@ addSlot(type: SlotType): Promise\ ```js Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { - console.info("addSlot sucess"); + console.info("addSlot success"); }); ``` @@ -466,7 +466,7 @@ addSlots(slots: Array\, callback: AsyncCallback\): voi **示例:** ```js -//addSlots回调 +// addSlots回调 function addSlotsCallBack(err) { if (err.code) { console.info("addSlots failed " + JSON.stringify(err)); @@ -474,15 +474,15 @@ function addSlotsCallBack(err) { console.info("addSlots success"); } } -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} -//通知slot array 对象 -var notificationSlotArray = new Array(); +}; +// 通知slot array 对象 +let notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; -Notification.addSlots(notificationSlotArray, addSlotsCallBack) +Notification.addSlots(notificationSlotArray, addSlotsCallBack); ``` @@ -508,16 +508,16 @@ addSlots(slots: Array\): Promise\ **示例:** ```js -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} -//通知slot array 对象 -var notificationSlotArray = new Array(); +}; +// 通知slot array 对象 +let notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; Notification.addSlots(notificationSlotArray).then(() => { - console.info("addSlots sucess"); + console.info("addSlots success"); }); ``` @@ -527,7 +527,7 @@ Notification.addSlots(notificationSlotArray).then(() => { getSlot(slotType: SlotType, callback: AsyncCallback\): void -获取一个通知通道(callback形式)。 +获取一个指定类型的通知通道(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -535,22 +535,22 @@ getSlot(slotType: SlotType, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ----------------------------------------------------------- | -| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | +| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 | **示例:** ```js -//getSlot回调 -function getSlotCallback(err,data) { +// getSlot回调 +function getSlotCallback(err, data) { if (err.code) { console.info("getSlot failed " + JSON.stringify(err)); } else { console.info("getSlot success"); } } -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; -Notification.getSlot(slotType, getSlotCallback) +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +Notification.getSlot(slotType, getSlotCallback); ``` @@ -559,7 +559,7 @@ Notification.getSlot(slotType, getSlotCallback) getSlot(slotType: SlotType): Promise\ -获取一个通知通道(Promise形式)。 +获取一个指定类型的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -567,7 +567,7 @@ getSlot(slotType: SlotType): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ----------------------------------------------------------- | -| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | +| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | **返回值:** @@ -578,9 +578,9 @@ getSlot(slotType: SlotType): Promise\ **示例:** ```js -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; 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>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\\> | 是 | 表示被指定的回调方法。 | +| callback | AsyncCallback\\> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 | **示例:** ```js -//getSlots回调 -function getSlotsCallback(err,data) { +// getSlots回调 +function getSlotsCallback(err, data) { if (err.code) { console.info("getSlots failed " + JSON.stringify(err)); } else { console.info("getSlots success"); } } -Notification.getSlots(getSlotsCallback) +Notification.getSlots(getSlotsCallback); ``` @@ -634,7 +634,7 @@ getSlots(): Promise\> ```js 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) => { removeSlot(slotType: SlotType, callback: AsyncCallback\): void -根据通知通道类型删除创建的通知通道(callback形式)。 +删除指定类型的通知通道(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -658,7 +658,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\): void **示例:** ```js -//removeSlot回调 +// removeSlot回调 function removeSlotCallback(err) { if (err.code) { console.info("removeSlot failed " + JSON.stringify(err)); @@ -666,8 +666,8 @@ function removeSlotCallback(err) { console.info("removeSlot success"); } } -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; -Notification.removeSlot(slotType,removeSlotCallback) +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +Notification.removeSlot(slotType,removeSlotCallback); ``` @@ -676,7 +676,7 @@ Notification.removeSlot(slotType,removeSlotCallback) removeSlot(slotType: SlotType): Promise\ -根据通知通道类型删除创建的通知通道(Promise形式)。 +删除指定类型的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -689,9 +689,9 @@ removeSlot(slotType: SlotType): Promise\ **示例:** ```js -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.removeSlot(slotType).then(() => { - console.info("removeSlot sucess"); + console.info("removeSlot success"); }); ``` @@ -721,7 +721,7 @@ function removeAllCallBack(err) { console.info("removeAllSlots success"); } } -Notification.removeAllSlots(removeAllCallBack) +Notification.removeAllSlots(removeAllCallBack); ``` @@ -738,7 +738,7 @@ removeAllSlots(): Promise\ ```js Notification.removeAllSlots().then(() => { - console.info("removeAllSlots sucess"); + console.info("removeAllSlots success"); }); ``` @@ -761,13 +761,13 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------- | ---- | ---------------- | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | -| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 订阅信息。 | +| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 通知订阅信息。 | | callback | AsyncCallback\ | 是 | 订阅动作回调函数。 | **示例:** ```js -//subscribe回调 +// subscribe回调 function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); @@ -778,12 +778,12 @@ function subscribeCallback(err) { function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback -} -var info = { - bundleNames: ["bundleName1","bundleName2"] -} +}; +let info = { + bundleNames: ["bundleName1", "bundleName2"] +}; Notification.subscribe(subscriber, info, subscribeCallback); ``` @@ -793,7 +793,7 @@ Notification.subscribe(subscriber, info, subscribeCallback); subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): void -订阅通知并指定订阅信息(callback形式)。 +订阅当前用户下所有应用的通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -821,9 +821,9 @@ function subscribeCallback(err) { function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback -} +}; Notification.subscribe(subscriber, subscribeCallback); ``` @@ -846,7 +846,7 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------- | ---- | ------------ | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | -| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 订阅信息。 | +| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 通知订阅信息。 | **示例:** @@ -854,11 +854,11 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback }; Notification.subscribe(subscriber).then(() => { - console.info("subscribe sucess"); + console.info("subscribe success"); }); ``` @@ -893,12 +893,12 @@ function unsubscribeCallback(err) { console.info("unsubscribe success"); } } -function onCancelCallback(data) { +function onDisconnectCallback(data) { console.info("Cancel callback: " + JSON.stringify(data)); } -var subscriber = { - onCancel: onCancelCallback -} +let subscriber = { + onDisconnect: onDisconnectCallback +}; Notification.unsubscribe(subscriber, unsubscribeCallback); ``` @@ -925,14 +925,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\ **示例:** ```js -function onCancelCallback(data) { +function onDisconnectCallback(data) { console.info("Cancel callback: " + JSON.stringify(data)); } -var subscriber = { - onCancel: onCancelCallback +let subscriber = { + onDisconnect: onDisconnectCallback }; Notification.unsubscribe(subscriber).then(() => { - console.info("unsubscribe sucess"); + console.info("unsubscribe success"); }); ``` @@ -942,7 +942,7 @@ Notification.unsubscribe(subscriber).then(() => { enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void -设定指定包的通知使能状态(Callback形式)。 +设定指定应用的通知使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -954,7 +954,7 @@ enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallbac | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | | callback | AsyncCallback\ | 是 | 设定通知使能回调函数。 | @@ -968,9 +968,9 @@ function enableNotificationCallback(err) { console.info("enableNotification success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.enableNotification(bundle, false, enableNotificationCallback); ``` @@ -980,7 +980,7 @@ Notification.enableNotification(bundle, false, enableNotificationCallback); enableNotification(bundle: BundleOption, enable: boolean): Promise\ -设定指定包的通知使能状态(Promise形式)。 +设定指定应用的通知使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -992,17 +992,17 @@ enableNotification(bundle: BundleOption, enable: boolean): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.enableNotification(bundle, false).then(() => { - console.info("enableNotification sucess"); + console.info("enableNotification success"); }); ``` @@ -1012,7 +1012,7 @@ Notification.enableNotification(bundle, false).then(() => { isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): void -获取指定包的通知使能状态(Callback形式)。 +获取指定应用的通知使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1024,7 +1024,7 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | callback | AsyncCallback\ | 是 | 获取通知使能状态回调函数。 | **示例:** @@ -1037,9 +1037,9 @@ function isNotificationEnabledCallback(err, data) { console.info("isNotificationEnabled success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); ``` @@ -1049,7 +1049,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); isNotificationEnabled(bundle: BundleOption): Promise\ -获取指定包的通知使能状态(Promise形式)。 +获取指定应用的通知使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1061,22 +1061,22 @@ isNotificationEnabled(bundle: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取指定包的通知使能状态的结果。 | +| 类型 | 说明 | +| ------------------ | --------------------------------------------------- | +| Promise\ | 以Promise形式返回获取指定应用的通知使能状态的结果。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** @@ -1144,7 +1144,7 @@ isNotificationEnabled(): Promise\ ```js 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) => { displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void -设定指定包的角标使能状态(Callback形式)。 +设定指定应用的角标使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1166,7 +1166,7 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\ | 是 | 设定角标使能回调函数。 | @@ -1180,9 +1180,9 @@ function displayBadgeCallback(err) { console.info("displayBadge success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.displayBadge(bundle, false, displayBadgeCallback); ``` @@ -1192,7 +1192,7 @@ Notification.displayBadge(bundle, false, displayBadgeCallback); displayBadge(bundle: BundleOption, enable: boolean): Promise\ -设定指定包的角标使能状态(Promise形式)。 +设定指定应用的角标使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1204,17 +1204,17 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.displayBadge(bundle, false).then(() => { - console.info("displayBadge sucess"); + console.info("displayBadge success"); }); ``` @@ -1224,7 +1224,7 @@ Notification.displayBadge(bundle, false).then(() => { isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\): void -获取指定包的角标使能状态(Callback形式)。 +获取指定应用的角标使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1236,7 +1236,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | callback | AsyncCallback\ | 是 | 获取角标使能状态回调函数。 | **示例:** @@ -1249,9 +1249,9 @@ function isBadgeDisplayedCallback(err, data) { console.info("isBadgeDisplayed success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); ``` @@ -1261,7 +1261,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); isBadgeDisplayed(bundle: BundleOption): Promise\ -获取指定包的角标使能状态(Promise形式)。 +获取指定应用的角标使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1273,22 +1273,22 @@ isBadgeDisplayed(bundle: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取指定包的角标使能状态。 | +| Promise\ | 以Promise形式返回获取指定应用的角标使能状态。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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) => { setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\): void -设定指定包的通知通道状态(Callback形式)。 +设定指定应用的通知通道(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1310,7 +1310,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | | callback | AsyncCallback\ | 是 | 设定通知通道回调函数。 | @@ -1324,12 +1324,12 @@ function setSlotByBundleCallback(err) { console.info("setSlotByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationSlot = { +}; +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); ``` @@ -1339,7 +1339,7 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ -设定指定包的通知通道状态(Promise形式)。 +设定指定应用的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1351,20 +1351,20 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| slot | [NotificationSlot](#notificationslot) | 是 | 使能状态。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationSlot = { +}; +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.setSlotByBundle(bundle, notificationSlot).then(() => { - console.info("setSlotByBundle sucess"); + console.info("setSlotByBundle success"); }); ``` @@ -1374,7 +1374,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void -获取指定包的通知通道(Callback形式)。 +获取指定应用的所有通知通道(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1386,7 +1386,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback> | 是 | 获取通知通道回调函数。 | **示例:** @@ -1399,9 +1399,9 @@ function getSlotsByBundleCallback(err, data) { console.info("getSlotsByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ``` @@ -1411,7 +1411,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); getSlotsByBundle(bundle: BundleOption): Promise> -获取指定包的通知通道(Promise形式)。 +获取指定应用的所有通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1423,22 +1423,22 @@ getSlotsByBundle(bundle: BundleOption): Promise> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | 以Promise形式返回获取指定包的通知通道。 | +| Promise> | 以Promise形式返回获取指定应用的通知通道。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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) => { getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\): void -获取指定包的通知通道数(Callback形式)。 +获取指定应用的通知通道数量(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1460,8 +1460,8 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| callback | AsyncCallback\ | 是 | 获取通知通道数回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| callback | AsyncCallback\ | 是 | 获取通知通道数量回调函数。 | **示例:** @@ -1473,9 +1473,9 @@ function getSlotNumByBundleCallback(err, data) { console.info("getSlotNumByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); ``` @@ -1485,7 +1485,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); getSlotNumByBundle(bundle: BundleOption): Promise\ -获取指定包的通知通道数(Promise形式)。 +获取指定应用的通知通道数量(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1497,22 +1497,22 @@ getSlotNumByBundle(bundle: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取指定包的通知通道数。 | +| Promise\ | 以Promise形式返回获取指定应用的通知通道数量。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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 | 参数名 | 类型 | 必填 | 说明 | | --------------- | ----------------------------------| ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 | | callback | AsyncCallback\ | 是 | 删除指定通知回调函数。 | @@ -1549,14 +1549,14 @@ function removeCallback(err) { console.info("remove success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationKey = { +}; +let notificationKey = { id: 0, label: "label", -} -var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; +}; +let reason = Notification.RemoveReason.CLICK_REASON_REMOVE; Notification.remove(bundle, notificationKey, reason, removeCallback); ``` @@ -1578,23 +1578,23 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea | 参数名 | 类型 | 必填 | 说明 | | --------------- | --------------- | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 | **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationKey = { +}; +let notificationKey = { id: 0, label: "label", -} -var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; +}; +let reason = Notification.RemoveReason.CLICK_REASON_REMOVE; 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\): | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| hashCode | string | 是 | 通知唯一ID。 | +| hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](#onconsume)回调的入参[SubscribeCallbackData](#subscribecallbackdata)获取其内部[NotificationRequest](#notificationrequest)对象中的hashCode。 | | reason | [RemoveReason](#removereason9) | 是 | 通知删除原因。 | | callback | AsyncCallback\ | 是 | 删除指定通知回调函数。 | **示例:** ```js -var hashCode = 'hashCode' +let hashCode = 'hashCode'; function removeCallback(err) { if (err.code) { @@ -1632,7 +1632,7 @@ function removeCallback(err) { console.info("remove success"); } } -var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE; +let reason = Notification.RemoveReason.CANCEL_REASON_REMOVE; Notification.remove(hashCode, reason, removeCallback); ``` @@ -1660,10 +1660,10 @@ remove(hashCode: string, reason: RemoveReason): Promise\ **示例:** ```js -var hashCode = 'hashCode' -var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; +let hashCode = 'hashCode'; +let reason = Notification.RemoveReason.CLICK_REASON_REMOVE; Notification.remove(hashCode, reason).then(() => { - console.info("remove sucess"); + console.info("remove success"); }); ``` @@ -1673,7 +1673,7 @@ Notification.remove(hashCode, reason).then(() => { removeAll(bundle: BundleOption, callback: AsyncCallback\): void -删除指定包的所有通知(Callback形式)。 +删除指定应用的所有通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1685,8 +1685,8 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ---------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| callback | AsyncCallback\ | 是 | 删除指定包的所有通知回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| callback | AsyncCallback\ | 是 | 删除指定应用的所有通知回调函数。 | **示例:** @@ -1698,9 +1698,9 @@ function removeAllCallback(err) { console.info("removeAll success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.removeAll(bundle, removeAllCallback); ``` @@ -1744,7 +1744,7 @@ Notification.removeAll(removeAllCallback); removeAll(bundle?: BundleOption): Promise\ -删除所有通知(Promise形式)。 +删除指定应用的所有通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1756,13 +1756,14 @@ removeAll(bundle?: BundleOption): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 否 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 否 | 指定应用的包信息。 | **示例:** ```js +// 不指定应用时,删除所有通知 Notification.removeAll().then(() => { - console.info("removeAll sucess"); + console.info("removeAll success"); }); ``` @@ -1770,7 +1771,7 @@ Notification.removeAll().then(() => { removeAll(userId: number, callback: AsyncCallback\): void -删除所有通知(callback形式)。 +删除指定用户下的所有通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1782,8 +1783,8 @@ removeAll(userId: number, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| userId | number | 是 | 接收通知用户的Id。 | -| callback | AsyncCallback\ | 是 | 删除所有通知回调函数。 | +| userId | number | 是 | 用户ID。 | +| callback | AsyncCallback\ | 是 | 删除指定用户所有通知回调函数。 | **示例:** @@ -1796,8 +1797,7 @@ function removeAllCallback(err) { } } -var userId = 1 - +let userId = 1; Notification.removeAll(userId, removeAllCallback); ``` @@ -1805,7 +1805,7 @@ Notification.removeAll(userId, removeAllCallback); removeAll(userId: number): Promise\ -删除所有通知(Promise形式)。 +删除指定用户下的所有通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1817,22 +1817,15 @@ removeAll(userId: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | **示例:** ```js -function removeAllCallback(err) { - if (err.code) { - console.info("removeAll failed " + JSON.stringify(err)); - } else { - console.info("removeAll success"); - } -} - -var userId = 1 - -Notification.removeAll(userId, removeAllCallback); +let userId = 1; +Notification.removeAll(userId).then(() => { + console.info("removeAll success"); +}); ``` @@ -1840,7 +1833,7 @@ Notification.removeAll(userId, removeAllCallback); getAllActiveNotifications(callback: AsyncCallback>): void -获取活动通知(Callback形式)。 +获取当前未删除的所有通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1874,7 +1867,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); getAllActiveNotifications(): Promise\\> -获取活动通知(Promise形式)。 +获取当前未删除的所有通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1892,7 +1885,7 @@ getAllActiveNotifications(): Promise\ { - console.info("getAllActiveNotifications sucess, data: " + JSON.stringify(data)); + console.info("getAllActiveNotifications success, data: " + JSON.stringify(data)); }); ``` @@ -1902,7 +1895,7 @@ Notification.getAllActiveNotifications().then((data) => { getActiveNotificationCount(callback: AsyncCallback\): void -获取当前应用的活动通知数(Callback形式)。 +获取当前应用未删除的通知数(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1910,7 +1903,7 @@ getActiveNotificationCount(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---------------------- | -| callback | AsyncCallback\ | 是 | 获取活动通知数回调函数。 | +| callback | AsyncCallback\ | 是 | 获取未删除通知数回调函数。 | **示例:** @@ -1932,21 +1925,21 @@ Notification.getActiveNotificationCount(getActiveNotificationCountCallback); getActiveNotificationCount(): Promise\ -获取当前应用的活动通知数(Promise形式)。 +获取当前应用未删除的通知数(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取当前应用的活动通知数。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------- | +| Promise\ | 以Promise形式返回获取当前应用未删除通知数。 | **示例:** ```js 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) => { getActiveNotifications(callback: AsyncCallback>): void -获取当前应用的活动通知(Callback形式)。 +获取当前应用未删除的通知列表(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1964,7 +1957,7 @@ getActiveNotifications(callback: AsyncCallback>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ | -| callback | AsyncCallback> | 是 | 获取当前应用的活动通知回调函数。 | +| callback | AsyncCallback> | 是 | 获取当前应用通知列表回调函数。 | **示例:** @@ -1986,21 +1979,21 @@ Notification.getActiveNotifications(getActiveNotificationsCallback); getActiveNotifications(): Promise\\> -获取当前应用的活动通知(Promise形式)。 +获取当前应用未删除的通知列表(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\\> | 以Promise形式返回获取当前应用的活动通知。 | +| 类型 | 说明 | +| ------------------------------------------------------------ | --------------------------------------- | +| Promise\\> | 以Promise形式返回获取当前应用通知列表。 | **示例:** ```js 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) => { cancelGroup(groupName: string, callback: AsyncCallback\): void -取消本应用指定组通知(Callback形式)。 +取消本应用指定组下的通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2018,8 +2011,8 @@ cancelGroup(groupName: string, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------- | -| groupName | string | 是 | 指定通知组名称。 | -| callback | AsyncCallback\ | 是 | 取消本应用指定组通知回调函数。 | +| groupName | string | 是 | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](#notificationrequest)对象指定。 | +| callback | AsyncCallback\ | 是 | 取消本应用指定组下通知的回调函数。 | **示例:** @@ -2032,7 +2025,7 @@ function cancelGroupCallback(err) { } } -var groupName = "GroupName"; +let groupName = "GroupName"; Notification.cancelGroup(groupName, cancelGroupCallback); ``` @@ -2043,7 +2036,7 @@ Notification.cancelGroup(groupName, cancelGroupCallback); cancelGroup(groupName: string): Promise\ -取消本应用指定组通知(Promise形式)。 +取消本应用指定组下的通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2051,14 +2044,14 @@ cancelGroup(groupName: string): Promise\ | 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | -------------- | -| groupName | string | 是 | 指定通知组名称。 | +| groupName | string | 是 | 通知组名称。 | **示例:** ```js -var groupName = "GroupName"; +let groupName = "GroupName"; Notification.cancelGroup(groupName).then(() => { - console.info("cancelGroup sucess"); + console.info("cancelGroup success"); }); ``` @@ -2068,7 +2061,7 @@ Notification.cancelGroup(groupName).then(() => { removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\): void -删除指定应用指定组通知(Callback形式)。 +删除指定应用的指定组下的通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2080,9 +2073,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall | 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| groupName | string | 是 | 指定通知组名称。 | -| callback | AsyncCallback\ | 是 | 删除本应用指定组通知回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| groupName | string | 是 | 通知组名称。 | +| callback | AsyncCallback\ | 是 | 删除指定应用指定组下通知的回调函数。 | **示例:** @@ -2095,8 +2088,8 @@ function removeGroupByBundleCallback(err) { } } -var bundleOption = {bundle: "Bundle"}; -var groupName = "GroupName"; +let bundleOption = {bundle: "Bundle"}; +let groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); ``` @@ -2107,7 +2100,7 @@ Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCal removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ -删除指定应用指定组通知(Promise形式)。 +删除指定应用的指定组下的通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2119,16 +2112,16 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------ | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| groupName | string | 是 | 指定通知组名称。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| groupName | string | 是 | 通知组名称。 | **示例:** ```js -var bundleOption = {bundle: "Bundle"}; -var groupName = "GroupName"; +let bundleOption = {bundle: "Bundle"}; +let groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName).then(() => { - console.info("removeGroupByBundle sucess"); + console.info("removeGroupByBundle success"); }); ``` @@ -2164,11 +2157,11 @@ function setDoNotDisturbDateCallback(err) { } } -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); ``` @@ -2179,7 +2172,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); setDoNotDisturbDate(date: DoNotDisturbDate): Promise\ -设置免打扰时间接口(Promise形式)。 +设置免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2196,13 +2189,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\ **示例:** ```js -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { - console.info("setDoNotDisturbDate sucess"); + console.info("setDoNotDisturbDate success"); }); ``` @@ -2224,7 +2217,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ---------------------- | | date | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 设置免打扰时间的用户ID。 | | callback | AsyncCallback\ | 是 | 设置免打扰时间回调函数。 | **示例:** @@ -2238,14 +2231,13 @@ function setDoNotDisturbDateCallback(err) { } } -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} - -var userId = 1 +}; +let userId = 1 Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); ``` @@ -2255,7 +2247,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCa setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\ -指定用户设置免打扰时间接口(Promise形式)。 +指定用户设置免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2268,21 +2260,21 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------- | ---- | -------------- | | date | [DoNotDisturbDate](#donotdisturbdate8) | 是 | 免打扰时间选项。 | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 设置免打扰时间的用户ID。 | **示例:** ```js -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; -var userId = 1 +let userId = 1; Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { - console.info("setDoNotDisturbDate sucess"); + console.info("setDoNotDisturbDate success"); }); ``` @@ -2291,7 +2283,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { getDoNotDisturbDate(callback: AsyncCallback\): void -查询免打扰时间接口(Callback形式)。 +查询免打扰时间(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2308,7 +2300,7 @@ getDoNotDisturbDate(callback: AsyncCallback\): void **示例:** ```js -function getDoNotDisturbDateCallback(err,data) { +function getDoNotDisturbDateCallback(err, data) { if (err.code) { console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); } else { @@ -2325,7 +2317,7 @@ Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); getDoNotDisturbDate(): Promise\ -查询免打扰时间接口(Promise形式)。 +查询免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2335,15 +2327,15 @@ getDoNotDisturbDate(): Promise\ **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 | +| 类型 | 说明 | +| ------------------------------------------------- | ----------------------------------------- | +| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询到的免打扰时间。 | **示例:** ```js 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) => { getDoNotDisturbDate(userId: number, callback: AsyncCallback\): void -指定用户查询免打扰时间接口(Callback形式)。 +查询指定用户的免打扰时间(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2365,7 +2357,7 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\) | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ---------------------- | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | 是 | 查询免打扰时间回调函数。 | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 用户ID。 | **示例:** @@ -2378,7 +2370,7 @@ function getDoNotDisturbDateCallback(err,data) { } } -var userId = 1 +let userId = 1; Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); ``` @@ -2389,7 +2381,7 @@ Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); getDoNotDisturbDate(userId: number): Promise\ -指定用户查询免打扰时间接口(Promise形式)。 +查询指定用户的免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2401,21 +2393,21 @@ getDoNotDisturbDate(userId: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ---------------------- | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 用户ID。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询免打扰时间接口。 | +| 类型 | 说明 | +| ------------------------------------------------- | ----------------------------------------- | +| Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | 以Promise形式返回获取查询到的免打扰时间。 | **示例:** ```js -var userId = 1 +let userId = 1; 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) => { supportDoNotDisturbMode(callback: AsyncCallback\): void -查询是否支持勿扰模式功能(Callback形式)。 +查询是否支持免打扰功能(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2436,7 +2428,7 @@ supportDoNotDisturbMode(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------------- | -| callback | AsyncCallback\ | 是 | 查询是否支持勿扰模式功能回调函数。 | +| callback | AsyncCallback\ | 是 | 查询是否支持免打扰功能回调函数。 | **示例:** @@ -2458,7 +2450,7 @@ Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); supportDoNotDisturbMode(): Promise\ -查询是否支持勿扰模式功能(Promise形式)。 +查询是否支持免打扰功能(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2470,13 +2462,13 @@ supportDoNotDisturbMode(): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取是否支持勿扰模式功能的结果。 | +| Promise\ | 以Promise形式返回获取是否支持免打扰功能的结果。 | **示例:** ```js 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\): voi **示例:** ```javascript -var templateName = 'process'; +let templateName = 'process'; function isSupportTemplateCallback(err, data) { if (err.code) { console.info("isSupportTemplate failed " + JSON.stringify(err)); @@ -2537,7 +2529,7 @@ isSupportTemplate(templateName: string): Promise\ **示例:** ```javascript -var templateName = 'process'; +let templateName = 'process'; Notification.isSupportTemplate(templateName).then((data) => { console.info("isSupportTemplate success, data: " + JSON.stringify(data)); @@ -2567,7 +2559,7 @@ function requestEnableNotificationCallback(err) { if (err.code) { console.info("requestEnableNotification failed " + JSON.stringify(err)); } else { - + console.info("requestEnableNotification success"); } }; @@ -2587,10 +2579,9 @@ requestEnableNotification(): Promise\ **示例:** ```javascript -Notification.requestEnableNotification() - .then(() => { - console.info("requestEnableNotification sucess"); - }); +Notification.requestEnableNotification().then(() => { + console.info("requestEnableNotification success"); +}); ``` @@ -2610,7 +2601,7 @@ enableDistributed(enable: boolean, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| enable | boolean | 是 | 是否支持。
true 支持。
false 不支持。| +| enable | boolean | 是 | 是否支持。 | | callback | AsyncCallback\ | 是 | 设置设备是否支持分布式通知的回调函数。 | **示例:** @@ -2624,7 +2615,7 @@ function enabledNotificationCallback(err) { } }; -var enable = true +let enable = true; Notification.enableDistributed(enable, enabledNotificationCallback); ``` @@ -2647,17 +2638,15 @@ enableDistributed(enable: boolean): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| enable | boolean | 是 | 是否支持。
true 支持。
false 不支持。| +| enable | boolean | 是 | 是否支持。 | **示例:** ```javascript -var enable = true - -Notification.enableDistributed(enable) - .then(() => { - console.info("enableDistributed sucess"); - }); +let enable = true; +Notification.enableDistributed(enable).then(() => { + console.info("enableDistributed success"); +}); ``` @@ -2665,7 +2654,7 @@ Notification.enableDistributed(enable) isDistributedEnabled(callback: AsyncCallback\): void -获取设备是否支持分布式通知(Callback形式)。 +查询设备是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2695,23 +2684,22 @@ Notification.isDistributedEnabled(isDistributedEnabledCallback); isDistributedEnabled(): Promise\ -获取设备是否支持分布式通知(Promise形式)。 +查询设备是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **返回值:** -| 类型 | 说明 | -| ------------------ | --------------- | -| Promise\ | Promise方式返回设备是否支持分布式通知的结果。
true 支持。
false 不支持。 | +| 类型 | 说明 | +| ------------------ | --------------------------------------------- | +| Promise\ | Promise方式返回设备是否支持分布式通知的结果。 | **示例:** ```javascript -Notification.isDistributedEnabled() - .then((data) => { - console.info("isDistributedEnabled sucess, data: " + JSON.stringify(data)); - }); +Notification.isDistributedEnabled().then((data) => { + console.info("isDistributedEnabled success, data: " + JSON.stringify(data)); +}); ``` @@ -2719,7 +2707,7 @@ Notification.isDistributedEnabled() enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void -根据应用的包设置应用程序是否支持分布式通知(Callback形式)。 +设置指定应用是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2731,7 +2719,7 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: Async | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | | enable | boolean | 是 | 是否支持。 | | callback | AsyncCallback\ | 是 | 应用程序是否支持分布式通知的回调函数。 | @@ -2746,11 +2734,11 @@ function enableDistributedByBundleCallback(err) { } }; -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; -var enable = true +let enable = true; Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback); ``` @@ -2761,7 +2749,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\ -根据应用的包设置应用程序是否支持分布式通知(Promise形式)。 +设置指定应用是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2779,16 +2767,14 @@ enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\ **示例:** ```javascript -var bundle = { +let bundle = { bundle: "bundleName1", -} - -var enable = true +}; -Notification.enableDistributedByBundle(bundle, enable) - .then(() => { - console.info("enableDistributedByBundle sucess"); - }); +let enable = true; +Notification.enableDistributedByBundle(bundle, enable).then(() => { + console.info("enableDistributedByBundle success"); +}); ``` ## Notification.isDistributedEnabledByBundle8+ @@ -2808,7 +2794,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\ | 是 | 应用程序是否支持分布式通知的回调函数。 | +| callback | AsyncCallback\ | 是 | 查询指定应用是否支持分布式通知的回调函数。 | **示例:** @@ -2821,9 +2807,9 @@ function isDistributedEnabledByBundleCallback(err, data) { } }; -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); ``` @@ -2834,7 +2820,7 @@ Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCa isDistributedEnabledByBundle(bundle: BundleOption): Promise\ -根据应用的包获取应用程序是否支持分布式通知(Promise形式)。 +查询指定应用是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2850,21 +2836,20 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\ **返回值:** -| 类型 | 说明 | -| ------------------ | --------------- | -| Promise\ | Promise方式返回应用程序是否支持分布式通知的结果。
true 支持。
false 不支持。 | +| 类型 | 说明 | +| ------------------ | ------------------------------------------------- | +| Promise\ | Promise方式返回指定应用是否支持分布式通知的结果。 | **示例:** ```javascript -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; -Notification.isDistributedEnabledByBundle(bundle) - .then((data) => { - console.info("isDistributedEnabledByBundle sucess, data: " + JSON.stringify(data)); - }); +Notification.isDistributedEnabledByBundle(bundle).then((data) => { + console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data)); +}); ``` @@ -2884,7 +2869,7 @@ getDeviceRemindType(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | -------------------------- | -| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | 是 | 获取通知的提醒方式的回调函数。 | +| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | 是 | 获取通知提醒方式的回调函数。 | **示例:** @@ -2918,15 +2903,14 @@ getDeviceRemindType(): Promise\ | 类型 | 说明 | | ------------------ | --------------- | -| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise方式返回通知的提醒方式的结果。 | +| Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise方式返回获取通知提醒方式的结果。 | **示例:** ```javascript -Notification.getDeviceRemindType() - .then((data) => { - console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data)); - }); +Notification.getDeviceRemindType().then((data) => { + console.info("getDeviceRemindType success, data: " + JSON.stringify(data)); +}); ``` @@ -2944,18 +2928,18 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | -| representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | -| callback | AsyncCallback | 是 | 发布代理通知的回调方法。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| representativeBundle | string | 是 | 被代理应用的包名。 | +| userId | number | 是 | 用户ID。 | +| callback | AsyncCallback | 是 | 发布代理通知的回调方法。 | **示例:** ```js -//publishAsBundle回调 -function publishAsBundleCallback(err) { +// publishAsBundle回调 +function callback(err) { if (err.code) { console.info("publishAsBundle failed " + JSON.stringify(err)); } else { @@ -2963,11 +2947,11 @@ function publishAsBundleCallback(err) { } } // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 -//通知Request对象 -let notificationRequest = { +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; +// NotificationRequest对象 +let request = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -2977,9 +2961,9 @@ let notificationRequest = { additionalText: "test_additionalText" } } -} +}; -Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback); +Notification.publishAsBundle(request, representativeBundle, userId, callback); ``` ## Notification.publishAsBundle9+ @@ -2999,19 +2983,19 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | | representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | **示例:** ```js // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 -//通知Request对象 -var notificationRequest = { +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; +// NotificationRequest对象 +let request = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -3021,10 +3005,10 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; -Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => { - console.info("publishAsBundle sucess"); +Notification.publishAsBundle(request, representativeBundle, userId).then(() => { + console.info("publishAsBundle success"); }); ``` @@ -3048,13 +3032,13 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac | -------------------- | ------------- | ---- | ------------------------ | | id | number | 是 | 通知ID。 | | representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | | callback | AsyncCallback | 是 | 取消代理通知的回调方法。 | **示例:** ```js -//cancelAsBundle +// cancelAsBundle function cancelAsBundleCallback(err) { if (err.code) { console.info("cancelAsBundle failed " + JSON.stringify(err)); @@ -3063,9 +3047,9 @@ function cancelAsBundleCallback(err) { } } // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); ``` @@ -3074,7 +3058,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallb cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\ -发布代理通知(Promise形式)。 +取消代理通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3090,15 +3074,15 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis | -------------------- | ------ | ---- | ------------------ | | id | number | 是 | 通知ID。 | | representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | **示例:** ```js // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { console.info("cancelAsBundle success"); @@ -3109,7 +3093,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\): void -设定指定类型的渠道使能状态(Callback形式)。 +设置指定应用的指定渠道类型的使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3121,15 +3105,15 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, ca | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | | type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | enable | boolean | 是 | 使能状态。 | -| callback | AsyncCallback\ | 是 | 设定渠道使能回调函数。 | +| callback | AsyncCallback\ | 是 | 设置渠道使能回调函数。 | **示例:** ```js -//enableNotificationSlot +// enableNotificationSlot function enableSlotCallback(err) { if (err.code) { console.info("enableNotificationSlot failed " + JSON.stringify(err)); @@ -3149,7 +3133,7 @@ Notification.enableNotificationSlot( enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\ -设定指定类型的渠道使能状态(Promise形式)。 +设置指定应用的指定渠道类型的使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3161,27 +3145,25 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): P | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| type | [SlotType](#slottype) | 是 | 渠道类型。 | | enable | boolean | 是 | 使能状态。 | **示例:** ```js -//enableNotificationSlot -Notification.enableNotificationSlot( - { bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION, - true).then(() => { - console.info("enableNotificationSlot sucess"); - }); +// enableNotificationSlot +Notification.enableNotificationSlot({ bundle: "ohos.samples.notification", }, + Notification.SlotType.SOCIAL_COMMUNICATION,true).then(() => { + console.info("enableNotificationSlot success"); +}); ``` ## Notification.isNotificationSlotEnabled 9+ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\): void -获取指定类型的渠道使能状态(Callback形式)。 +获取指定应用的指定渠道类型的使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3193,14 +3175,14 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | -| callback | AsyncCallback\ | 是 | 设定渠道使能回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| type | [SlotType](#slottype) | 是 | 渠道类型。 | +| callback | AsyncCallback\ | 是 | 获取渠道使能状态回调函数。 | **示例:** ```js -//isNotificationSlotEnabled +// isNotificationSlotEnabled function getEnableSlotCallback(err, data) { if (err.code) { console.info("isNotificationSlotEnabled failed " + JSON.stringify(err)); @@ -3219,7 +3201,7 @@ Notification.isNotificationSlotEnabled( isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ -获取指定类型的渠道使能状态(Promise形式)。 +获取指定应用的指定渠道类型的使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3231,25 +3213,23 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ | 以Promise形式返回指定类型的渠道使能状态。 | +| 类型 | 说明 | +| ------------------ | ------------------------------- | +| Promise\ | 以Promise形式返回渠道使能状态。 | **示例:** ```js -//isNotificationSlotEnabled -Notification.isNotificationSlotEnabled( - { bundle: "ohos.samples.notification", }, - Notification.SlotType.SOCIAL_COMMUNICATION - ).then((data) => { - console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data)); - }); +// isNotificationSlotEnabled +Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", }, + Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => { + console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data)); +}); ``` @@ -3269,8 +3249,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| userId | number | 是 | 用户Id。 | -| enable | boolean | 是 | 是否启用。
true:启用。
false:禁用。 | +| userId | number | 是 | 用户ID。 | +| enable | boolean | 是 | 是否启用。 | | callback | AsyncCallback\ | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。 | **示例:** @@ -3279,7 +3259,7 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: let userId = 100; let enable = true; -function setSyncNotificationEnabledWithoutAppCallback(err) { +function callback(err) { if (err.code) { console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err)); } else { @@ -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\< | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| userId | number | 是 | 用户Id。 | -| enable | boolean | 是 | 是否启用。
true:启用。
false:禁用。 | +| userId | number | 是 | 用户ID。 | +| enable | boolean | 是 | 是否启用。 | **返回值:** @@ -3322,13 +3302,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\< let userId = 100; let enable = true; -Notification.setSyncNotificationEnabledWithoutApp(userId, enable) - .then(() => { - console.info('setSyncNotificationEnabledWithoutApp'); - }) - .catch((err) => { - console.info('setSyncNotificationEnabledWithoutApp, err:', err); - }); +Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => { + console.info('setSyncNotificationEnabledWithoutApp success'); +}).catch((err) => { + console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err)); +}); ``` @@ -3336,7 +3314,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable) getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\): void -获取是否同步通知到未安装应用程序的设备(callback形式)。 +获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3348,19 +3326,19 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\ | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。
true: 是。
false: 否。 | +| userId | number | 是 | 用户ID。 | +| callback | AsyncCallback\ | 是 | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数。 | **示例:** ```js let userId = 100; -function getSyncNotificationEnabledWithoutAppCallback(data, err) { +function getSyncNotificationEnabledWithoutAppCallback(err, data) { if (err) { - console.info('getSyncNotificationEnabledWithoutAppCallback, err' + err); + console.info('getSyncNotificationEnabledWithoutAppCallback, err:' + err); } else { - console.info('getSyncNotificationEnabledWithoutAppCallback, data' + data); + console.info('getSyncNotificationEnabledWithoutAppCallback, data:' + data); } } @@ -3372,7 +3350,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEna getSyncNotificationEnabledWithoutApp(userId: number): Promise\ -获取是否同步通知到未安装应用程序的设备(Promise形式)。 +获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3384,33 +3362,30 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| userId | number | 是 | 用户Id。 | +| userId | number | 是 | 用户ID。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取是否同步通知到未安装应用程序的设备的结果。
true: 是。
false: 否。 | +| 类型 | 说明 | +| ------------------ | ------------------------------------------------------------ | +| Promise\ | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果。 | **示例:** ```js let userId = 100; - -Notification.getSyncNotificationEnabledWithoutApp(userId) - .then((data) => { - console.info('getSyncNotificationEnabledWithoutApp, data:', data); - }) - .catch((err) => { - console.info('getSyncNotificationEnabledWithoutApp, err:', err); - }); +Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { + console.info('getSyncNotificationEnabledWithoutApp, data:' + data); +}).catch((err) => { + console.info('getSyncNotificationEnabledWithoutApp, err:' + err); +}); ``` ## NotificationSubscriber -提供订阅者接收到新通知或取消通知时的回调方法。 +作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。 **系统API**:此接口为系统接口,三方应用不支持调用。 @@ -3418,7 +3393,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void -接收通知回调函数。 +接收到新通知的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -3428,7 +3403,7 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------ | ---- | -------------------------- | -| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | +| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 新接收到的通知信息。 | **示例:** @@ -3442,12 +3417,11 @@ function subscribeCallback(err) { }; function onConsumeCallback(data) { - console.info('===> onConsume in test'); let req = data.request; console.info('===> onConsume callback req.id:' + req.id); }; -var subscriber = { +let subscriber = { onConsume: onConsumeCallback }; @@ -3458,7 +3432,7 @@ Notification.subscribe(subscriber, subscribeCallback); onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void -删除通知回调函数。 +取消通知的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -3468,7 +3442,7 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------ | ---- | -------------------------- | -| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | +| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 需要取消的通知信息。 | **示例:** @@ -3482,12 +3456,11 @@ function subscribeCallback(err) { }; function onCancelCallback(data) { - console.info('===> onCancel in test'); let req = data.request; console.info('===> onCancel callback req.id:' + req.id); } -var subscriber = { +let subscriber = { onCancel: onCancelCallback }; @@ -3498,7 +3471,7 @@ Notification.subscribe(subscriber, subscribeCallback); onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void -更新通知排序回调函数。 +更新通知排序的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -3508,7 +3481,7 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------ | ---- | -------------------------- | -| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 回调返回接收到的通知信息。 | +| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 最新的通知排序列表。 | **示例:** @@ -3521,11 +3494,11 @@ function subscribeCallback(err) { } }; -function onUpdateCallback() { - console.info('===> onUpdate in test'); +function onUpdateCallback(map) { + console.info('===> onUpdateCallback map:' + JSON.stringify(map)); } -var subscriber = { +let subscriber = { onUpdate: onUpdateCallback }; @@ -3536,7 +3509,7 @@ Notification.subscribe(subscriber, subscribeCallback); onConnect?:() => void -注册订阅回调函数。 +订阅完成的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -3557,7 +3530,7 @@ function onConnectCallback() { console.info('===> onConnect in test'); } -var subscriber = { +let subscriber = { onConnect: onConnectCallback }; @@ -3568,7 +3541,7 @@ Notification.subscribe(subscriber, subscribeCallback); onDisconnect?:() => void -取消订阅回调函数。 +取消订阅的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -3584,16 +3557,30 @@ function subscribeCallback(err) { 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() { console.info('===> onDisconnect in test'); } -var subscriber = { +let subscriber = { + onConnect: onConnectCallback, onDisconnect: onDisconnectCallback }; +// 订阅通知后会收到onConnect回调 Notification.subscribe(subscriber, subscribeCallback); +// 取消订阅后会收到onDisconnect回调 +Notification.unsubscribe(subscriber, unsubscribeCallback); ``` ### onDestroy @@ -3621,7 +3608,7 @@ function onDestroyCallback() { console.info('===> onDestroy in test'); } -var subscriber = { +let subscriber = { onDestroy: onDestroyCallback }; @@ -3632,7 +3619,7 @@ Notification.subscribe(subscriber, subscribeCallback); onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void -免打扰时间选项变更回调函数。 +免打扰时间选项发生变更时的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -3654,15 +3641,24 @@ function subscribeCallback(err) { } }; -function onDoNotDisturbDateChangeCallback() { - console.info('===> onDoNotDisturbDateChange in test'); +function onDoNotDisturbDateChangeCallback(mode) { + console.info('===> onDoNotDisturbDateChange:' + mode); } -var subscriber = { +let subscriber = { onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback }; - 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) { }; function onEnabledNotificationChangedCallback(callbackData) { - console.info("bundle: ", callbackData.bundle); - console.info("uid: ", callbackData.uid); - console.info("enable: ", callbackData.enable); + console.info("bundle: " + callbackData.bundle); + console.info("uid: " + callbackData.uid); + console.info("enable: " + callbackData.enable); }; -var subscriber = { +let subscriber = { onEnabledNotificationChanged: onEnabledNotificationChangedCallback }; - Notification.subscribe(subscriber, subscribeCallback); + +let bundle = { + bundle: "bundleName1", +} +// 设置指定应用通知使能状态触发onEnabledNotificationChanged回调 +Notification.enableNotification(bundle, false).then(() => { + console.info("enableNotification sucess"); +}); ``` ## SubscribeCallbackData @@ -3715,7 +3718,7 @@ Notification.subscribe(subscriber, subscribeCallback); | 名称 | 类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------------------------------- | ---- | --- | -------- | | request | [NotificationRequest](#notificationrequest) | 是 | 否 | 通知内容。 | -| sortingMap | [NotificationSortingMap](#notificationsortingmap) | 是 | 否 | 排序信息。 | +| sortingMap | [NotificationSortingMap](#notificationsortingmap) | 是 | 否 | 通知排序信息。 | | reason | number | 是 | 否 | 删除原因。 | | sound | string | 是 | 否 | 通知声音。 | | vibrationValues | Array\ | 是 | 否 | 通知震动。 | @@ -3740,13 +3743,11 @@ Notification.subscribe(subscriber, subscribeCallback); **系统API**:此接口为系统接口,三方应用不支持调用。 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----- ------------------------------------- || ---- | --- | ------------------------ | -| type | [DoNotDisturbType](#donotdisturbtype8) | 是 | 否 | 指定免打扰设置的时间类型。 | -| begin | Date | 是 | 否 | 指定免打扰设置的起点时间。 | -| end | Date | 是 | 否 | 指定免打扰设置的终点时间。 | - - +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | -------------------------------------- | ---- | ---- | ---------------------- | +| type | [DoNotDisturbType](#donotdisturbtype8) | 是 | 是 | 免打扰设置的时间类型。 | +| begin | Date | 是 | 是 | 免打扰设置的起点时间。 | +| end | Date | 是 | 是 | 免打扰设置的终点时间。 | ## DoNotDisturbType8+ @@ -3793,8 +3794,8 @@ Notification.subscribe(subscriber, subscribeCallback); | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ |---- | --- | ------ | -| bundle | string | 是 | 是 | 包名。 | -| uid | number | 是 | 是 | 用户id。 | +| bundle | string | 是 | 是 | 应用的包信息。 | +| uid | number | 是 | 是 | 用户ID。 | @@ -3830,7 +3831,7 @@ Notification.subscribe(subscriber, subscribeCallback); | 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | ----------------------------------------------- | --- | ---- | ------------------------- | | title | string | 是 | 是 | 按钮标题。 | -| wantAgent | WantAgent | 是 | 是 | 点击按钮时触发的WantAgent。 | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 点击按钮时触发的WantAgent。 | | extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 | | userInput8+ | [NotificationUserInput](#notificationuserinput8) | 是 | 是 | 用户输入对象实例。 | @@ -3845,7 +3846,7 @@ Notification.subscribe(subscriber, subscribeCallback); | -------------- | ------ | ---- | ---- | ---------------------------------- | | title | string | 是 | 是 | 通知标题。 | | text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | ## NotificationLongTextContent @@ -3858,7 +3859,7 @@ Notification.subscribe(subscriber, subscribeCallback); | -------------- | ------ | ---- | --- | -------------------------------- | | title | string | 是 | 是 | 通知标题。 | | text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | | longText | string | 是 | 是 | 通知的长文本。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | | expandedTitle | string | 是 | 是 | 通知展开时的标题。 | @@ -3874,7 +3875,7 @@ Notification.subscribe(subscriber, subscribeCallback); | -------------- | --------------- | --- | --- | -------------------------------- | | title | string | 是 | 是 | 通知标题。 | | text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | | longTitle | string | 是 | 是 | 通知展开时的标题。 | | lines | Array\ | 是 | 是 | 通知的多行文本。 | @@ -3890,10 +3891,10 @@ Notification.subscribe(subscriber, subscribeCallback); | -------------- | -------------- | ---- | --- | -------------------------------- | | title | string | 是 | 是 | 通知标题。 | | text | string | 是 | 是 | 通知内容。 | -| additionalText | string | 是 | 是 | 通知次要内容,是对通知内容的补充。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | | briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | | expandedTitle | string | 是 | 是 | 通知展开时的标题。 | -| picture | image.PixelMap | 是 | 是 | 通知的图片内容。 | +| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知的图片内容。 | ## NotificationContent @@ -3934,8 +3935,8 @@ Notification.subscribe(subscriber, subscribeCallback); | 名称 | 类型 | 可读 | 可写 | 说明 | | ---------------- | ---------------------- | ---- | ---- | --------------------------------- | -| soundEnabled | NotificationFlagStatus | 是 | 否 | 是否启用声音提示。 | -| vibrationEnabled | NotificationFlagStatus | 是 | 否 | 是否启用振动提醒功能。 | +| soundEnabled | [NotificationFlagStatus](#notificationflagstatus8) | 是 | 否 | 是否启用声音提示。 | +| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus8) | 是 | 否 | 是否启用振动提醒功能。 | ## NotificationRequest @@ -3954,11 +3955,11 @@ Notification.subscribe(subscriber, subscribeCallback); | deliveryTime | number | 是 | 是 | 通知发送时间。 | | tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 | | autoDeletedTime | number | 是 | 是 | 自动清除的时间。 | -| wantAgent | WantAgent | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | | extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 | -| color | number | 是 | 是 | 通知背景颜色。暂不支持。 | -| colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。暂不支持。 | -| isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知警报。 | +| color | number | 是 | 是 | 通知背景颜色。预留能力,暂未支持。 | +| colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。预留能力,暂未支持。 | +| isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知提醒。 | | isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 | | isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 | | isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 | @@ -3966,8 +3967,8 @@ Notification.subscribe(subscriber, subscribeCallback); | badgeIconStyle | number | 是 | 是 | 通知角标类型。 | | showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 | | actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | 是 | 是 | 通知按钮,最多两个按钮。 | -| smallIcon | PixelMap | 是 | 是 | 通知小图标。 | -| largeIcon | PixelMap | 是 | 是 | 通知大图标。 | +| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知小图标。可选字段,大小不超过30KB。 | +| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知大图标。可选字段,大小不超过30KB。 | | creatorBundleName | string | 是 | 否 | 创建通知的包名。 | | creatorUid | number | 是 | 否 | 创建通知的UID。 | | creatorPid | number | 是 | 否 | 创建通知的PID。 | @@ -3981,10 +3982,9 @@ Notification.subscribe(subscriber, subscribeCallback); | distributedOption8+ | [DistributedOptions](#distributedoptions8) | 是 | 是 | 分布式通知的选项。 | | deviceId8+ | string | 是 | 否 | 通知源的deviceId。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | | notificationFlags8+ | [NotificationFlags](#notificationflags8) | 是 | 否 | 获取NotificationFlags。 | -| removalWantAgent9+ | WantAgent | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 | +| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 | | badgeNumber9+ | number | 是 | 是 | 应用程序图标上显示的通知数。 | - ## DistributedOptions8+ 描述分布式选项。 @@ -3994,8 +3994,8 @@ Notification.subscribe(subscriber, subscribeCallback); | 名称 | 类型 | 可读 | 可写 | 说明 | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- | | isDistributed | boolean | 是 | 是 | 是否为分布式通知。 | -| supportDisplayDevices | Array\ | 是 | 是 | 可以同步通知到的设备类型。 | -| supportOperateDevices | Array\ | 是 | 是 | 可以打开通知的设备。 | +| supportDisplayDevices | Array\ | 是 | 是 | 可以同步通知到的设备列表。 | +| supportOperateDevices | Array\ | 是 | 是 | 可以打开通知的设备列表。 | | remindType | number | 是 | 否 | 通知的提醒方式。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md b/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md index 4e8bc45120117bda88f19e622ed58c79a5a635f7..7c53b3cd6e78afc6cc4f8520689bc6c193e8e474 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md @@ -22,10 +22,10 @@ publish(request: NotificationRequest, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | -| callback | AsyncCallback\ | 是 | 被指定的回调方法。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| callback | AsyncCallback\ | 是 | 发布通知的回调方法。 | **错误码:** @@ -50,7 +50,7 @@ function publishCallback(err) { } } //通知Request对象 -var notificationRequest = { +let notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -60,8 +60,8 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} -Notification.publish(notificationRequest, publishCallback) +}; +Notification.publish(notificationRequest, publishCallback); ``` @@ -76,9 +76,9 @@ publish(request: NotificationRequest): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | **错误码:** @@ -94,8 +94,8 @@ publish(request: NotificationRequest): Promise\ **示例:** ```js -//通知Request对象 -var notificationRequest = { +// 通知Request对象 +let notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -105,9 +105,9 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; Notification.publish(notificationRequest).then(() => { - console.info("publish sucess"); + console.info("publish success"); }); ``` @@ -116,7 +116,7 @@ Notification.publish(notificationRequest).then(() => { publish(request: NotificationRequest, userId: number, callback: AsyncCallback\): void -发布通知(callback形式)。 +发布通知给指定的用户(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -126,10 +126,10 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\ | 是 | 被指定的回调方法。 | **错误码:** @@ -147,7 +147,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\ -发布通知(Promise形式)。 +发布通知给指定的用户(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -186,10 +186,10 @@ publish(request: NotificationRequest, userId: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------- | ---- | ------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | -| userId | number | 是 | 接收通知用户的Id。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| userId | number | 是 | 用户ID。 | **错误码:** @@ -206,7 +206,7 @@ publish(request: NotificationRequest, userId: number): Promise\ **示例:** ```js -var notificationRequest = { +let notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -216,12 +216,12 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; -var userId = 1 +let userId = 1; Notification.publish(notificationRequest, userId).then(() => { - console.info("publish sucess"); + console.info("publish success"); }); ``` @@ -230,13 +230,13 @@ Notification.publish(notificationRequest, userId).then(() => { cancel(id: number, label: string, callback: AsyncCallback\): void -取消与指定id和label相匹配的已发布通知(callback形式)。 +通过通知ID和通知标签取消已发布的通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | | id | number | 是 | 通知ID。 | | label | string | 是 | 通知标签。 | @@ -254,7 +254,7 @@ cancel(id: number, label: string, callback: AsyncCallback\): void **示例:** ```js -//cancel回调 +// cancel回调 function cancelCallback(err) { if (err) { console.info("cancel failed " + JSON.stringify(err)); @@ -262,7 +262,7 @@ function cancelCallback(err) { console.info("cancel success"); } } -Notification.cancel(0, "label", cancelCallback) +Notification.cancel(0, "label", cancelCallback); ``` @@ -271,13 +271,13 @@ Notification.cancel(0, "label", cancelCallback) cancel(id: number, label?: string): Promise\ -取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 +取消与指定通知ID相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | -------- | | id | number | 是 | 通知ID。 | | label | string | 否 | 通知标签。 | @@ -295,7 +295,7 @@ cancel(id: number, label?: string): Promise\ ```js Notification.cancel(0).then(() => { - console.info("cancel sucess"); + console.info("cancel success"); }); ``` @@ -305,13 +305,13 @@ Notification.cancel(0).then(() => { cancel(id: number, callback: AsyncCallback\): void -取消与指定id相匹配的已发布通知(callback形式)。 +取消与指定通知ID相匹配的已发布通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | | id | number | 是 | 通知ID。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | @@ -328,7 +328,7 @@ cancel(id: number, callback: AsyncCallback\): void **示例:** ```js -//cancel回调 +// cancel回调 function cancelCallback(err) { if (err) { console.info("cancel failed " + JSON.stringify(err)); @@ -336,7 +336,7 @@ function cancelCallback(err) { console.info("cancel success"); } } -Notification.cancel(0, cancelCallback) +Notification.cancel(0, cancelCallback); ``` @@ -359,14 +359,14 @@ cancelAll(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **示例:** ```js -//cancel回调 +// cancel回调 function cancelAllCallback(err) { if (err) { console.info("cancelAll failed " + JSON.stringify(err)); @@ -374,7 +374,7 @@ function cancelAllCallback(err) { console.info("cancelAll success"); } } -Notification.cancelAll(cancelAllCallback) +Notification.cancelAll(cancelAllCallback); ``` @@ -399,7 +399,7 @@ cancelAll(): Promise\ ```js Notification.cancelAll().then(() => { - console.info("cancelAll sucess"); + console.info("cancelAll success"); }); ``` @@ -419,7 +419,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | | slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | @@ -435,7 +435,7 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\): void **示例:** ```js -//addslot回调 +// addslot回调 function addSlotCallBack(err) { if (err) { console.info("addSlot failed " + JSON.stringify(err)); @@ -443,11 +443,11 @@ function addSlotCallBack(err) { console.info("addSlot success"); } } -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} -Notification.addSlot(notificationSlot, addSlotCallBack) +}; +Notification.addSlot(notificationSlot, addSlotCallBack); ``` @@ -466,7 +466,7 @@ addSlot(slot: NotificationSlot): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ---------------- | ---- | -------------------- | | slot | [NotificationSlot](#notificationslot) | 是 | 要创建的通知通道对象。 | @@ -481,12 +481,12 @@ addSlot(slot: NotificationSlot): Promise\ **示例:** ```js -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.addSlot(notificationSlot).then(() => { - console.info("addSlot sucess"); + console.info("addSlot success"); }); ``` @@ -496,13 +496,13 @@ Notification.addSlot(notificationSlot).then(() => { addSlot(type: SlotType, callback: AsyncCallback\): void -创建通知通道(callback形式)。 +创建指定类型的通知通道(callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ---------------------- | | type | [SlotType](#slottype) | 是 | 要创建的通知通道的类型。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | @@ -518,7 +518,7 @@ addSlot(type: SlotType, callback: AsyncCallback\): void **示例:** ```js -//addslot回调 +// addslot回调 function addSlotCallBack(err) { if (err) { console.info("addSlot failed " + JSON.stringify(err)); @@ -526,7 +526,7 @@ function addSlotCallBack(err) { 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 addSlot(type: SlotType): Promise\ -创建通知通道(Promise形式)。 +创建指定类型的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | -------- | ---- | ---------------------- | | type | [SlotType](#slottype) | 是 | 要创建的通知通道的类型。 | @@ -557,7 +557,7 @@ addSlot(type: SlotType): Promise\ ```js Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { - console.info("addSlot sucess"); + console.info("addSlot success"); }); ``` @@ -577,7 +577,7 @@ addSlots(slots: Array\, callback: AsyncCallback\): voi **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------ | | slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | @@ -593,7 +593,7 @@ addSlots(slots: Array\, callback: AsyncCallback\): voi **示例:** ```js -//addSlots回调 +// addSlots回调 function addSlotsCallBack(err) { if (err) { console.info("addSlots failed " + JSON.stringify(err)); @@ -601,15 +601,15 @@ function addSlotsCallBack(err) { console.info("addSlots success"); } } -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} -//通知slot array 对象 -var notificationSlotArray = new Array(); +}; +// 通知slot array 对象 +let notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; -Notification.addSlots(notificationSlotArray, addSlotsCallBack) +Notification.addSlots(notificationSlotArray, addSlotsCallBack); ``` @@ -628,7 +628,7 @@ addSlots(slots: Array\): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------------------------- | ---- | ------------------------ | | slots | Array\<[NotificationSlot](#notificationslot)\> | 是 | 要创建的通知通道对象数组。 | @@ -643,16 +643,16 @@ addSlots(slots: Array\): Promise\ **示例:** ```js -//通知slot对象 -var notificationSlot = { +// 通知slot对象 +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} -//通知slot array 对象 -var notificationSlotArray = new Array(); +}; +// 通知slot array 对象 +let notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; Notification.addSlots(notificationSlotArray).then(() => { - console.info("addSlots sucess"); + console.info("addSlots success"); }); ``` @@ -662,15 +662,15 @@ Notification.addSlots(notificationSlotArray).then(() => { getSlot(slotType: SlotType, callback: AsyncCallback\): void -获取一个通知通道(callback形式)。 +获取一个指定类型的通知通道(callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ----------------------------------------------------------- | -| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | +| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | 是 | 表示被指定的回调方法。 | **错误码:** @@ -684,7 +684,7 @@ getSlot(slotType: SlotType, callback: AsyncCallback\): void **示例:** ```js -//getSlot回调 +// getSlot回调 function getSlotCallback(err,data) { if (err) { console.info("getSlot failed " + JSON.stringify(err)); @@ -692,8 +692,8 @@ function getSlotCallback(err,data) { console.info("getSlot success"); } } -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; -Notification.getSlot(slotType, getSlotCallback) +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +Notification.getSlot(slotType, getSlotCallback); ``` @@ -702,15 +702,15 @@ Notification.getSlot(slotType, getSlotCallback) getSlot(slotType: SlotType): Promise\ -获取一个通知通道(Promise形式)。 +获取一个指定类型的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ----------------------------------------------------------- | -| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | +| slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | **返回值:** @@ -729,9 +729,9 @@ getSlot(slotType: SlotType): Promise\ **示例:** ```js -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; 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>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\\> | 是 | 表示被指定的回调方法。 | +| callback | AsyncCallback\\> | 是 | 以callback形式返回获取此应用程序的所有通知通道的结果。 | **错误码:** @@ -762,7 +762,7 @@ getSlots(callback: AsyncCallback>): void **示例:** ```js -//getSlots回调 +// getSlots回调 function getSlotsCallback(err,data) { if (err) { console.info("getSlots failed " + JSON.stringify(err)); @@ -770,7 +770,7 @@ function getSlotsCallback(err,data) { console.info("getSlots success"); } } -Notification.getSlots(getSlotsCallback) +Notification.getSlots(getSlotsCallback); ``` @@ -801,7 +801,7 @@ getSlots(): Promise\> ```js 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) => { removeSlot(slotType: SlotType, callback: AsyncCallback\): void -根据通知通道类型删除创建的通知通道(callback形式)。 +删除指定类型的通知通道(callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ----------------------------------------------------------- | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | @@ -833,7 +833,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\): void **示例:** ```js -//removeSlot回调 +// removeSlot回调 function removeSlotCallback(err) { if (err) { console.info("removeSlot failed " + JSON.stringify(err)); @@ -841,8 +841,8 @@ function removeSlotCallback(err) { console.info("removeSlot success"); } } -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; -Notification.removeSlot(slotType,removeSlotCallback) +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +Notification.removeSlot(slotType,removeSlotCallback); ``` @@ -851,13 +851,13 @@ Notification.removeSlot(slotType,removeSlotCallback) removeSlot(slotType: SlotType): Promise\ -根据通知通道类型删除创建的通知通道(Promise形式)。 +删除指定类型的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ----------------------------------------------------------- | | slotType | [SlotType](#slottype) | 是 | 通知渠道类型,目前分为社交通信、服务提醒、内容咨询和其他类型。 | @@ -872,9 +872,9 @@ removeSlot(slotType: SlotType): Promise\ **示例:** ```js -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.removeSlot(slotType).then(() => { - console.info("removeSlot sucess"); + console.info("removeSlot success"); }); ``` @@ -890,7 +890,7 @@ removeAllSlots(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | @@ -912,7 +912,7 @@ function removeAllCallBack(err) { console.info("removeAllSlots success"); } } -Notification.removeAllSlots(removeAllCallBack) +Notification.removeAllSlots(removeAllCallBack); ``` @@ -937,7 +937,7 @@ removeAllSlots(): Promise\ ```js Notification.removeAllSlots().then(() => { - console.info("removeAllSlots sucess"); + console.info("removeAllSlots success"); }); ``` @@ -947,7 +947,7 @@ Notification.removeAllSlots().then(() => { setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void -设定指定包的通知使能状态(Callback形式)。 +设定指定应用的通知使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -957,9 +957,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | | callback | AsyncCallback\ | 是 | 设定通知使能回调函数。 | @@ -982,9 +982,9 @@ function setNotificationEnablenCallback(err) { console.info("setNotificationEnablenCallback success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback); ``` @@ -994,7 +994,7 @@ Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\ -设定指定包的通知使能状态(Promise形式)。 +设定指定应用的通知使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1004,9 +1004,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | **错误码:** @@ -1021,11 +1021,11 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\ **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.setNotificationEnable(bundle, false).then(() => { - console.info("setNotificationEnable sucess"); + console.info("setNotificationEnable success"); }); ``` @@ -1035,7 +1035,7 @@ Notification.setNotificationEnable(bundle, false).then(() => { isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): void -获取指定包的通知使能状态(Callback形式)。 +获取指定应用的通知使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1045,9 +1045,9 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | callback | AsyncCallback\ | 是 | 获取通知使能状态回调函数。 | **错误码:** @@ -1069,9 +1069,9 @@ function isNotificationEnabledCallback(err, data) { console.info("isNotificationEnabled success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); ``` @@ -1081,7 +1081,7 @@ Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); isNotificationEnabled(bundle: BundleOption): Promise\ -获取指定包的通知使能状态(Promise形式)。 +获取指定应用的通知使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1091,15 +1091,15 @@ isNotificationEnabled(bundle: BundleOption): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取指定包的通知使能状态的结果。 | +| 类型 | 说明 | +| ------------------ | --------------------------------------------------- | +| Promise\ | 以Promise形式返回获取指定应用的通知使能状态的结果。 | **错误码:** @@ -1113,11 +1113,11 @@ isNotificationEnabled(bundle: BundleOption): Promise\ **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------ | | callback | AsyncCallback\ | 是 | 获取通知使能状态回调函数。 | @@ -1179,9 +1179,9 @@ isNotificationEnabled(): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** @@ -1202,7 +1202,7 @@ isNotificationEnabled(): Promise\ ```js 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) => { displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void -设定指定包的角标使能状态(Callback形式)。 +设定指定应用的角标使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1222,9 +1222,9 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\ | 是 | 设定角标使能回调函数。 | @@ -1247,9 +1247,9 @@ function displayBadgeCallback(err) { console.info("displayBadge success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.displayBadge(bundle, false, displayBadgeCallback); ``` @@ -1259,7 +1259,7 @@ Notification.displayBadge(bundle, false, displayBadgeCallback); displayBadge(bundle: BundleOption, enable: boolean): Promise\ -设定指定包的角标使能状态(Promise形式)。 +设定指定应用的角标使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1269,9 +1269,9 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | enable | boolean | 是 | 使能状态。 | **错误码:** @@ -1286,11 +1286,11 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\ **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.displayBadge(bundle, false).then(() => { - console.info("displayBadge sucess"); + console.info("displayBadge success"); }); ``` @@ -1300,7 +1300,7 @@ Notification.displayBadge(bundle, false).then(() => { isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\): void -获取指定包的角标使能状态(Callback形式)。 +获取指定应用的角标使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1310,9 +1310,9 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ------------------------ | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | callback | AsyncCallback\ | 是 | 获取角标使能状态回调函数。 | **错误码:** @@ -1334,9 +1334,9 @@ function isBadgeDisplayedCallback(err, data) { console.info("isBadgeDisplayed success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); ``` @@ -1346,7 +1346,7 @@ Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); isBadgeDisplayed(bundle: BundleOption): Promise\ -获取指定包的角标使能状态(Promise形式)。 +获取指定应用的角标使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1356,15 +1356,15 @@ isBadgeDisplayed(bundle: BundleOption): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取指定包的角标使能状态。 | +| Promise\ | 以Promise形式返回获取指定应用的角标使能状态。 | **错误码:** @@ -1378,11 +1378,11 @@ isBadgeDisplayed(bundle: BundleOption): Promise\ **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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) => { setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\): void -设定指定包的通知通道状态(Callback形式)。 +设定指定应用的通知通道(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1402,9 +1402,9 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | | callback | AsyncCallback\ | 是 | 设定通知通道回调函数。 | @@ -1429,12 +1429,12 @@ function setSlotByBundleCallback(err) { console.info("setSlotByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationSlot = { +}; +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); ``` @@ -1444,7 +1444,7 @@ Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ -设定指定包的通知通道状态(Promise形式)。 +设定指定应用的通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1454,10 +1454,10 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| slot | [NotificationSlot](#notificationslot) | 是 | 使能状态。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| slot | [NotificationSlot](#notificationslot) | 是 | 通知通道。 | **错误码:** @@ -1471,14 +1471,14 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationSlot = { +}; +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.setSlotByBundle(bundle, notificationSlot).then(() => { - console.info("setSlotByBundle sucess"); + console.info("setSlotByBundle success"); }); ``` @@ -1488,7 +1488,7 @@ Notification.setSlotByBundle(bundle, notificationSlot).then(() => { getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void -获取指定包的通知通道(Callback形式)。 +获取指定应用的所有通知通道(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1498,9 +1498,9 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback> | 是 | 获取通知通道回调函数。 | **错误码:** @@ -1522,9 +1522,9 @@ function getSlotsByBundleCallback(err, data) { console.info("getSlotsByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ``` @@ -1534,7 +1534,7 @@ Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); getSlotsByBundle(bundle: BundleOption): Promise> -获取指定包的通知通道(Promise形式)。 +获取指定应用的所有通知通道(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1544,15 +1544,15 @@ getSlotsByBundle(bundle: BundleOption): Promise> **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise> | 以Promise形式返回获取指定包的通知通道。 | +| Promise> | 以Promise形式返回获取指定应用的通知通道。 | **错误码:** @@ -1566,11 +1566,11 @@ getSlotsByBundle(bundle: BundleOption): Promise> **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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) => { getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\): void -获取指定包的通知通道数(Callback形式)。 +获取指定应用的通知通道数量(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1590,10 +1590,10 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\): voi **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| callback | AsyncCallback\ | 是 | 获取通知通道数回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| callback | AsyncCallback\ | 是 | 获取通知通道数量回调函数。 | **错误码:** @@ -1614,9 +1614,9 @@ function getSlotNumByBundleCallback(err, data) { console.info("getSlotNumByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); ``` @@ -1626,7 +1626,7 @@ Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); getSlotNumByBundle(bundle: BundleOption): Promise\ -获取指定包的通知通道数(Promise形式)。 +获取指定应用的通知通道数量(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1636,15 +1636,15 @@ getSlotNumByBundle(bundle: BundleOption): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取指定包的通知通道数。 | +| Promise\ | 以Promise形式返回获取指定应用的通知通道数量。 | **错误码:** @@ -1658,11 +1658,11 @@ getSlotNumByBundle(bundle: BundleOption): Promise\ **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; 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) => { getAllActiveNotifications(callback: AsyncCallback>): void -获取活动通知(Callback形式)。 +获取当前未删除的所有通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1683,7 +1683,7 @@ getAllActiveNotifications(callback: AsyncCallback>) **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | -------------------- | | callback | AsyncCallback> | 是 | 获取活动通知回调函数。 | @@ -1715,7 +1715,7 @@ Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); getAllActiveNotifications(): Promise\\> -获取活动通知(Promise形式)。 +获取当前未删除的所有通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1741,7 +1741,7 @@ getAllActiveNotifications(): Promise\ { - console.info("getAllActiveNotifications sucess, data: " + JSON.stringify(data)); + console.info("getAllActiveNotifications success, data: " + JSON.stringify(data)); }); ``` @@ -1751,15 +1751,15 @@ Notification.getAllActiveNotifications().then((data) => { getActiveNotificationCount(callback: AsyncCallback\): void -获取当前应用的活动通知数(Callback形式)。 +获取当前应用未删除的通知数(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---------------------- | -| callback | AsyncCallback\ | 是 | 获取活动通知数回调函数。 | +| callback | AsyncCallback\ | 是 | 获取未删除通知数回调函数。 | **错误码:** @@ -1789,15 +1789,15 @@ Notification.getActiveNotificationCount(getActiveNotificationCountCallback); getActiveNotificationCount(): Promise\ -获取当前应用的活动通知数(Promise形式)。 +获取当前应用未删除的通知数(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取当前应用的活动通知数。 | +| 类型 | 说明 | +| ----------------- | ------------------------------------------- | +| Promise\ | 以Promise形式返回获取当前应用未删除通知数。 | **错误码:** @@ -1811,7 +1811,7 @@ getActiveNotificationCount(): Promise\ ```js 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) => { getActiveNotifications(callback: AsyncCallback>): void -获取当前应用的活动通知(Callback形式)。 +获取当前应用未删除的通知列表(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ | -| callback | AsyncCallback> | 是 | 获取当前应用的活动通知回调函数。 | +| callback | AsyncCallback> | 是 | 获取当前应用通知列表回调函数。 | **错误码:** @@ -1859,15 +1859,15 @@ Notification.getActiveNotifications(getActiveNotificationsCallback); getActiveNotifications(): Promise\\> -获取当前应用的活动通知(Promise形式)。 +获取当前应用未删除的通知列表(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\\> | 以Promise形式返回获取当前应用的活动通知。 | +| 类型 | 说明 | +| ------------------------------------------------------------ | --------------------------------------- | +| Promise\\> | 以Promise形式返回获取当前应用通知列表。 | **错误码:** @@ -1881,7 +1881,7 @@ getActiveNotifications(): Promise\ { - console.info("removeGroupByBundle sucess, data: " + JSON.stringify(data)); + console.info("removeGroupByBundle success, data: " + JSON.stringify(data)); }); ``` @@ -1891,16 +1891,16 @@ Notification.getActiveNotifications().then((data) => { cancelGroup(groupName: string, callback: AsyncCallback\): void -取消本应用指定组通知(Callback形式)。 +取消本应用指定组下的通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------- | -| groupName | string | 是 | 指定通知组名称。 | -| callback | AsyncCallback\ | 是 | 取消本应用指定组通知回调函数。 | +| groupName | string | 是 | 通知组名称,此名称需要在发布通知时通过[NotificationRequest](#notificationrequest)对象指定。 | +| callback | AsyncCallback\ | 是 | 取消本应用指定组下通知的回调函数。 | **错误码:** @@ -1921,7 +1921,7 @@ function cancelGroupCallback(err) { } } -var groupName = "GroupName"; +let groupName = "GroupName"; Notification.cancelGroup(groupName, cancelGroupCallback); ``` @@ -1932,15 +1932,15 @@ Notification.cancelGroup(groupName, cancelGroupCallback); cancelGroup(groupName: string): Promise\ -取消本应用指定组通知(Promise形式)。 +取消本应用指定组下的通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | -------------- | -| groupName | string | 是 | 指定通知组名称。 | +| groupName | string | 是 | 通知组名称。 | **错误码:** @@ -1953,9 +1953,9 @@ cancelGroup(groupName: string): Promise\ **示例:** ```js -var groupName = "GroupName"; +let groupName = "GroupName"; Notification.cancelGroup(groupName).then(() => { - console.info("cancelGroup sucess"); + console.info("cancelGroup success"); }); ``` @@ -1965,7 +1965,7 @@ Notification.cancelGroup(groupName).then(() => { removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\): void -删除指定应用指定组通知(Callback形式)。 +删除指定应用的指定组下的通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -1975,11 +1975,11 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| groupName | string | 是 | 指定通知组名称。 | -| callback | AsyncCallback\ | 是 | 删除本应用指定组通知回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| groupName | string | 是 | 通知组名称。 | +| callback | AsyncCallback\ | 是 | 删除指定应用指定组下通知的回调函数。 | **错误码:** @@ -2001,8 +2001,8 @@ function removeGroupByBundleCallback(err) { } } -var bundleOption = {bundle: "Bundle"}; -var groupName = "GroupName"; +let bundleOption = {bundle: "Bundle"}; +let groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); ``` @@ -2013,7 +2013,7 @@ Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCal removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ -删除指定应用指定组通知(Promise形式)。 +删除指定应用的指定组下的通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2023,10 +2023,10 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ------------ | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| groupName | string | 是 | 指定通知组名称。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| groupName | string | 是 | 通知组名称。 | **错误码:** @@ -2040,10 +2040,10 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ **示例:** ```js -var bundleOption = {bundle: "Bundle"}; -var groupName = "GroupName"; +let bundleOption = {bundle: "Bundle"}; +let groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName).then(() => { - console.info("removeGroupByBundle sucess"); + console.info("removeGroupByBundle success"); }); ``` @@ -2063,7 +2063,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\): vo **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ---------------------- | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | | callback | AsyncCallback\ | 是 | 设置免打扰时间回调函数。 | @@ -2087,11 +2087,11 @@ function setDoNotDisturbDateCallback(err) { } } -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); ``` @@ -2102,7 +2102,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); setDoNotDisturbDate(date: DoNotDisturbDate): Promise\ -设置免打扰时间接口(Promise形式)。 +设置免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2112,7 +2112,7 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ---------------- | ---- | -------------- | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | @@ -2127,13 +2127,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\ **示例:** ```js -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { - console.info("setDoNotDisturbDate sucess"); + console.info("setDoNotDisturbDate success"); }); ``` @@ -2152,10 +2152,10 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ---------------------- | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 设置免打扰时间的用户ID。 | | callback | AsyncCallback\ | 是 | 设置免打扰时间回调函数。 | **错误码:** @@ -2178,13 +2178,13 @@ function setDoNotDisturbDateCallback(err) { } } -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; -var userId = 1 +let userId = 1; Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); ``` @@ -2195,7 +2195,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCa setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\ -指定用户设置免打扰时间接口(Promise形式)。 +指定用户设置免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2205,10 +2205,10 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------- | ---- | -------------- | | date | [DoNotDisturbDate](#donotdisturbdate) | 是 | 免打扰时间选项。 | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 设置免打扰时间的用户ID。 | **错误码:** @@ -2222,16 +2222,16 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\ **示例:** ```js -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; -var userId = 1 +let userId = 1; Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { - console.info("setDoNotDisturbDate sucess"); + console.info("setDoNotDisturbDate success"); }); ``` @@ -2240,7 +2240,7 @@ Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { getDoNotDisturbDate(callback: AsyncCallback\): void -查询免打扰时间接口(Callback形式)。 +查询免打扰时间(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2250,7 +2250,7 @@ getDoNotDisturbDate(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ---------------------- | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是 | 查询免打扰时间回调函数。 | @@ -2282,7 +2282,7 @@ Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); getDoNotDisturbDate(): Promise\ -查询免打扰时间接口(Promise形式)。 +查询免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2294,7 +2294,7 @@ getDoNotDisturbDate(): Promise\ | 类型 | 说明 | | ------------------------------------------------ | ----------------------------------------- | -| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询免打扰时间接口。 | +| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 | **错误码:** @@ -2308,7 +2308,7 @@ getDoNotDisturbDate(): Promise\ ```js 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) => { getDoNotDisturbDate(userId: number, callback: AsyncCallback\): void -指定用户查询免打扰时间接口(Callback形式)。 +查询指定用户的免打扰时间(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2327,10 +2327,10 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\) **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ---------------------- | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate)\> | 是 | 查询免打扰时间回调函数。 | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 用户ID。 | **错误码:** @@ -2352,7 +2352,7 @@ function getDoNotDisturbDateCallback(err,data) { } } -var userId = 1 +let userId = 1; Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); ``` @@ -2363,7 +2363,7 @@ Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); getDoNotDisturbDate(userId: number): Promise\ -指定用户查询免打扰时间接口(Promise形式)。 +查询指定用户的免打扰时间(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2373,15 +2373,15 @@ getDoNotDisturbDate(userId: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ---------------------- | -| userId | number | 是 | 设置免打扰事件的用户ID。 | +| userId | number | 是 | 用户ID。 | **返回值:** | 类型 | 说明 | | ------------------------------------------------ | ----------------------------------------- | -| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询免打扰时间接口。 | +| Promise\<[DoNotDisturbDate](#donotdisturbdate)\> | 以Promise形式返回获取查询到的免打扰时间。 | **错误码:** @@ -2395,10 +2395,10 @@ getDoNotDisturbDate(userId: number): Promise\ **示例:** ```js -var userId = 1 +let userId = 1; 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) => { supportDoNotDisturbMode(callback: AsyncCallback\): void -查询是否支持勿扰模式功能(Callback形式)。 +查询是否支持免打扰功能(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2417,9 +2417,9 @@ supportDoNotDisturbMode(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------------- | -| callback | AsyncCallback\ | 是 | 查询是否支持勿扰模式功能回调函数。 | +| callback | AsyncCallback\ | 是 | 查询是否支持免打扰功能回调函数。 | **错误码:** @@ -2461,7 +2461,7 @@ supportDoNotDisturbMode(): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取是否支持勿扰模式功能的结果。 | +| Promise\ | 以Promise形式返回获取是否支持免打扰功能的结果。 | **错误码:** @@ -2475,7 +2475,7 @@ supportDoNotDisturbMode(): Promise\ ```js 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\): voi **示例:** ```javascript -var templateName = 'process'; +let templateName = 'process'; function isSupportTemplateCallback(err, data) { if (err) { console.info("isSupportTemplate failed " + JSON.stringify(err)); @@ -2554,7 +2554,7 @@ isSupportTemplate(templateName: string): Promise\ **示例:** ```javascript -var templateName = 'process'; +let templateName = 'process'; Notification.isSupportTemplate(templateName).then((data) => { console.info("isSupportTemplate success, data: " + JSON.stringify(data)); @@ -2620,10 +2620,9 @@ requestEnableNotification(): Promise\ **示例:** ```javascript -Notification.requestEnableNotification() - .then(() => { - console.info("requestEnableNotification sucess"); - }); +Notification.requestEnableNotification().then(() => { + console.info("requestEnableNotification success"); +}); ``` @@ -2644,7 +2643,7 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| enable | boolean | 是 | 是否支持。
true 支持。
false 不支持。| +| enable | boolean | 是 | 是否支持。 | | callback | AsyncCallback\ | 是 | 设置设备是否支持分布式通知的回调函数。 | **错误码:** @@ -2667,7 +2666,7 @@ function setDistributedEnableCallback() { } }; -var enable = true +let enable = true; Notification.setDistributedEnable(enable, setDistributedEnableCallback); ``` @@ -2690,7 +2689,7 @@ setDistributedEnable(enable: boolean): Promise\ | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| enable | boolean | 是 | 是否支持。
true 支持。
false 不支持。| +| enable | boolean | 是 | 是否支持。 | **错误码:** @@ -2704,11 +2703,10 @@ setDistributedEnable(enable: boolean): Promise\ **示例:** ```javascript -var enable = true +let enable = true; -Notification.setDistributedEnable(enable) - .then(() => { - console.info("setDistributedEnable sucess"); +Notification.setDistributedEnable(enable).then(() => { + console.info("setDistributedEnable success"); }); ``` @@ -2717,7 +2715,7 @@ Notification.setDistributedEnable(enable) isDistributedEnabled(callback: AsyncCallback\): void -获取设备是否支持分布式通知(Callback形式)。 +查询设备是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2739,11 +2737,11 @@ isDistributedEnabled(callback: AsyncCallback\): void **示例:** ```javascript -function isDistributedEnabledCallback(err) { +function isDistributedEnabledCallback(err, data) { if (err) { console.info("isDistributedEnabled failed " + JSON.stringify(err)); } else { - console.info("isDistributedEnabled success"); + console.info("isDistributedEnabled success " + JSON.stringify(data)); } }; @@ -2756,15 +2754,15 @@ Notification.isDistributedEnabled(isDistributedEnabledCallback); isDistributedEnabled(): Promise\ -获取设备是否支持分布式通知(Promise形式)。 +查询设备是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification **返回值:** -| 类型 | 说明 | -| ------------------ | --------------- | -| Promise\ | Promise方式返回设备是否支持分布式通知的结果。
true 支持。
false 不支持。 | +| 类型 | 说明 | +| ------------------ | --------------------------------------------- | +| Promise\ | Promise方式返回设备是否支持分布式通知的结果。 | **错误码:** @@ -2780,7 +2778,7 @@ isDistributedEnabled(): Promise\ ```javascript Notification.isDistributedEnabled() .then((data) => { - console.info("isDistributedEnabled sucess, data: " + JSON.stringify(data)); + console.info("isDistributedEnabled success, data: " + JSON.stringify(data)); }); ``` @@ -2789,7 +2787,7 @@ Notification.isDistributedEnabled() setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void -根据应用的包设置应用程序是否支持分布式通知(Callback形式)。 +设置指定应用是否支持分布式通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2801,7 +2799,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | -------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 应用的包。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | | enable | boolean | 是 | 是否支持。 | | callback | AsyncCallback\ | 是 | 应用程序是否支持分布式通知的回调函数。 | @@ -2826,11 +2824,11 @@ function setDistributedEnableByBundleCallback(err) { } }; -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; -var enable = true +let enable = true Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback); ``` @@ -2841,7 +2839,7 @@ Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableBy setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\ -根据应用的包设置应用程序是否支持分布式通知(Promise形式)。 +设置指定应用是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2869,15 +2867,14 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\ { - console.info("setDistributedEnableByBundle sucess"); +Notification.setDistributedEnableByBundle(bundle, enable).then(() => { + console.info("setDistributedEnableByBundle success"); }); ``` @@ -2898,7 +2895,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\ | 是 | 应用程序是否支持分布式通知的回调函数。 | +| callback | AsyncCallback\ | 是 | 查询指定应用是否支持分布式通知的回调函数。 | **错误码:** @@ -2917,13 +2914,13 @@ function isDistributedEnabledByBundleCallback(data) { if (err) { console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err)); } else { - console.info("isDistributedEnabledByBundle success"); + console.info("isDistributedEnabledByBundle success" + JSON.stringify(data)); } }; -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); ``` @@ -2934,7 +2931,7 @@ Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCa isDistributedEnabledByBundle(bundle: BundleOption): Promise\ -根据应用的包获取应用程序是否支持分布式通知(Promise形式)。 +查询指定应用是否支持分布式通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -2950,9 +2947,9 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\ **返回值:** -| 类型 | 说明 | -| ------------------ | --------------- | -| Promise\ | Promise方式返回应用程序是否支持分布式通知的结果。
true 支持。
false 不支持。 | +| 类型 | 说明 | +| ------------------ | ------------------------------------------------- | +| Promise\ | Promise方式返回指定应用是否支持分布式通知的结果。 | **错误码:** @@ -2967,14 +2964,13 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\ **示例:** ```javascript -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; -Notification.isDistributedEnabledByBundle(bundle) - .then((data) => { - console.info("isDistributedEnabledByBundle sucess, data: " + JSON.stringify(data)); - }); +Notification.isDistributedEnabledByBundle(bundle).then((data) => { + console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data)); +}); ``` @@ -2994,7 +2990,7 @@ getDeviceRemindType(callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | -------------------------- | -| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | 是 | 获取通知的提醒方式的回调函数。 | +| callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype)\> | 是 | 获取通知提醒方式的回调函数。 | **错误码:** @@ -3036,7 +3032,7 @@ getDeviceRemindType(): Promise\ | 类型 | 说明 | | ------------------ | --------------- | -| Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise方式返回通知的提醒方式的结果。 | +| Promise\<[DeviceRemindType](#deviceremindtype)\> | Promise方式返回获取通知提醒方式的结果。 | **错误码:** @@ -3049,10 +3045,9 @@ getDeviceRemindType(): Promise\ **示例:** ```javascript -Notification.getDeviceRemindType() - .then((data) => { - console.info("getDeviceRemindType sucess, data: " + JSON.stringify(data)); - }); +Notification.getDeviceRemindType().then((data) => { + console.info("getDeviceRemindType success, data: " + JSON.stringify(data)); +}); ``` @@ -3070,12 +3065,12 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | -| representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | -| callback | AsyncCallback | 是 | 发布代理通知的回调方法。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------------- | ------------------------------------------- | ---- | ---------------------------------------- | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | +| representativeBundle | string | 是 | 被代理应用的包名。 | +| userId | number | 是 | 用户ID。 | +| callback | AsyncCallback | 是 | 发布代理通知的回调方法。 | **错误码:** @@ -3093,7 +3088,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ```js //publishAsBundle回调 -function publishAsBundleCallback(err) { +function callback(err) { if (err) { console.info("publishAsBundle failed " + JSON.stringify(err)); } else { @@ -3101,11 +3096,11 @@ function publishAsBundleCallback(err) { } } // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 -//通知Request对象 -let notificationRequest = { +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; +// NotificationRequest对象 +let request = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -3115,9 +3110,9 @@ let notificationRequest = { additionalText: "test_additionalText" } } -} +}; -Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback); +Notification.publishAsBundle(request, representativeBundle, userId, callback); ``` ## Notification.publishAsBundle @@ -3137,9 +3132,9 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | -| request | [NotificationRequest](#notificationrequest) | 是 | 设置要发布通知内容的NotificationRequest对象。 | +| request | [NotificationRequest](#notificationrequest) | 是 | 用于设置要发布通知的内容和相关配置信息。 | | representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | **错误码:** @@ -3157,11 +3152,11 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user ```js // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 -//通知Request对象 -var notificationRequest = { +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; +// NotificationRequest对象 +let request = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -3171,10 +3166,10 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; -Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => { - console.info("publishAsBundle sucess"); +Notification.publishAsBundle(request, representativeBundle, userId).then(() => { + console.info("publishAsBundle success"); }); ``` @@ -3198,7 +3193,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac | -------------------- | ------------- | ---- | ------------------------ | | id | number | 是 | 通知ID。 | | representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | | callback | AsyncCallback | 是 | 取消代理通知的回调方法。 | **错误码:** @@ -3214,7 +3209,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac **示例:** ```js -//cancelAsBundle +// cancelAsBundle function cancelAsBundleCallback(err) { if (err) { console.info("cancelAsBundle failed " + JSON.stringify(err)); @@ -3223,9 +3218,9 @@ function cancelAsBundleCallback(err) { } } // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); ``` @@ -3234,7 +3229,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallb cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\ -发布代理通知(Promise形式)。 +取消代理通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3250,7 +3245,7 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis | -------------------- | ------ | ---- | ------------------ | | id | number | 是 | 通知ID。 | | representativeBundle | string | 是 | 被代理应用的包名。 | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | **错误码:** @@ -3266,9 +3261,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis ```js // 被代理应用的包名 -let representativeBundle = "com.example.demo" -// 接收通知的用户ID -let userId = 100 +let representativeBundle = "com.example.demo"; +// 用户ID +let userId = 100; Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { console.info("cancelAsBundle success"); @@ -3279,7 +3274,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\): void -设定指定类型的渠道使能状态(Callback形式)。 +设置指定应用的指定渠道类型的使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3291,10 +3286,10 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | | type | [SlotType](#slottype) | 是 | 指定渠道类型。 | | enable | boolean | 是 | 使能状态。 | -| callback | AsyncCallback\ | 是 | 设定渠道使能回调函数。 | +| callback | AsyncCallback\ | 是 | 设置渠道使能回调函数。 | **错误码:** @@ -3308,7 +3303,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, **示例:** ```js -//setNotificationEnableSlot +// setNotificationEnableSlot function setNotificationEnableSlotCallback(err) { if (err) { console.info("setNotificationEnableSlot failed " + JSON.stringify(err)); @@ -3328,7 +3323,7 @@ Notification.setNotificationEnableSlot( setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\ -设定指定类型的渠道使能状态(Promise形式)。 +设置指定应用的指定渠道类型的使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3340,8 +3335,8 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean) | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| type | [SlotType](#slottype) | 是 | 渠道类型。 | | enable | boolean | 是 | 使能状态。 | **错误码:** @@ -3356,12 +3351,12 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean) **示例:** ```js -//setNotificationEnableSlot +// setNotificationEnableSlot Notification.setNotificationEnableSlot( { bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION, true).then(() => { - console.info("setNotificationEnableSlot sucess"); + console.info("setNotificationEnableSlot success"); }); ``` @@ -3369,7 +3364,7 @@ Notification.setNotificationEnableSlot( isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\): void -获取指定类型的渠道使能状态(Callback形式)。 +获取指定应用的指定渠道类型的使能状态(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3381,9 +3376,9 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | ---------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| type | [SlotType](#slottype) | 是 | 指定渠道类型。 | -| callback | AsyncCallback\ | 是 | 设定渠道使能回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 应用的包信息。 | +| type | [SlotType](#slottype) | 是 | 渠道类型。 | +| callback | AsyncCallback\ | 是 | 获取渠道使能状态回调函数。 | **错误码:** @@ -3397,7 +3392,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC **示例:** ```js -//isNotificationSlotEnabled +// isNotificationSlotEnabled function getEnableSlotCallback(err, data) { if (err) { console.info("isNotificationSlotEnabled failed " + JSON.stringify(err)); @@ -3416,7 +3411,7 @@ Notification.isNotificationSlotEnabled( isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ -获取指定类型的渠道使能状态(Promise形式)。 +获取指定应用的指定渠道类型的使能状态(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3428,8 +3423,8 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ { - console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data)); - }); +// isNotificationSlotEnabled +Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", }, + Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => { + console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data)); +}); ``` @@ -3475,8 +3468,8 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| userId | number | 是 | 用户Id。 | -| enable | boolean | 是 | 是否启用。
true:启用。
false:禁用。 | +| userId | number | 是 | 用户ID。 | +| enable | boolean | 是 | 是否启用。 | | callback | AsyncCallback\ | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。 | **错误码:** @@ -3494,7 +3487,7 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: let userId = 100; let enable = true; -function setSyncNotificationEnabledWithoutAppCallback(err) { +function callback(err) { if (err) { console.info("setSyncNotificationEnabledWithoutApp failed " + JSON.stringify(err)); } else { @@ -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\< | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| userId | number | 是 | 用户Id。 | -| enable | boolean | 是 | 是否启用。
true:启用。
false:禁用。 | +| userId | number | 是 | 用户ID。 | +| enable | boolean | 是 | 是否启用。 | **返回值:** @@ -3546,13 +3539,11 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\< let userId = 100; let enable = true; -Notification.setSyncNotificationEnabledWithoutApp(userId, enable) - .then(() => { - console.info('setSyncNotificationEnabledWithoutApp'); - }) - .catch((err) => { - console.info('setSyncNotificationEnabledWithoutApp, err:', err); - }); +Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => { + console.info('setSyncNotificationEnabledWithoutApp success'); +}).catch((err) => { + console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err)); +}); ``` @@ -3560,7 +3551,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable) getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\): void -获取是否同步通知到未安装应用程序的设备(callback形式)。 +获取同步通知到未安装应用程序设备的开关是否开启(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3572,8 +3563,8 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\ | 是 | 设置是否将通知同步到未安装应用程序的设备的回调函数。
true: 是。
false: 否。 | +| userId | number | 是 | 用户ID。 | +| callback | AsyncCallback\ | 是 | 获取同步通知到未安装应用程序设备的开关是否开启的回调函数。 | **错误码:** @@ -3589,11 +3580,11 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\ -获取是否同步通知到未安装应用程序的设备(Promise形式)。 +获取同步通知到未安装应用程序设备的开关是否开启(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -3617,13 +3608,13 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | -------------- | -| userId | number | 是 | 用户Id。 | +| userId | number | 是 | 用户ID。 | **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取是否同步通知到未安装应用程序的设备的结果。
true: 是。
false: 否。 | +| 类型 | 说明 | +| ------------------ | ------------------------------------------------------------ | +| Promise\ | 以Promise形式返回获取同步通知到未安装应用程序设备的开关是否开启的结果。 | **错误码:** @@ -3638,11 +3629,11 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\ ```js let userId = 100; - -Notification.getSyncNotificationEnabledWithoutApp(userId) - .then((data) => { - console.info('getSyncNotificationEnabledWithoutApp, data:', data); - }) +Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { + console.info('getSyncNotificationEnabledWithoutApp, data:' + data); +}).catch((err) => { + console.info('getSyncNotificationEnabledWithoutApp, err:' + err); +}); .catch((err) => { console.info('getSyncNotificationEnabledWithoutApp, err:', err); }); @@ -3657,11 +3648,11 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统API**:此接口为系统接口,三方应用不支持调用。 -| 名称 | 可读 | 可写 | 类型 | 说明 | -| ----- | ---- | --- | ------------------------------------- | ------------------------ | -| type | 是 | 否 | [DoNotDisturbType](#donotdisturbtype) | 指定免打扰设置的时间类型。 | -| begin | 是 | 否 | Date | 指定免打扰设置的起点时间。 | -| end | 是 | 否 | Date | 指定免打扰设置的终点时间。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------------------------------------- | ---- | ---- | ---------------------- | +| type | [DoNotDisturbType](#donotdisturbtype) | 是 | 是 | 免打扰设置的时间类型。 | +| begin | Date | 是 | 是 | 免打扰设置的起点时间。 | +| end | Date | 是 | 是 | 免打扰设置的终点时间。 | @@ -3708,10 +3699,10 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| ------ | ---- | --- | ------ | ------ | -| bundle | 是 | 是 | string | 包名。 | -| uid | 是 | 是 | number | 用户id。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ |---- | --- | ------ | +| bundle | string | 是 | 是 | 应用的包信息。 | +| uid | number | 是 | 是 | 用户ID。 | ## SlotType @@ -3733,12 +3724,12 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 说明 | -| --------- | --- | ---- | ----------------------------------------------- | ------------------------- | -| title | 是 | 是 | string | 按钮标题。 | -| wantAgent | 是 | 是 | WantAgent | 点击按钮时触发的WantAgent。 | -| extras | 是 | 是 | { [key: string]: any } | 按钮扩展信息。 | -| userInput | 是 | 是 | [NotificationUserInput](#notificationuserinput) | 用户输入对象实例。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ----------------------------------------------- | --- | ---- | ------------------------- | +| title | string | 是 | 是 | 按钮标题。 | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 点击按钮时触发的WantAgent。 | +| extras | { [key: string]: any } | 是 | 是 | 按钮扩展信息。 | +| userInput | [NotificationUserInput](#notificationuserinput) | 是 | 是 | 用户输入对象实例。 | ## NotificationBasicContent @@ -3747,11 +3738,11 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| -------------- | ---- | ---- | ------ | ---------------------------------- | -| title | 是 | 是 | string | 通知标题。 | -| text | 是 | 是 | string | 通知内容。 | -| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ------ | ---- | ---- | ---------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | ## NotificationLongTextContent @@ -3760,14 +3751,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| -------------- | ---- | --- | ------ | -------------------------------- | -| title | 是 | 是 | string | 通知标题。 | -| text | 是 | 是 | string | 通知内容。 | -| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | -| longText | 是 | 是 | string | 通知的长文本。 | -| briefText | 是 | 是 | string | 通知概要内容,是对通知内容的总结。 | -| expandedTitle | 是 | 是 | string | 通知展开时的标题。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ------ | ---- | --- | -------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | +| longText | string | 是 | 是 | 通知的长文本。 | +| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | +| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | ## NotificationMultiLineContent @@ -3776,14 +3767,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| -------------- | --- | --- | --------------- | -------------------------------- | -| title | 是 | 是 | string | 通知标题。 | -| text | 是 | 是 | string | 通知内容。 | -| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | -| briefText | 是 | 是 | string | 通知概要内容,是对通知内容的总结。 | -| longTitle | 是 | 是 | string | 通知展开时的标题。 | -| lines | 是 | 是 | Array\ | 通知的多行文本。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | --------------- | --- | --- | -------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | +| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | +| longTitle | string | 是 | 是 | 通知展开时的标题。 | +| lines | Array\ | 是 | 是 | 通知的多行文本。 | ## NotificationPictureContent @@ -3792,14 +3783,14 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| -------------- | ---- | --- | -------------- | -------------------------------- | -| title | 是 | 是 | string | 通知标题。 | -| text | 是 | 是 | string | 通知内容。 | -| additionalText | 是 | 是 | string | 通知次要内容,是对通知内容的补充。 | -| briefText | 是 | 是 | string | 通知概要内容,是对通知内容的总结。 | -| expandedTitle | 是 | 是 | string | 通知展开时的标题。 | -| picture | 是 | 是 | image.PixelMap | 通知的图片内容。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | -------------- | ---- | --- | -------------------------------- | +| title | string | 是 | 是 | 通知标题。 | +| text | string | 是 | 是 | 通知内容。 | +| additionalText | string | 是 | 是 | 通知附加内容,是对通知内容的补充。 | +| briefText | string | 是 | 是 | 通知概要内容,是对通知内容的总结。 | +| expandedTitle | string | 是 | 是 | 通知展开时的标题。 | +| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知的图片内容。 | ## NotificationContent @@ -3808,13 +3799,13 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| ----------- | ---- | --- | ------------------------------------------------------------ | ------------------ | -| contentType | 是 | 是 | [ContentType](#contenttype) | 通知内容类型。 | -| normal | 是 | 是 | [NotificationBasicContent](#notificationbasiccontent) | 基本类型通知内容。 | -| longText | 是 | 是 | [NotificationLongTextContent](#notificationlongtextcontent) | 长文本类型通知内容。 | -| multiLine | 是 | 是 | [NotificationMultiLineContent](#notificationmultilinecontent) | 多行类型通知内容。 | -| picture | 是 | 是 | [NotificationPictureContent](#notificationpicturecontent) | 图片类型通知内容。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ | +| contentType | [ContentType](#contenttype) | 是 | 是 | 通知内容类型。 | +| normal | [NotificationBasicContent](#notificationbasiccontent) | 是 | 是 | 基本类型通知内容。 | +| longText | [NotificationLongTextContent](#notificationlongtextcontent) | 是 | 是 | 长文本类型通知内容。 | +| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | 是 | 是 | 多行类型通知内容。 | +| picture | [NotificationPictureContent](#notificationpicturecontent) | 是 | 是 | 图片类型通知内容。 | ## NotificationFlagStatus @@ -3825,7 +3816,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统接口**:此接口为系统接口,三方应用不支持调用。 -| 名称 | 值 | 描述 | +| 名称 | 值 | 说明 | | -------------- | --- | --------------------------------- | | TYPE_NONE | 0 | 默认标志。 | | TYPE_OPEN | 1 | 通知标志打开。 | @@ -3838,10 +3829,10 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| ---------------- | ---- | ---- | ---------------------- | --------------------------------- | -| soundEnabled | 是 | 否 | NotificationFlagStatus | 是否启用声音提示。 | -| vibrationEnabled | 是 | 否 | NotificationFlagStatus | 是否启用振动提醒功能。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------------- | ---------------------- | ---- | ---- | --------------------------------- | +| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用声音提示。 | +| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | 是 | 否 | 是否启用振动提醒功能。 | ## NotificationRequest @@ -3850,45 +3841,45 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 说明 | -| --------------------- | ---- | --- | --------------------------------------------- | -------------------------- | -| content | 是 | 是 | [NotificationContent](#notificationcontent) | 通知内容。 | -| id | 是 | 是 | number | 通知ID。 | -| slotType | 是 | 是 | [SlotType](#slottype) | 通道类型。 | -| isOngoing | 是 | 是 | boolean | 是否进行时通知。 | -| isUnremovable | 是 | 是 | boolean | 是否可移除。 | -| deliveryTime | 是 | 是 | number | 通知发送时间。 | -| tapDismissed | 是 | 是 | boolean | 通知是否自动清除。 | -| autoDeletedTime | 是 | 是 | number | 自动清除的时间。 | -| wantAgent | 是 | 是 | WantAgent | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | -| extraInfo | 是 | 是 | {[key: string]: any} | 扩展参数。 | -| color | 是 | 是 | number | 通知背景颜色。暂不支持。 | -| colorEnabled | 是 | 是 | boolean | 通知背景颜色是否使能。暂不支持。 | -| isAlertOnce | 是 | 是 | boolean | 设置是否仅有一次此通知警报。 | -| isStopwatch | 是 | 是 | boolean | 是否显示已用时间。 | -| isCountDown | 是 | 是 | boolean | 是否显示倒计时时间。 | -| isFloatingIcon | 是 | 是 | boolean | 是否显示状态栏图标。 | -| label | 是 | 是 | string | 通知标签。 | -| badgeIconStyle | 是 | 是 | number | 通知角标类型。 | -| showDeliveryTime | 是 | 是 | boolean | 是否显示分发时间。 | -| actionButtons | 是 | 是 | Array\<[NotificationActionButton](#notificationactionbutton)\> | 通知按钮,最多两个按钮。 | -| smallIcon | 是 | 是 | PixelMap | 通知小图标。 | -| largeIcon | 是 | 是 | PixelMap | 通知大图标。 | -| creatorBundleName | 是 | 否 | string | 创建通知的包名。 | -| creatorUid | 是 | 否 | number | 创建通知的UID。 | -| creatorPid | 是 | 否 | number | 创建通知的PID。 | -| creatorUserId | 是 | 否 | number | 创建通知的UserId。 | -| hashCode | 是 | 否 | string | 通知唯一标识。 | -| classification | 是 | 是 | string | 通知分类。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| groupName | 是 | 是 | string | 组通知名称。 | -| template | 是 | 是 | [NotificationTemplate](#notificationtemplate) | 通知模板。 | -| isRemoveAllowed | 是 | 否 | boolean | 通知是否能被移除。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| source | 是 | 否 | number | 通知源。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| distributedOption | 是 | 是 | [DistributedOptions](#distributedoptions) | 分布式通知的选项。 | -| deviceId | 是 | 否 | string | 通知源的deviceId。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| notificationFlags | 是 | 否 | [NotificationFlags](#notificationflags) | 获取NotificationFlags。 | -| removalWantAgent | 是 | 是 | WantAgent | 当移除通知时,通知将被重定向到的WantAgent实例。 | -| badgeNumber | 是 | 是 | number | 应用程序图标上显示的通知数。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- | +| content | [NotificationContent](#notificationcontent) | 是 | 是 | 通知内容。 | +| id | number | 是 | 是 | 通知ID。 | +| slotType | [SlotType](#slottype) | 是 | 是 | 通道类型。 | +| isOngoing | boolean | 是 | 是 | 是否进行时通知。 | +| isUnremovable | boolean | 是 | 是 | 是否可移除。 | +| deliveryTime | number | 是 | 是 | 通知发送时间。 | +| tapDismissed | boolean | 是 | 是 | 通知是否自动清除。 | +| autoDeletedTime | number | 是 | 是 | 自动清除的时间。 | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | +| extraInfo | {[key: string]: any} | 是 | 是 | 扩展参数。 | +| color | number | 是 | 是 | 通知背景颜色。预留能力,暂未支持。 | +| colorEnabled | boolean | 是 | 是 | 通知背景颜色是否使能。预留能力,暂未支持。 | +| isAlertOnce | boolean | 是 | 是 | 设置是否仅有一次此通知提醒。 | +| isStopwatch | boolean | 是 | 是 | 是否显示已用时间。 | +| isCountDown | boolean | 是 | 是 | 是否显示倒计时时间。 | +| isFloatingIcon | boolean | 是 | 是 | 是否显示状态栏图标。 | +| label | string | 是 | 是 | 通知标签。 | +| badgeIconStyle | number | 是 | 是 | 通知角标类型。 | +| showDeliveryTime | boolean | 是 | 是 | 是否显示分发时间。 | +| actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | 是 | 是 | 通知按钮,最多两个按钮。 | +| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知小图标。可选字段,大小不超过30KB。 | +| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | 是 | 是 | 通知大图标。可选字段,大小不超过30KB。 | +| creatorBundleName | string | 是 | 否 | 创建通知的包名。 | +| creatorUid | number | 是 | 否 | 创建通知的UID。 | +| creatorPid | number | 是 | 否 | 创建通知的PID。 | +| creatorUserId| number | 是 | 否 | 创建通知的UserId。 | +| hashCode | string | 是 | 否 | 通知唯一标识。 | +| classification | string | 是 | 是 | 通知分类。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| groupName| string | 是 | 是 | 组通知名称。 | +| template | [NotificationTemplate](#notificationtemplate) | 是 | 是 | 通知模板。 | +| isRemoveAllowed | boolean | 是 | 否 | 通知是否能被移除。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| source | number | 是 | 否 | 通知源。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| distributedOption | [DistributedOptions](#distributedoptions) | 是 | 是 | 分布式通知的选项。 | +| deviceId | string | 是 | 否 | 通知源的deviceId。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| notificationFlags | [NotificationFlags](#notificationflags) | 是 | 否 | 获取NotificationFlags。 | +| removalWantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | 是 | 是 | 当移除通知时,通知将被重定向到的WantAgent实例。 | +| badgeNumber | number | 是 | 是 | 应用程序图标上显示的通知数。 | ## DistributedOptions @@ -3897,12 +3888,12 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| ---------------------- | ---- | ---- | -------------- | ---------------------------------- | -| isDistributed | 是 | 是 | boolean | 是否为分布式通知。 | -| supportDisplayDevices | 是 | 是 | Array\ | 可以同步通知到的设备类型。 | -| supportOperateDevices | 是 | 是 | Array\ | 可以打开通知的设备。 | -| remindType | 是 | 否 | number | 通知的提醒方式。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------------------- | -------------- | ---- | ---- | ---------------------------------- | +| isDistributed | boolean | 是 | 是 | 是否为分布式通知。 | +| supportDisplayDevices | Array\ | 是 | 是 | 可以同步通知到的设备列表。 | +| supportOperateDevices | Array\ | 是 | 是 | 可以打开通知的设备列表。 | +| remindType | number | 是 | 否 | 通知的提醒方式。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | ## NotificationSlot @@ -3911,20 +3902,20 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| -------------------- | ---- | --- | --------------------- | ------------------------------------------ | -| type | 是 | 是 | [SlotType](#slottype) | 通道类型。 | -| level | 是 | 是 | number | 通知级别,不设置则根据通知渠道类型有默认值。 | -| desc | 是 | 是 | string | 通知渠道描述信息。 | -| badgeFlag | 是 | 是 | boolean | 是否显示角标。 | -| bypassDnd | 是 | 是 | boolean | 置是否在系统中绕过免打扰模式。 | -| lockscreenVisibility | 是 | 是 | number | 在锁定屏幕上显示通知的模式。 | -| vibrationEnabled | 是 | 是 | boolean | 是否可振动。 | -| sound | 是 | 是 | string | 通知提示音。 | -| lightEnabled | 是 | 是 | boolean | 是否闪灯。 | -| lightColor | 是 | 是 | number | 通知灯颜色。 | -| vibrationValues | 是 | 是 | Array\ | 通知振动样式。 | -| enabled9+ | 是 | 否 | boolean | 此通知插槽中的启停状态。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------------- | --------------------- | ---- | --- | ------------------------------------------ | +| type | [SlotType](#slottype) | 是 | 是 | 通道类型。 | +| level | number | 是 | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 | +| desc | string | 是 | 是 | 通知渠道描述信息。 | +| badgeFlag | boolean | 是 | 是 | 是否显示角标。 | +| bypassDnd | boolean | 是 | 是 | 置是否在系统中绕过免打扰模式。 | +| lockscreenVisibility | number | 是 | 是 | 在锁定屏幕上显示通知的模式。 | +| vibrationEnabled | boolean | 是 | 是 | 是否可振动。 | +| sound | string | 是 | 是 | 通知提示音。 | +| lightEnabled | boolean | 是 | 是 | 是否闪灯。 | +| lightColor | number | 是 | 是 | 通知灯颜色。 | +| vibrationValues | Array\ | 是 | 是 | 通知振动样式。 | +| enabled9+ | boolean | 是 | 否 | 此通知插槽中的启停状态。 | ## NotificationTemplate @@ -3933,7 +3924,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ---------------------- | ---- | ---- | ---------- | | name | string | 是 | 是 | 模板名称。 | | data | {[key:string]: Object} | 是 | 是 | 模板数据。 | @@ -3945,9 +3936,9 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统能力**:SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| -------- | --- | ---- | ------ | ----------------------------- | -| inputKey | 是 | 是 | string | 用户输入时用于标识此输入的key。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------ | --- | ---- | ----------------------------- | +| inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 | ## DeviceRemindType @@ -3956,7 +3947,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统API**: 此接口为系统接口,三方应用不支持调用。 -| 名称 | 值 | 描述 | +| 名称 | 值 | 说明 | | -------------------- | --- | --------------------------------- | | IDLE_DONOT_REMIND | 0 | 设备未被使用,无需提醒。 | | IDLE_REMIND | 1 | 提醒设备未被使用。 | @@ -3970,7 +3961,7 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) **系统API**: 此接口为系统接口,三方应用不支持调用。 -| 名称 | 值 | 描述 | +| 名称 | 值 | 说明 | | -------------------- | --- | -------------------- | | TYPE_NORMAL | 0 | 一般通知。 | | TYPE_CONTINUOUS | 1 | 连续通知。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md index da154974391b7ac513b31ca4d2485272c0de2205..cc3438f5a42df3976a7f472312d4c67310715b4d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -28,10 +28,10 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------- | ---- | ---------------- | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | -| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 订阅信息。 | +| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 通知订阅信息。 | | callback | AsyncCallback\ | 是 | 订阅动作回调函数。 | **错误码:** @@ -56,12 +56,12 @@ function subscribeCallback(err) { function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback -} -var info = { +}; +let info = { bundleNames: ["bundleName1","bundleName2"] -} +}; NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); ``` @@ -71,7 +71,7 @@ NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): void -订阅通知并指定订阅信息(callback形式)。 +订阅当前用户下所有应用的通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -81,7 +81,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------- | ---- | ---------------- | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | callback | AsyncCallback\ | 是 | 订阅动作回调函数。 | @@ -107,9 +107,9 @@ function subscribeCallback(err) { function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback -} +}; NotificationSubscribe.subscribe(subscriber, subscribeCallback); ``` @@ -129,10 +129,10 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------- | ---- | ------------ | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | -| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 订阅信息。 | +| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 通知订阅信息。 | **错误码:** @@ -146,17 +146,13 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ```js function onConsumeCallback(data) { - if (err) { - console.info("subscribe failed " + JSON.stringify(err)); - } else { - console.info("subscribe success"); - } + console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback }; NotificationSubscribe.subscribe(subscriber).then(() => { - console.info("subscribe sucess"); + console.info("subscribe success"); }); ``` @@ -176,7 +172,7 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\) **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------- | ---- | -------------------- | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | callback | AsyncCallback\ | 是 | 取消订阅动作回调函数。 | @@ -199,12 +195,12 @@ function unsubscribeCallback(err) { console.info("unsubscribe success"); } } -function onCancelCallback(data) { +function onDisconnectCallback(data) { console.info("Cancel callback: " + JSON.stringify(data)); } -var subscriber = { - onCancel: onCancelCallback -} +let subscriber = { + onDisconnect: onDisconnectCallback +}; NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); ``` @@ -224,7 +220,7 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------- | ---- | ------------ | | subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | @@ -239,14 +235,14 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\ **示例:** ```js -function onCancelCallback(data) { +function onDisconnectCallback(data) { console.info("Cancel callback: " + JSON.stringify(data)); } -var subscriber = { - onCancel: onCancelCallback +let subscriber = { + onDisconnect: onDisconnectCallback }; NotificationSubscribe.unsubscribe(subscriber).then(() => { - console.info("unsubscribe sucess"); + console.info("unsubscribe success"); }); ``` @@ -266,9 +262,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------------- | ----------------------------------| ---- | -------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | callback | AsyncCallback\ | 是 | 删除指定通知回调函数。 | @@ -293,14 +289,14 @@ function removeCallback(err) { console.info("remove success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationKey = { +}; +let notificationKey = { id: 0, label: "label", -} -var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +}; +let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); ``` @@ -320,9 +316,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------------- | --------------- | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | @@ -339,16 +335,16 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea **示例:** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationKey = { +}; +let notificationKey = { id: 0, label: "label", -} -var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +}; +let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; 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\): **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | -| hashCode | string | 是 | 通知唯一ID。 | +| hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](#onconsume)回调的入参[SubscribeCallbackData](#subscribecallbackdata)获取其内部[NotificationRequest](#notificationrequest)对象中的hashCode。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | callback | AsyncCallback\ | 是 | 删除指定通知回调函数。 | @@ -386,7 +382,7 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\): **示例:** ```js -var hashCode = 'hashCode' +let hashCode = 'hashCode'; function removeCallback(err) { if (err) { @@ -395,7 +391,7 @@ function removeCallback(err) { console.info("remove success"); } } -var reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; +let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; NotificationSubscribe.remove(hashCode, reason, removeCallback); ``` @@ -415,7 +411,7 @@ remove(hashCode: string, reason: RemoveReason): Promise\ **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------- | ---- | ---------- | | hashCode | string | 是 | 通知唯一ID。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | @@ -432,10 +428,10 @@ remove(hashCode: string, reason: RemoveReason): Promise\ **示例:** ```js -var hashCode = 'hashCode' -var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +let hashCode = 'hashCode'; +let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; NotificationSubscribe.remove(hashCode, reason).then(() => { - console.info("remove sucess"); + console.info("remove success"); }); ``` @@ -445,7 +441,7 @@ NotificationSubscribe.remove(hashCode, reason).then(() => { removeAll(bundle: BundleOption, callback: AsyncCallback\): void -删除指定包的所有通知(Callback形式)。 +删除指定应用的所有通知(Callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -455,10 +451,10 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ---------------------------- | -| bundle | [BundleOption](#bundleoption) | 是 | 指定包信息。 | -| callback | AsyncCallback\ | 是 | 删除指定包的所有通知回调函数。 | +| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | +| callback | AsyncCallback\ | 是 | 删除指定应用的所有通知回调函数。 | **错误码:** @@ -479,9 +475,9 @@ function removeAllCallback(err) { console.info("removeAll success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; NotificationSubscribe.removeAll(bundle, removeAllCallback); ``` @@ -501,7 +497,7 @@ removeAll(callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | -------------------- | | callback | AsyncCallback\ | 是 | 删除所有通知回调函数。 | @@ -533,7 +529,7 @@ NotificationSubscribe.removeAll(removeAllCallback); removeAll(bundle?: BundleOption): Promise\ -删除所有通知(Promise形式)。 +删除指定应用的所有通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -543,9 +539,9 @@ removeAll(bundle?: BundleOption): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| bundle | [BundleOption](#bundleoption) | 否 | 指定包信息。 | +| bundle | [BundleOption](#bundleoption) | 否 | 指定应用的包信息。 | **错误码:** @@ -559,8 +555,9 @@ removeAll(bundle?: BundleOption): Promise\ **示例:** ```js +// 不指定应用时,删除所有通知 NotificationSubscribe.removeAll().then(() => { - console.info("removeAll sucess"); + console.info("removeAll success"); }); ``` @@ -568,7 +565,7 @@ NotificationSubscribe.removeAll().then(() => { removeAll(userId: number, callback: AsyncCallback\): void -删除所有通知(callback形式)。 +删除指定用户下的所有通知(callback形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -578,10 +575,10 @@ removeAll(userId: number, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| userId | number | 是 | 接收通知用户的Id。 | -| callback | AsyncCallback\ | 是 | 删除所有通知回调函数。 | +| userId | number | 是 | 用户ID。 | +| callback | AsyncCallback\ | 是 | 删除指定用户所有通知回调函数。 | **错误码:** @@ -603,7 +600,7 @@ function removeAllCallback(err) { } } -var userId = 1 +let userId = 1; NotificationSubscribe.removeAll(userId, removeAllCallback); ``` @@ -612,7 +609,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback); removeAll(userId: number): Promise\ -删除所有通知(Promise形式)。 +删除指定用户下的所有通知(Promise形式)。 **系统能力**:SystemCapability.Notification.Notification @@ -622,9 +619,9 @@ removeAll(userId: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------ | ---- | ---------- | -| userId | number | 是 | 接收通知用户的Id。 | +| userId | number | 是 | 用户ID。 | **错误码:** @@ -646,7 +643,7 @@ function removeAllCallback(err) { } } -var userId = 1 +let userId = 1; NotificationSubscribe.removeAll(userId, removeAllCallback); ``` @@ -655,7 +652,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback); ## NotificationSubscriber -提供订阅者接收到新通知或取消通知时的回调方法。 +作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。 **系统API**:此接口为系统接口,三方应用不支持调用。 @@ -663,7 +660,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback); onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void -接收通知回调函数。 +接收到新通知的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -673,7 +670,7 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------ | ---- | -------------------------- | -| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | +| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 新接收到的通知信息。 | **示例:** @@ -692,7 +689,7 @@ function onConsumeCallback(data) { console.info('===> onConsume callback req.id:' + req.id); }; -var subscriber = { +let subscriber = { onConsume: onConsumeCallback }; @@ -703,7 +700,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void -删除通知回调函数。 +取消通知的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -713,7 +710,7 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------ | ---- | -------------------------- | -| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 回调返回接收到的通知信息。 | +| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 需要取消的通知信息。 | **示例:** @@ -732,7 +729,7 @@ function onCancelCallback(data) { console.info('===> onCancel callback req.id:' + req.id); } -var subscriber = { +let subscriber = { onCancel: onCancelCallback }; @@ -743,7 +740,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void -更新通知排序回调函数。 +更新通知排序的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -753,7 +750,7 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void | 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------ | ---- | -------------------------- | -| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 回调返回接收到的通知信息。 | +| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 最新的通知排序列表。 | **示例:** @@ -766,11 +763,11 @@ function subscribeCallback(err) { } }; -function onUpdateCallback() { - console.info('===> onUpdate in test'); +function onUpdateCallback(map) { + console.info('===> onUpdateCallback map:' + JSON.stringify(map)); } -var subscriber = { +let subscriber = { onUpdate: onUpdateCallback }; @@ -781,7 +778,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); onConnect?:() => void -注册订阅回调函数。 +订阅完成的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -802,7 +799,7 @@ function onConnectCallback() { console.info('===> onConnect in test'); } -var subscriber = { +let subscriber = { onConnect: onConnectCallback }; @@ -813,7 +810,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); onDisconnect?:() => void -取消订阅回调函数。 +取消订阅的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -829,16 +826,30 @@ function subscribeCallback(err) { 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() { console.info('===> onDisconnect in test'); } -var subscriber = { +let subscriber = { + onConnect: onConnectCallback, onDisconnect: onDisconnectCallback }; +// 订阅通知后会收到onConnect回调 NotificationSubscribe.subscribe(subscriber, subscribeCallback); +// 取消订阅后会收到onDisconnect回调 +NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); ``` ### onDestroy @@ -866,7 +877,7 @@ function onDestroyCallback() { console.info('===> onDestroy in test'); } -var subscriber = { +let subscriber = { onDestroy: onDestroyCallback }; @@ -877,7 +888,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void -免打扰时间选项变更回调函数。 +免打扰时间选项发生变更时的回调函数。 **系统能力**:SystemCapability.Notification.Notification @@ -900,11 +911,11 @@ function subscribeCallback(err) { } }; -function onDoNotDisturbDateChangeCallback() { - console.info('===> onDoNotDisturbDateChange in test'); +function onDoNotDisturbDateChangeCallback(mode) { + console.info('===> onDoNotDisturbDateChange:' + mode); } -var subscriber = { +let subscriber = { onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback }; @@ -945,7 +956,7 @@ function onEnabledNotificationChangedCallback(callbackData) { console.info("enable: ", callbackData.enable); }; -var subscriber = { +let subscriber = { onEnabledNotificationChanged: onEnabledNotificationChangedCallback }; @@ -956,19 +967,19 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 说明 | -| ------ | ---- | ---- | ------ | -------- | -| bundle | 是 | 是 | string | 包名。 | -| uid | 是 | 是 | number | 用户id。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ |---- | --- | ------ | +| bundle | string | 是 | 是 | 应用的包信息。 | +| uid | number | 是 | 是 | 用户ID。 | ## NotificationKey **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 说明 | -| ----- | ---- | ---- | ------ | ---------- | -| id | 是 | 是 | number | 通知ID。 | -| label | 是 | 是 | string | 通知标签。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | --- | -------- | +| id | number | 是 | 是 | 通知ID。 | +| label | string | 是 | 是 | 通知标签。 | ## SubscribeCallbackData @@ -976,13 +987,13 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统API**:此接口为系统接口,三方应用不支持调用。 -| 名称 | 可读 | 可写 | 类型 | 说明 | -| --------------- | ---- | --- | ------------------------------------------------- | -------- | -| request | 是 | 否 | [NotificationRequest](js-apis-notificationManager.md#notificationrequest) | 通知内容。 | -| sortingMap | 是 | 否 | [NotificationSortingMap](#notificationsortingmap) | 排序信息。 | -| reason | 是 | 否 | number | 删除原因。 | -| sound | 是 | 否 | string | 通知声音。 | -| vibrationValues | 是 | 否 | Array\ | 通知震动。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------- | ------------------------------------------------- | -------- | -------- | -------- | +| request | [NotificationRequest](js-apis-notificationManager.md#notificationrequest) | 是 | 否 | 通知内容。 | +| sortingMap | [NotificationSortingMap](#notificationsortingmap) | 是 | 否 | 排序信息。 | +| reason | number | 是 | 否 | 删除原因。 | +| sound | string | 是 | 否 | 通知声音。 | +| vibrationValues | Array\ | 是 | 否 | 通知震动。 | ## EnabledNotificationCallbackData @@ -991,11 +1002,11 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统API**:此接口为系统接口,三方应用不支持调用。 -| 名称 | 可读 | 可写 | 类型 | 描述 | -| ------ | ---- | --- | ------- | ---------------- | -| bundle | 是 | 否 | string | 应用的包名。 | -| uid | 是 | 否 | number | 应用的uid。 | -| enable | 是 | 否 | boolean | 应用通知使能状态。 | +| 名称 | 类型 | 可读 | 可写 | 描述 | +| ------ | ------- | ---------------- | ---------------- | ---------------- | +| bundle | string | 是 | 否 | 应用的包名。 | +| uid | number | 是 | 否 | 应用的uid。 | +| enable | boolean | 是 | 否 | 应用通知使能状态。 | ## NotificationSorting @@ -1006,11 +1017,11 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统API**: 此接口为系统接口,三方应用不支持调用。 -| 名称 | 可读 | 可写 | 类型 | 说明 | -| -------- | ---- | --- | ------------------------------------- | ------------ | -| slot | 是 | 否 | [NotificationSlot](js-apis-notificationManager.md#notificationslot) | 通知通道内容。 | -| hashCode | 是 | 否 | string | 通知唯一标识。 | -| ranking | 是 | 否 | number | 通知排序序号。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------------------------------------- | ---- | --- | ------------ | +| slot | [NotificationSlot](js-apis-notificationManager.md#notificationslot) | 是 | 否 | 通知通道内容。 | +| hashCode | string | 是 | 否 | 通知唯一标识。 | +| ranking | number | 是 | 否 | 通知排序序号。 | ## NotificationSortingMap @@ -1021,10 +1032,10 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统API**:此接口为系统接口,三方应用不支持调用。 -| 名称 | 可读 | 可写 | 类型 | 说明 | -| -------------- | ---- | --- | ------------------------------------------------------------ | ---------------- | -| sortings | 是 | 否 | {[key: string]: [NotificationSorting](#notificationsorting)} | 通知排序信息数组。 | -| sortedHashCode | 是 | 否 | Array\ | 通知唯一标识数组。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- | +| sortings | {[key: string]: [NotificationSorting](#notificationsorting)} | 是 | 否 | 通知排序信息数组。 | +| sortedHashCode | Array\ | 是 | 否 | 通知唯一标识数组。 | ## NotificationSubscribeInfo @@ -1035,10 +1046,10 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统API**: 此接口为系统接口,三方应用不支持调用。 -| 名称 | 可读 | 可写 | 类型 | 描述 | -| ----------- | --- | ---- | --------------- | ------------------------------- | -| bundleNames | 是 | 是 | Array\ | 指定订阅哪些包名的APP发来的通知。 | -| userId | 是 | 是 | number | 指定订阅哪个用户下发来的通知。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | --------------- | --- | ---- | ------------------------------- | +| bundleNames | Array\ | 是 | 是 | 指定订阅哪些包名的APP发来的通知。 | +| userId | number | 是 | 是 | 指定订阅哪个用户下发来的通知。 | ## NotificationUserInput @@ -1047,9 +1058,9 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统能力**:SystemCapability.Notification.Notification -| 名称 | 可读 | 可写 | 类型 | 描述 | -| -------- | --- | ---- | ------ | ----------------------------- | -| inputKey | 是 | 是 | string | 用户输入时用于标识此输入的key。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------ | --- | ---- | ----------------------------- | +| inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 | ## RemoveReason @@ -1057,7 +1068,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); **系统API**: 此接口为系统接口,三方应用不支持调用。 -| 名称 | 值 | 描述 | +| 名称 | 值 | 说明 | | -------------------- | --- | -------------------- | | CLICK_REASON_REMOVE | 1 | 点击通知后删除通知。 | | CANCEL_REASON_REMOVE | 2 | 用户删除通知。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-notification.md b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md index db00c4997350484ffb9fa17e72259205272b24e8..de75ed99a66540804acb0900340c3c0738ee3ec9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md @@ -59,9 +59,9 @@ export default { clickAction: { bundleName: 'com.example.testapp', abilityName: 'notificationDemo', - uri: '/path/to/notification', - }, + uri: '/path/to/notification' + } }); - }, + } } ``` \ No newline at end of file