diff --git a/build-profile.json5 b/build-profile.json5 index bafa06da309abfe85de762b332db2f50a34f5088..d14eb6563bf067f61bad8f4b4185f25ebead41e9 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 e72118cab952a946b20ba4d483345e907f805e15..86aa9f55f94e8264e8f66d137da0ca6c79a3fc83 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 74671a12363575fe8a8a6536b1af3ac5ac2bad1e..0cfa3855af5e9b3bec0f3c19baa498e2716a2ea8 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 457207e3b369fbcdc2c0c13a110a8313fd1d6ebf..58c39287718b80bc001d691fe1181cd89ffe8393 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",