From 834c031e13af4f27d56043f434dd50e1908efe93 Mon Sep 17 00:00:00 2001 From: lloyd <353627866@qq.com> Date: Sun, 10 Aug 2025 15:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AE=9E=E7=8E=B0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=80=9A=E7=9F=A5=E8=A7=92=E6=A0=87=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=91=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 1 + .../main/ets/feature/NotificationOperations.ets | 2 +- .../ets/notification/NotificationRequestUtil.ets | 14 ++++++++------ oh-package.json5 | 1 - 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build-profile.json5 b/build-profile.json5 index bafa06d..d14eb65 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -6,6 +6,7 @@ "name": "default", "signingConfig": "default", "compatibleSdkVersion": "5.0.0(12)", + "targetSdkVersion": "5.0.0(12)", "runtimeOS": "HarmonyOS" } ] diff --git a/entry/src/main/ets/feature/NotificationOperations.ets b/entry/src/main/ets/feature/NotificationOperations.ets index e72118c..86aa9f5 100644 --- a/entry/src/main/ets/feature/NotificationOperations.ets +++ b/entry/src/main/ets/feature/NotificationOperations.ets @@ -71,7 +71,7 @@ export default class NotificationOperations { let notificationContent = notificationContentUtil.initBasicNotificationContent(this.basicContent); notificationUtil.publishNotification(notificationRequestUtil.initBasicNotificationRequest(notificationContent as notificationManager.NotificationContent) as notificationManager.NotificationRequest); } catch (error) { - logger.info(TAG, `publishBasicNotification error, error = ${JSON.stringify(error)}`); + logger.error(TAG, `publishBasicNotification error, error = ${JSON.stringify(error)}`); } }; publishLongTextNotification = () => { diff --git a/notification/src/main/ets/notification/NotificationRequestUtil.ets b/notification/src/main/ets/notification/NotificationRequestUtil.ets index 74671a1..0cfa385 100644 --- a/notification/src/main/ets/notification/NotificationRequestUtil.ets +++ b/notification/src/main/ets/notification/NotificationRequestUtil.ets @@ -18,7 +18,7 @@ import { WantAgent } from '@ohos.wantAgent' interface NotificationRequestUtilResultType { slotType: notificationManager.SlotType, - id: number, // 通知id,默认为1 + id: number, content: notificationManager.NotificationContent } @@ -43,14 +43,15 @@ class NotificationRequestUtil { * @param notificationActionButtons * @return return the created NotificationRequest */ - initButtonNotificationRequest(notificationContent: notificationManager.NotificationContent, notificationActionButtons: notificationManager.NotificationActionButton[]): notificationManager.NotificationRequest { + initButtonNotificationRequest(notificationContent: notificationManager.NotificationContent, + notificationActionButtons: notificationManager.NotificationActionButton[]): notificationManager.NotificationRequest { let actionButtons = notificationActionButtons - if (notificationActionButtons.length > 2) { // 当前通知接口最大允许有两个按钮,超过两个按钮不展示 + if (notificationActionButtons.length > 2) { actionButtons = notificationActionButtons.splice(0, 2) } return { notificationSlotType: notificationManager.SlotType.CONTENT_INFORMATION, - id: 1, // 通知id,默认为1 + id: 1, content: notificationContent, actionButtons: actionButtons }; @@ -63,10 +64,11 @@ class NotificationRequestUtil { * @return return the created NotificationRequest */ - initWantAgentNotificationRequest(notificationContent: notificationManager.NotificationContent, notificationWantAgent: WantAgent): notificationManager.NotificationRequest { + initWantAgentNotificationRequest(notificationContent: notificationManager.NotificationContent, + notificationWantAgent: WantAgent): notificationManager.NotificationRequest { return { notificationSlotType: notificationManager.SlotType.CONTENT_INFORMATION, - id: 1, // 通知id,默认为1 + id: 1, content: notificationContent, wantAgent: notificationWantAgent }; diff --git a/oh-package.json5 b/oh-package.json5 index 457207e..58c3928 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -2,7 +2,6 @@ "modelVersion": "5.0.0", "license": "", "devDependencies": { - "@ohos/hypium": "1.0.15" }, "author": "", "name": "customnotificationbadge", -- Gitee