From 51e238d11b5f31459e5d372e2e3499498b98faac Mon Sep 17 00:00:00 2001 From: baozeyu Date: Sat, 29 Mar 2025 15:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E5=AE=9E=E4=BE=8B=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: baozeyu --- frameworks/ans/BUILD.gn | 1 - frameworks/ans/src/notification_helper.cpp | 42 ++++++++++++------- frameworks/core/BUILD.gn | 1 - frameworks/core/include/ans_notification.h | 19 +++++---- frameworks/core/src/ans_notification.cpp | 40 +++++++----------- frameworks/js/napi/include/common.h | 1 + frameworks/js/napi/src/common.cpp | 12 ++++++ .../js/napi/src/manager/napi_cancel.cpp | 14 ++++--- .../napi/src/manager/napi_display_badge.cpp | 3 +- .../js/napi/src/manager/napi_get_active.cpp | 4 +- .../js/napi/src/manager/napi_publish.cpp | 10 ++--- interfaces/inner_api/notification_helper.h | 20 +++++---- 12 files changed, 95 insertions(+), 72 deletions(-) diff --git a/frameworks/ans/BUILD.gn b/frameworks/ans/BUILD.gn index 3883d2f55..69636286c 100644 --- a/frameworks/ans/BUILD.gn +++ b/frameworks/ans/BUILD.gn @@ -123,7 +123,6 @@ ohos_shared_library("ans_innerkits") { external_deps = [ "ability_base:want", "ability_base:zuri", - "ability_runtime:app_context", "ability_runtime:appkit_native", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", diff --git a/frameworks/ans/src/notification_helper.cpp b/frameworks/ans/src/notification_helper.cpp index 3107e6860..8138c41a7 100644 --- a/frameworks/ans/src/notification_helper.cpp +++ b/frameworks/ans/src/notification_helper.cpp @@ -73,14 +73,18 @@ ErrCode NotificationHelper::SetNotificationSlotFlagsAsBundle(const NotificationB return DelayedSingleton::GetInstance()->SetNotificationSlotFlagsAsBundle(bundleOption, slotFlags); } -ErrCode NotificationHelper::PublishNotification(const NotificationRequest &request) +ErrCode NotificationHelper::PublishNotification(const NotificationRequest &request, + std::string instanceKey) { - return DelayedSingleton::GetInstance()->PublishNotification(request); + return DelayedSingleton::GetInstance()->PublishNotification( + request, instanceKey); } -ErrCode NotificationHelper::PublishNotification(const std::string &label, const NotificationRequest &request) +ErrCode NotificationHelper::PublishNotification(const std::string &label, + const NotificationRequest &request, std::string instanceKey) { - return DelayedSingleton::GetInstance()->PublishNotification(label, request); + return DelayedSingleton::GetInstance()->PublishNotification( + label, request, instanceKey); } ErrCode NotificationHelper::PublishNotificationForIndirectProxy(const NotificationRequest &request) @@ -88,19 +92,22 @@ ErrCode NotificationHelper::PublishNotificationForIndirectProxy(const Notificati return DelayedSingleton::GetInstance()->PublishNotificationForIndirectProxy(request); } -ErrCode NotificationHelper::CancelNotification(int32_t notificationId) +ErrCode NotificationHelper::CancelNotification(int32_t notificationId, std::string instanceKey) { - return DelayedSingleton::GetInstance()->CancelNotification(notificationId); + return DelayedSingleton::GetInstance()->CancelNotification( + notificationId, instanceKey); } -ErrCode NotificationHelper::CancelNotification(const std::string &label, int32_t notificationId) +ErrCode NotificationHelper::CancelNotification(const std::string &label, int32_t notificationId, + std::string instanceKey) { - return DelayedSingleton::GetInstance()->CancelNotification(label, notificationId); + return DelayedSingleton::GetInstance()->CancelNotification( + label, notificationId, instanceKey); } -ErrCode NotificationHelper::CancelAllNotifications() +ErrCode NotificationHelper::CancelAllNotifications(std::string instanceKey) { - return DelayedSingleton::GetInstance()->CancelAllNotifications(); + return DelayedSingleton::GetInstance()->CancelAllNotifications(instanceKey); } ErrCode NotificationHelper::CancelAsBundle( @@ -122,9 +129,11 @@ ErrCode NotificationHelper::GetActiveNotificationNums(uint64_t &num) return DelayedSingleton::GetInstance()->GetActiveNotificationNums(num); } -ErrCode NotificationHelper::GetActiveNotifications(std::vector> &request) +ErrCode NotificationHelper::GetActiveNotifications( + std::vector> &request, std::string instanceKey) { - return DelayedSingleton::GetInstance()->GetActiveNotifications(request); + return DelayedSingleton::GetInstance()->GetActiveNotifications( + request, instanceKey); } ErrCode NotificationHelper::CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish) @@ -373,9 +382,10 @@ ErrCode NotificationHelper::GetShowBadgeEnabled(bool &enabled) return DelayedSingleton::GetInstance()->GetShowBadgeEnabled(enabled); } -ErrCode NotificationHelper::CancelGroup(const std::string &groupName) +ErrCode NotificationHelper::CancelGroup(const std::string &groupName, std::string instanceKey) { - return DelayedSingleton::GetInstance()->CancelGroup(groupName); + return DelayedSingleton::GetInstance()->CancelGroup( + groupName, instanceKey); } ErrCode NotificationHelper::RemoveGroupByBundle( @@ -517,9 +527,9 @@ ErrCode NotificationHelper::GetSyncNotificationEnabledWithoutApp(const int32_t u userId, enabled); } -ErrCode NotificationHelper::SetBadgeNumber(int32_t badgeNumber) +ErrCode NotificationHelper::SetBadgeNumber(int32_t badgeNumber, std::string instanceKey) { - return DelayedSingleton::GetInstance()->SetBadgeNumber(badgeNumber); + return DelayedSingleton::GetInstance()->SetBadgeNumber(badgeNumber, instanceKey); } ErrCode NotificationHelper::SetBadgeNumberByBundle(const NotificationBundleOption &bundleOption, int32_t badgeNumber) diff --git a/frameworks/core/BUILD.gn b/frameworks/core/BUILD.gn index c90cde0df..74a703fdc 100644 --- a/frameworks/core/BUILD.gn +++ b/frameworks/core/BUILD.gn @@ -72,7 +72,6 @@ ohos_shared_library("ans_core") { external_deps = [ "ability_base:want", "ability_base:zuri", - "ability_runtime:app_context", "ability_runtime:wantagent_innerkits", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", diff --git a/frameworks/core/include/ans_notification.h b/frameworks/core/include/ans_notification.h index caf337ac8..1347f9e4d 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -134,7 +134,7 @@ public: * This parameter must be specified. * @return Returns publish notification result. */ - ErrCode PublishNotification(const NotificationRequest &request); + ErrCode PublishNotification(const NotificationRequest &request, std::string instanceKey = ""); /** * @brief Publishes a notification with a specified label. @@ -146,7 +146,8 @@ public: * This parameter must be specified. * @return Returns publish notification result. */ - ErrCode PublishNotification(const std::string &label, const NotificationRequest &request); + ErrCode PublishNotification(const std::string &label, const NotificationRequest &request, + std::string instanceKey = ""); /** * @brief Publishes a notification. @@ -167,7 +168,7 @@ public: * Otherwise, this method does not take effect. * @return Returns cancel notification result. */ - ErrCode CancelNotification(int32_t notificationId); + ErrCode CancelNotification(int32_t notificationId, std::string instanceKey = ""); /** * @brief Cancels a published notification matching the specified label and notificationId. @@ -176,7 +177,8 @@ public: * @param notificationId Indicates the ID of the notification to cancel. * @return Returns cancel notification result. */ - ErrCode CancelNotification(const std::string &label, int32_t notificationId); + ErrCode CancelNotification(const std::string &label, int32_t notificationId, + std::string instanceKey = ""); /** * @brief Cancels all the published notifications. @@ -184,7 +186,7 @@ public: * * @return Returns cancel all notifications result. */ - ErrCode CancelAllNotifications(); + ErrCode CancelAllNotifications(std::string instanceKey = ""); /** * @brief Cancels a published agent notification. @@ -223,7 +225,8 @@ public: * @param request Indicates active NotificationRequest objects of the current application. * @return Returns get active notifications result. */ - ErrCode GetActiveNotifications(std::vector> &request); + ErrCode GetActiveNotifications(std::vector> &request, + std::string instanceKey = ""); /** * @brief Checks whether your application has permission to publish notifications by calling @@ -731,7 +734,7 @@ public: * @param groupName the specified group name. * @return Returns cancel group result. */ - ErrCode CancelGroup(const std::string &groupName); + ErrCode CancelGroup(const std::string &groupName, std::string instanceKey = ""); /** * @brief Removes the notification of the specified group of the specified application. @@ -1007,7 +1010,7 @@ public: * @param badgeNumber The badge number. * @return Returns set badge number result. */ - ErrCode SetBadgeNumber(int32_t badgeNumber); + ErrCode SetBadgeNumber(int32_t badgeNumber, std::string instanceKey = ""); /** * @brief Set badge number by bundle. diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index b17ef316d..1c356b790 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -179,13 +179,14 @@ ErrCode AnsNotification::SetNotificationSlotFlagsAsBundle(const NotificationBund return proxy->SetSlotFlagsAsBundle(bo, slotFlags); } -ErrCode AnsNotification::PublishNotification(const NotificationRequest &request) +ErrCode AnsNotification::PublishNotification(const NotificationRequest &request, std::string instanceKey) { ANS_LOGD("enter"); - return PublishNotification(std::string(), request); + return PublishNotification(std::string(), request, instanceKey); } -ErrCode AnsNotification::PublishNotification(const std::string &label, const NotificationRequest &request) +ErrCode AnsNotification::PublishNotification(const std::string &label, const NotificationRequest &request, + std::string instanceKey) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); ANS_LOGI("PublishNotification,notificationId:%{public}u", request.GetNotificationId()); @@ -230,7 +231,6 @@ ErrCode AnsNotification::PublishNotification(const std::string &label, const Not if (IsNonDistributedNotificationType(reqPtr->GetNotificationType())) { reqPtr->SetDistributed(false); } - std::string instanceKey = GetAppInstanceKey(); reqPtr->SetAppInstanceKey(instanceKey); return proxy->Publish(label, reqPtr); @@ -281,18 +281,17 @@ ErrCode AnsNotification::PublishNotificationForIndirectProxy(const NotificationR if (IsNonDistributedNotificationType(reqPtr->GetNotificationType())) { reqPtr->SetDistributed(false); } - std::string instanceKey = GetAppInstanceKey(); - reqPtr->SetAppInstanceKey(instanceKey); return proxy->PublishNotificationForIndirectProxy(reqPtr); } -ErrCode AnsNotification::CancelNotification(int32_t notificationId) +ErrCode AnsNotification::CancelNotification(int32_t notificationId, std::string instanceKey) { - return CancelNotification("", notificationId); + return CancelNotification("", notificationId, instanceKey); } -ErrCode AnsNotification::CancelNotification(const std::string &label, int32_t notificationId) +ErrCode AnsNotification::CancelNotification(const std::string &label, int32_t notificationId, + std::string instanceKey) { ANS_LOGI("enter CancelNotification,notificationId:%{public}d", notificationId); HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); @@ -301,11 +300,10 @@ ErrCode AnsNotification::CancelNotification(const std::string &label, int32_t no ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - std::string instanceKey = GetAppInstanceKey(); return proxy->Cancel(notificationId, label, instanceKey); } -ErrCode AnsNotification::CancelAllNotifications() +ErrCode AnsNotification::CancelAllNotifications(std::string instanceKey) { ANS_LOGI("CancelAllNotifications called."); @@ -314,7 +312,6 @@ ErrCode AnsNotification::CancelAllNotifications() ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - std::string instanceKey = GetAppInstanceKey(); return proxy->CancelAll(instanceKey); } @@ -353,14 +350,14 @@ ErrCode AnsNotification::GetActiveNotificationNums(uint64_t &num) return proxy->GetActiveNotificationNums(num); } -ErrCode AnsNotification::GetActiveNotifications(std::vector> &request) +ErrCode AnsNotification::GetActiveNotifications(std::vector> &request, + std::string instanceKey) { sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - std::string instanceKey = GetAppInstanceKey(); return proxy->GetActiveNotifications(request, instanceKey); } @@ -1079,7 +1076,7 @@ ErrCode AnsNotification::GetShowBadgeEnabled(bool &enabled) return proxy->GetShowBadgeEnabled(enabled); } -ErrCode AnsNotification::CancelGroup(const std::string &groupName) +ErrCode AnsNotification::CancelGroup(const std::string &groupName, std::string instanceKey) { ANS_LOGI("enter CancelGroup,groupName:%{public}s", groupName.c_str()); if (groupName.empty()) { @@ -1092,7 +1089,6 @@ ErrCode AnsNotification::CancelGroup(const std::string &groupName) ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - std::string instanceKey = GetAppInstanceKey(); return proxy->CancelGroup(groupName, instanceKey); } @@ -1694,14 +1690,13 @@ ErrCode AnsNotification::GetSyncNotificationEnabledWithoutApp(const int32_t user return proxy->GetSyncNotificationEnabledWithoutApp(userId, enabled); } -ErrCode AnsNotification::SetBadgeNumber(int32_t badgeNumber) +ErrCode AnsNotification::SetBadgeNumber(int32_t badgeNumber, std::string instanceKey) { sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("SetBadgeNumber fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - std::string instanceKey = GetAppInstanceKey(); return proxy->SetBadgeNumber(badgeNumber, instanceKey); } @@ -2056,14 +2051,7 @@ ErrCode AnsNotification::UpdateNotificationTimerByUid(const int32_t uid, const b std::string AnsNotification::GetAppInstanceKey() const { - std::shared_ptrcontext = - OHOS::AbilityRuntime::Context::GetApplicationContext(); - if (context != nullptr) { - return context->GetCurrentInstanceKey(); - } else { - ANS_LOGE("GetApplicationContext for instacekey fail."); - return ""; - } + return ""; } ErrCode AnsNotification::DisableNotificationFeature(const NotificationDisable ¬ificationDisable) diff --git a/frameworks/js/napi/include/common.h b/frameworks/js/napi/include/common.h index 8fd8ce9ad..cb29b57f0 100644 --- a/frameworks/js/napi/include/common.h +++ b/frameworks/js/napi/include/common.h @@ -1852,6 +1852,7 @@ public: const std::string& value); static napi_value SetObjectUint32Property(const napi_env &env, napi_value& object, const std::string& key, uint32_t value); + static std::string GetAppInstanceKey(); private: static const int32_t ARGS_ONE = 1; static const int32_t ARGS_TWO = 2; diff --git a/frameworks/js/napi/src/common.cpp b/frameworks/js/napi/src/common.cpp index 4cc0cbc80..77ca5ada8 100644 --- a/frameworks/js/napi/src/common.cpp +++ b/frameworks/js/napi/src/common.cpp @@ -1539,5 +1539,17 @@ napi_value Common::SetDoNotDisturbProfile(const napi_env &env, const Notificatio } return NapiGetBoolean(env, true); } + +std::string Common::GetAppInstanceKey() +{ + std::shared_ptrcontext = + OHOS::AbilityRuntime::Context::GetApplicationContext(); + if (context != nullptr) { + return context->GetCurrentInstanceKey(); + } else { + ANS_LOGE("GetApplicationContext for instacekey fail."); + return ""; + } +} } // namespace NotificationNapi } // namespace OHOS diff --git a/frameworks/js/napi/src/manager/napi_cancel.cpp b/frameworks/js/napi/src/manager/napi_cancel.cpp index 198307c68..96baa784e 100644 --- a/frameworks/js/napi/src/manager/napi_cancel.cpp +++ b/frameworks/js/napi/src/manager/napi_cancel.cpp @@ -59,8 +59,9 @@ napi_value NapiCancel(napi_env env, napi_callback_info info) asynccallbackinfo->info.errorCode = NotificationHelper::CancelAsBundleWithAgent( asynccallbackinfo->option, asynccallbackinfo->id); } else { - asynccallbackinfo->info.errorCode = - NotificationHelper::CancelNotification(asynccallbackinfo->label, asynccallbackinfo->id); + std::string instanceKey = Common::GetAppInstanceKey(); + asynccallbackinfo->info.errorCode = NotificationHelper::CancelNotification( + asynccallbackinfo->label, asynccallbackinfo->id, instanceKey); } } }, @@ -120,7 +121,9 @@ napi_value NapiCancelAll(napi_env env, napi_callback_info info) ANS_LOGD("NapiCancelAll work excute."); AsyncCallbackInfoCancel *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { - asynccallbackinfo->info.errorCode = NotificationHelper::CancelAllNotifications(); + std::string instanceKey = Common::GetAppInstanceKey(); + asynccallbackinfo->info.errorCode = + NotificationHelper::CancelAllNotifications(instanceKey); } }, [](napi_env env, napi_status status, void *data) { @@ -182,8 +185,9 @@ napi_value NapiCancelGroup(napi_env env, napi_callback_info info) if (asynccallbackinfo) { ANS_LOGI("asynccallbackinfo->params.groupName = %{public}s", asynccallbackinfo->params.groupName.c_str()); - asynccallbackinfo->info.errorCode = - NotificationHelper::CancelGroup(asynccallbackinfo->params.groupName); + std::string instanceKey = Common::GetAppInstanceKey(); + asynccallbackinfo->info.errorCode = NotificationHelper::CancelGroup( + asynccallbackinfo->params.groupName, instanceKey); } }, [](napi_env env, napi_status status, void *data) { diff --git a/frameworks/js/napi/src/manager/napi_display_badge.cpp b/frameworks/js/napi/src/manager/napi_display_badge.cpp index 234664e0e..8bbced666 100644 --- a/frameworks/js/napi/src/manager/napi_display_badge.cpp +++ b/frameworks/js/napi/src/manager/napi_display_badge.cpp @@ -274,8 +274,9 @@ napi_value NapiSetBadgeNumber(napi_env env, napi_callback_info info) AsyncCallbackSetBadgeNumber *asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { ANS_LOGI("option.badgeNumber: %{public}d", asynccallbackinfo->params.badgeNumber); + std::string instanceKey = Common::GetAppInstanceKey(); asynccallbackinfo->info.errorCode = NotificationHelper::SetBadgeNumber( - asynccallbackinfo->params.badgeNumber); + asynccallbackinfo->params.badgeNumber, instanceKey); } }, AsyncCompleteCallbackNapiSetBadgeNumber, diff --git a/frameworks/js/napi/src/manager/napi_get_active.cpp b/frameworks/js/napi/src/manager/napi_get_active.cpp index 4fc167a53..0fedf9e8c 100644 --- a/frameworks/js/napi/src/manager/napi_get_active.cpp +++ b/frameworks/js/napi/src/manager/napi_get_active.cpp @@ -201,8 +201,10 @@ napi_value NapiGetActiveNotifications(napi_env env, napi_callback_info info) ANS_LOGD("NapiGetActiveNotifications work excute."); auto asynccallbackinfo = static_cast(data); if (asynccallbackinfo) { + std::string instanceKey = Common::GetAppInstanceKey(); asynccallbackinfo->info.errorCode = - NotificationHelper::GetActiveNotifications(asynccallbackinfo->requests); + NotificationHelper::GetActiveNotifications( + asynccallbackinfo->requests, instanceKey); } }, AsyncCompleteCallbackNapiGetActiveNotifications, diff --git a/frameworks/js/napi/src/manager/napi_publish.cpp b/frameworks/js/napi/src/manager/napi_publish.cpp index 8d139fd4b..6d26825a8 100644 --- a/frameworks/js/napi/src/manager/napi_publish.cpp +++ b/frameworks/js/napi/src/manager/napi_publish.cpp @@ -55,9 +55,9 @@ napi_value NapiPublish(napi_env env, napi_callback_info info) "%{public}d", asynccallbackinfo->request.GetNotificationId(), asynccallbackinfo->request.GetContent()->GetContentType()); - - asynccallbackinfo->info.errorCode = - NotificationHelper::PublishNotification(asynccallbackinfo->request); + std::string instanceKey = Common::GetAppInstanceKey(); + asynccallbackinfo->info.errorCode = NotificationHelper::PublishNotification( + asynccallbackinfo->request, instanceKey); } }, [](napi_env env, napi_status status, void *data) { @@ -120,9 +120,9 @@ napi_value NapiShowNotification(napi_env env, napi_callback_info info) "%{public}d", asynccallbackinfo->request.GetNotificationId(), asynccallbackinfo->request.GetContent()->GetContentType()); - + std::string instanceKey = Common::GetAppInstanceKey(); asynccallbackinfo->info.errorCode = - NotificationHelper::PublishNotification(asynccallbackinfo->request); + NotificationHelper::PublishNotification(asynccallbackinfo->request, instanceKey); } }, [](napi_env env, napi_status status, void *data) { diff --git a/interfaces/inner_api/notification_helper.h b/interfaces/inner_api/notification_helper.h index 08c951e2b..f9ba88162 100644 --- a/interfaces/inner_api/notification_helper.h +++ b/interfaces/inner_api/notification_helper.h @@ -200,7 +200,8 @@ public: * This parameter must be specified. * @return Returns publish notification result. */ - static ErrCode PublishNotification(const NotificationRequest &request); + static ErrCode PublishNotification(const NotificationRequest &request, + std::string instanceKey = ""); /** * @brief Publishes a notification. @@ -223,7 +224,8 @@ public: * This parameter must be specified. * @return Returns publish notification result. */ - static ErrCode PublishNotification(const std::string &label, const NotificationRequest &request); + static ErrCode PublishNotification(const std::string &label, const NotificationRequest &request, + std::string instanceKey = ""); /** * @brief Cancels a published notification. @@ -233,7 +235,7 @@ public: * Otherwise, this method does not take effect. * @return Returns cancel notification result. */ - static ErrCode CancelNotification(int32_t notificationId); + static ErrCode CancelNotification(int32_t notificationId, std::string instanceKey = ""); /** * @brief Cancels a published notification matching the specified label and notificationId. @@ -242,7 +244,8 @@ public: * @param notificationId Indicates the ID of the notification to cancel. * @return Returns cancel notification result. */ - static ErrCode CancelNotification(const std::string &label, int32_t notificationId); + static ErrCode CancelNotification(const std::string &label, int32_t notificationId, + std::string instanceKey = ""); /** * @brief Cancels all the published notifications. @@ -250,7 +253,7 @@ public: * @note To cancel a specified notification, see CancelNotification(int32_t). * @return Returns cancel all notifications result. */ - static ErrCode CancelAllNotifications(); + static ErrCode CancelAllNotifications(std::string instanceKey = ""); /** * @brief Cancels a published agent notification. @@ -289,7 +292,8 @@ public: * @param request Indicates active NotificationRequest objects of the current application. * @return Returns get active notifications result. */ - static ErrCode GetActiveNotifications(std::vector> &request); + static ErrCode GetActiveNotifications(std::vector> &request, + std::string instanceKey = ""); /** * @brief Checks whether your application has permission to publish notifications by calling @@ -771,7 +775,7 @@ public: * @param groupName Indicates the specified group name. * @return Returns cancel group result. */ - static ErrCode CancelGroup(const std::string &groupName); + static ErrCode CancelGroup(const std::string &groupName, std::string instanceKey = ""); /** * @brief Remove the notification of the specified group of the specified application. @@ -992,7 +996,7 @@ public: * @param badgeNumber The badge number. * @return Returns set badge number result. */ - static ErrCode SetBadgeNumber(int32_t badgeNumber); + static ErrCode SetBadgeNumber(int32_t badgeNumber, std::string instanceKey = ""); /** * @brief Set badge number by bundle. -- Gitee