
回复
1.notificationManager.getActiveNotificationCount
支持设备Phone2in1TabletCarWearable
getActiveNotificationCount(callback: AsyncCallback<number>): void
获取当前应用未删除的通知数。使用callback异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
let getActiveNotificationCountCallback = (err: BusinessError, data: number): void => {
if (err) {
console.error(`Failed to get active notification count. Code is ${err.code}, message is ${err.message}`);
} else {
console.info(`Succeeded in getting active notification count, data is ` + JSON.stringify(data));
}
}
notificationManager.getActiveNotificationCount(getActiveNotificationCountCallback);
2.notificationManager.getActiveNotificationCount
支持设备Phone2in1TabletCarWearable
getActiveNotificationCount(): Promise<number>
获取当前应用未删除的通知数。使用Promise异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
notificationManager.getActiveNotificationCount().then((data: number) => {
console.info(`Succeeded in getting active notification count, data is ` + JSON.stringify(data));
}).catch((err: BusinessError) => {
console.error(`Failed to get active notification count. Code is ${err.code}, message is ${err.message}`);
});
本文主要参考引用自HarmonyOS官方网站