From ada895da178a936c33c5475455736fc70f91da47 Mon Sep 17 00:00:00 2001 From: heguokai <275503077@qq.com> Date: Thu, 4 Sep 2025 19:59:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcancel=E5=92=8Cremove?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3label=E4=B8=8D=E4=BC=A0=E6=97=B6=E8=BF=94?= =?UTF-8?q?=E5=9B=9E401=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: heguokai <275503077@qq.com> --- frameworks/ets/ani/src/sts_subscribe.cpp | 5 ++++- frameworks/ets/ets/@ohos.notificationManager.ets | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/ets/ani/src/sts_subscribe.cpp b/frameworks/ets/ani/src/sts_subscribe.cpp index 8b58a23aa..959c0a2ad 100644 --- a/frameworks/ets/ani/src/sts_subscribe.cpp +++ b/frameworks/ets/ani/src/sts_subscribe.cpp @@ -787,10 +787,13 @@ bool UnWarpNotificationKey(ani_env *env, const ani_object obj, NotificationKey & } OutObj.id = static_cast(idInt); std::string label; - if (GetPropertyString(env, obj, "label", isUndefined, label) != ANI_OK || isUndefined == ANI_TRUE) { + if (GetPropertyString(env, obj, "label", isUndefined, label) != ANI_OK) { ANS_LOGD("UnWarpNotificationKey GetPropertyString label fail"); return false; } + if (isUndefined == ANI_TRUE) { + return true; + } OutObj.label = GetResizeStr(label, STR_MAX_SIZE); ANS_LOGD("UnWarpNotificationKey id: %{public}d, label: %{public}s", OutObj.id, OutObj.label.c_str()); return true; diff --git a/frameworks/ets/ets/@ohos.notificationManager.ets b/frameworks/ets/ets/@ohos.notificationManager.ets index 41e141584..342ec75b6 100644 --- a/frameworks/ets/ets/@ohos.notificationManager.ets +++ b/frameworks/ets/ets/@ohos.notificationManager.ets @@ -1587,9 +1587,6 @@ export default namespace notificationManager { } export function cancel(id: int, label?: string): Promise { - if (label == null || label?.length === 0) { - throw errorParamInvalid; - } let pPromise = new Promise((resolve: ResolveCallback, reject: RejectCallback): void => { let p = taskpool.execute((): void => { return nativeCancelWithIdOptionalLabel(id, label); }); p.then((data: NullishType): void => { -- Gitee