diff --git a/frameworks/ets/ani/src/sts_subscribe.cpp b/frameworks/ets/ani/src/sts_subscribe.cpp index 8b58a23aaccc01bfaee37c5f775236d227209385..959c0a2ad74029a3a417e99c073162d35f526733 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 41e141584e976d304aaee93ad2aaee2a235989a7..342ec75b6f6bbbe86c00fc2cc75e00473fa05589 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 => {