diff --git a/frameworks/ets/ani/src/sts_subscribe.cpp b/frameworks/ets/ani/src/sts_subscribe.cpp index a3b06074c0070d1057634b4d46a594c702be01e1..ef8e5b2d1917f20d6051c15ac4725da14e0c68c0 100644 --- a/frameworks/ets/ani/src/sts_subscribe.cpp +++ b/frameworks/ets/ani/src/sts_subscribe.cpp @@ -791,10 +791,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 4113d28a6855834179fbe3b6c6df7cdad0c94fc7..29c001dc874ddf4b88d38cd88aba6d1298fb1ea8 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 => { nativeCancelWithIdOptionalLabel(id, label); }); p.then((data: NullishType): void => {