From 851bc5b78b7788ea1849b4fd92b244a4c9e08a68 Mon Sep 17 00:00:00 2001 From: XKK Date: Thu, 24 Aug 2023 15:53:35 +0800 Subject: [PATCH] =?UTF-8?q?docs=E6=96=87=E6=A1=A3=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: XKK --- ...-inner-notification-notificationRequest.md | 74 +++++++++---------- ...-inner-notification-notificationSorting.md | 10 +-- .../apis/js-apis-notificationManager.md | 69 +++++++++++++++++ .../apis/js-apis-notificationSubscribe.md | 12 +-- 4 files changed, 117 insertions(+), 48 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md index 51816f591c..6cf91a1a0e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md @@ -10,45 +10,45 @@ **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification -| 名称 | 类型 | 必填 | 说明 | -| --------------------- | --------------------------------------------- | --- |-----------------------------------------------------------------------| -| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | 是 | 通知内容。 | -| id | number | 否 | 通知ID。 | -| slotType | [SlotType](js-apis-notificationManager.md#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](js-apis-inner-notification-notificationActionButton.md)\> | 否 | 通知按钮,最多三个按钮。 | -| 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。 | -| creatorUserId8+ | number | 否 | 创建通知的UserId。 | -| hashCode | string | 否 | 通知唯一标识。 | -| classification | string | 否 | 通知分类。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| groupName8+ | string | 否 | 组通知名称。 | -| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | 否 | 通知模板。 | -| isRemoveAllowed10+ | boolean | 否 | 通知是否能被移除(点击通知下方删除按钮无法删除,左滑不出现删除按钮)。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | -| source8+ | number | 否 | 通知源。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| 名称 | 类型 | 必填 | 说明 | +|-------------------------------| --------------------------------------------- | --- |-----------------------------------------------------------------------| +| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | 是 | 通知内容。 | +| id | number | 否 | 通知ID。 | +| slotType | [SlotType](js-apis-notificationManager.md#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](js-apis-inner-notification-notificationActionButton.md)\> | 否 | 通知按钮,最多三个按钮。 | +| 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。 | +| creatorUserId8+ | number | 否 | 创建通知的UserId。 | +| hashCode | string | 否 | 通知唯一标识。 | +| classification | string | 否 | 通知分类。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| groupName8+ | string | 否 | 组通知名称。 | +| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | 否 | 通知模板。 | +| isRemoveAllowed8+ | boolean | 否 | 通知是否能被移除(点击通知下方删除按钮无法删除,左滑不出现删除按钮)。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| source8+ | number | 否 | 通知源。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | | distributedOption8+ | [DistributedOptions](#distributedoptions) | 否 | 分布式通知的选项。 | -| deviceId8+ | string | 否 | 通知源的deviceId。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | +| deviceId8+ | string | 否 | 通知源的deviceId。
**系统API**: 此接口为系统接口,三方应用不支持调用。 | | notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | 否 | 获取NotificationFlags。 | -| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | 否 | 当移除通知时,通知将被重定向到的WantAgent实例。 | -| badgeNumber9+ | number | 否 | 应用程序图标上显示的通知数。 | +| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | 否 | 当移除通知时,通知将被重定向到的WantAgent实例。 | +| badgeNumber9+ | number | 否 | 应用程序图标上显示的通知数。 | ## DistributedOptions diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md index 70dd4d279f..d1f9442736 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md @@ -12,8 +12,8 @@ **系统接口**: 以下为系统接口,三方应用不支持调用。 -| 名称 | 类型 | 必填 | 说明 | -| -------------------- | --------------------- | --- | ------------------------------------------ | -| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 通道类型。 | -| level | number | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 | -| desc | string | 是 | 通知渠道描述信息。 | +| 名称 | 类型 | 必填 | 说明 | +|---------| --------------------- | --- |------------------------| +| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 通道类型。 | +| ranking | number | 是 | 通知级别,不设置则根据通知渠道类型有默认值。 | +| hashCode | string | 是 | 通知唯一标识。 | 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 ca406ed0ae..51de9fbd33 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md @@ -2808,7 +2808,76 @@ notificationManager.requestEnableNotification().then(() => { }); ``` +## notificationManager.requestEnableNotification10+ +requestEnableNotification(context: UIAbilityContext, callback: AsyncCallback\): void + +应用请求通知使能模态弹窗(Callback形式)。 + +**系统能力**:SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- |--------------------| +| context | UIAbilityContext | 是 | 通知弹窗绑定Ability的上下文。 | +| callback | AsyncCallback\ | 是 | 应用请求通知使能的回调函数。 | + +**错误码:** + +错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。 + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 1600001 | Internal error. | +| 1600002 | Marshalling or unmarshalling error. | +| 1600003 | Failed to connect service. | + +**示例:** + +```javascript +function requestEnableNotificationCallback(err) { + if (err) { + console.error(`requestEnableNotification failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("requestEnableNotification success"); + } +}; + +notificationManager.requestEnableNotification(globalThis.uicontext, requestEnableNotificationCallback); +``` + +## notificationManager.requestEnableNotification10+ + +requestEnableNotification(context: UIAbilityContext): Promise\ + +应用请求通知使能模态弹窗(Promise形式)。 + +**系统能力**:SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- |--------------------| +| context | UIAbilityContext | 是 | 通知弹窗绑定Ability的上下文。 | + +**错误码:** + +错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)。 + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 1600001 | Internal error. | +| 1600002 | Marshalling or unmarshalling error. | +| 1600003 | Failed to connect service. | + +**示例:** + +```javascript +notificationManager.requestEnableNotification(globalThis.uicontext).then(() => { + console.info("requestEnableNotification success"); +}); +``` ## notificationManager.setDistributedEnable 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 3969df3f29..f7dafa9c21 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -443,9 +443,9 @@ notificationSubscribe.remove(hashCode, reason).then(() => { console.info("remove success"); }); ``` -## NotificationSubscribe.remove +## NotificationSubscribe.remove10+ -remove(hashCodes: Array\, reason: RemoveReason, callback: AsyncCallback\): void +remove(hashCodes: Array\, reason: RemoveReason, callback: AsyncCallback\): void 批量删除指定通知(Callback形式)。 @@ -459,7 +459,7 @@ remove(hashCodes: Array\, reason: RemoveReason, callback: AsyncCallback | 参数名 | 类型 | 必填 | 说明 | |-----------|-------------------------------| ---- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| hashCodes | Array\ | 是 | 通知唯一ID数组集合。可以通过[onConsume](js-apis-inner-notification-notificationSubscriber.md#onConsume)回调的入参[SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)获取其内部[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)对象中的hashCode。 | +| hashCodes | Array\ | 是 | 通知唯一ID数组集合。可以通过[onConsume](js-apis-inner-notification-notificationSubscriber.md#onConsume)回调的入参[SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)获取其内部[NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest)对象中的hashCode。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | callback | AsyncCallback\ | 是 | 删除指定通知回调函数。 | @@ -489,9 +489,9 @@ let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; notificationSubscribe.remove(hashCodes, reason, removeCallback); ``` -## NotificationSubscribe.remove +## NotificationSubscribe.remove10+ -remove(hashCodes: Array\, reason: RemoveReason): Promise\ +remove(hashCodes: Array\, reason: RemoveReason): Promise\ 批量删除指定通知(Promise形式)。 @@ -505,7 +505,7 @@ remove(hashCodes: Array\, reason: RemoveReason): Promise\ | 参数名 | 类型 | 必填 | 说明 | |-----------|-------------------------------| ---- |-------------| -| hashCodes | Array\ | 是 | 通知唯一ID数组集合。 | +| hashCodes | Array\ | 是 | 通知唯一ID数组集合。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | **错误码:** -- GitLab