diff --git a/interfaces/kits/napi/ans/include/publish.h b/interfaces/kits/napi/ans/include/publish.h index 6d8405209b1d24bdfadfd4ef6ffc2c8a5d776204..684921abd8d70ee4042f3ec76d382305eee5ae75 100644 --- a/interfaces/kits/napi/ans/include/publish.h +++ b/interfaces/kits/napi/ans/include/publish.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,6 +21,7 @@ namespace OHOS { namespace NotificationNapi { using namespace OHOS::Notification; napi_value Publish(napi_env env, napi_callback_info info); +napi_value ShowNotification(napi_env env, napi_callback_info info); } // namespace NotificationNapi } // namespace OHOS #endif // BASE_NOTIFICATION_ANS_STANDARD_KITS_NAPI_INCLUDE_PUBLISH_H \ No newline at end of file diff --git a/interfaces/kits/napi/ans/src/init.cpp b/interfaces/kits/napi/ans/src/init.cpp index 2a26b7ce35f7443ec3d14cf9f9d38427b8ecb1c4..6361a6a97a00b4d195b6a10ffe94180ee2105fb2 100644 --- a/interfaces/kits/napi/ans/src/init.cpp +++ b/interfaces/kits/napi/ans/src/init.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -76,6 +76,7 @@ napi_value NotificationInit(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("enableDistributedSelf", EnableDistributedSelf), DECLARE_NAPI_FUNCTION("isDistributedEnableByBundle", IsDistributedEnableByBundle), DECLARE_NAPI_FUNCTION("getDeviceRemindType", GetDeviceRemindType), + DECLARE_NAPI_FUNCTION("show", ShowNotification), }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); diff --git a/interfaces/kits/napi/ans/src/publish.cpp b/interfaces/kits/napi/ans/src/publish.cpp index d099d521182fda0803d55364cf299806049307c1..2c4b9609586b84e596b647a939d3841b8011797e 100644 --- a/interfaces/kits/napi/ans/src/publish.cpp +++ b/interfaces/kits/napi/ans/src/publish.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -137,15 +137,12 @@ napi_value Publish(napi_env env, napi_callback_info info) [](napi_env env, napi_status status, void *data) { ANS_LOGI("Publish napi_create_async_work complete start"); AsyncCallbackInfoPublish *asynccallbackinfo = (AsyncCallbackInfoPublish *)data; - - Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); - - if (asynccallbackinfo->info.callback != nullptr) { - napi_delete_reference(env, asynccallbackinfo->info.callback); - } - - napi_delete_async_work(env, asynccallbackinfo->asyncWork); if (asynccallbackinfo) { + Common::ReturnCallbackPromise(env, asynccallbackinfo->info, Common::NapiGetNull(env)); + if (asynccallbackinfo->info.callback != nullptr) { + napi_delete_reference(env, asynccallbackinfo->info.callback); + } + napi_delete_async_work(env, asynccallbackinfo->asyncWork); delete asynccallbackinfo; asynccallbackinfo = nullptr; } @@ -162,5 +159,11 @@ napi_value Publish(napi_env env, napi_callback_info info) return promise; } } + +napi_value ShowNotification(napi_env env, napi_callback_info info) +{ + ANS_LOGI("ShowNotification enter"); + return Common::NapiGetNull(env); +} } // namespace NotificationNapi } // namespace OHOS \ No newline at end of file